Arp Spoofing in Firestore
How ARP Spoofing Manifests in Firestore
ARP spoofing is a local network attack where an adversary sends falsified ARP messages to link their MAC address with the IP address of a legitimate gateway or server, enabling man-in-the-middle (MITM) interception. When targeting applications using Firestore, the attack typically occurs on the client's local network (e.g., public Wi-Fi, compromised router) before traffic reaches Google's infrastructure.
Firestore clients communicate via HTTPS to endpoints like firestore.googleapis.com or custom domains. An attacker performing ARP spoofing can redirect this traffic to a rogue server they control. If the Firestore client SDK or application does not strictly validate TLS certificates or server identity, the malicious server can intercept, modify, or steal data. Specific Firestore attack patterns include:
- Credential Harvesting: Intercepting unauthenticated requests to capture Firebase Authentication tokens or API keys embedded in client code.
- Data Injection/Manipulation: Altering Firestore REST API requests/responses to inject malicious documents, modify query results, or exfiltrate data.
- Session Hijacking: Stealing
Authorization: Bearer <token>headers to impersonate a user. - Custom Domain Exploitation: If an app uses a custom domain (e.g.,
api.yourapp.com) pointing to Firestore, ARP spoofing can redirect to a server with a mismatched or self-signed certificate, potentially bypassing weak validation.
While Firestore enforces TLS 1.2+ and Google manages server certificates, client-side validation is ultimately the application's responsibility. Vulnerable implementations might disable certificate checks for debugging or use outdated SDKs with known TLS weaknesses (e.g., CVE-2020-28052 in older OkHttp versions affecting Android Firestore clients).
Firestore-Specific Detection
Detecting ARP spoofing's impact on Firestore requires examining both network-level anomalies and application-layer inconsistencies. Since ARP spoofing operates below the HTTP layer, direct detection from Firestore is impossible; instead, look for symptoms of MITM in API interactions.
1. TLS/SSL Certificate Anomalies: Use tools to verify Firestore endpoint certificates. A MITM server might present a different certificate or chain. For custom domains, check if the certificate matches the expected domain and is issued by a trusted CA. Example using OpenSSL:
openssl s_client -connect your-custom-domain.com:443 -servername your-custom-domain.com | openssl x509 -noout -subject
2. middleBrick API Scanning: While middleBrick does not scan network layers, it can reveal inconsistencies indicative of MITM. Run a scan against your Firestore REST endpoint (e.g., https://your-project.firebaseio.com or custom domain). Key findings to watch for:
- Encryption Check: middleBrick flags weak TLS configurations or certificate validation issues. If your endpoint responds with a certificate that doesn't match the domain or uses outdated ciphers, it scores poorly here.
- Authentication Bypass: If ARP spoofing redirects to a server that incorrectly accepts unauthenticated requests (e.g., missing
Authorizationheader validation), middleBrick's Authentication test may detect unauthorized data access. - Response Inconsistency: Compare middleBrick's findings with your OpenAPI/Swagger spec. Unexpected fields, schema violations, or altered error messages could indicate response tampering.
3. Client-Side Logging: In your application, enable detailed Firestore SDK logging (e.g., FirebaseFirestore.setLogLevel(Logger.Level.DEBUG) in Android) to monitor TLS handshake failures or certificate pinning errors, which may signal MITM attempts.
Firestore-Specific Remediation
Remediation focuses on strengthening client-side validation and leveraging Firestore's native security features to mitigate MITM risks, even if ARP spoofing occurs.
1. Enforce Strict Certificate Validation & Pinning:
- Ensure your Firestore SDK is up-to-date to avoid known TLS vulnerabilities.
- For mobile apps (Android/iOS), implement certificate pinning. Example using Android's
NetworkSecurityConfig:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="false">
<domain includeSubdomains="true">firebaseio.com</domain>
<domain includeSubdomains="true">firestore.googleapis.com</domain>
<pin-set expiration="2025-12-31">
<pin digest="SHA-256">YourPinnedPublicKeyHashHere</pin>
</pin-set>
</domain-config>
</network-security-config>For custom domains, pin the exact certificate from your CDN (e.g., Firebase Hosting or Cloud CDN).
2. Enable Firebase App Check: App Check ensures only your authentic app can access Firestore, blocking requests from unauthorized clients (including those potentially hijacked via MITM). Register your app with a provider (reCAPTCHA for web, Device Check for iOS, Play Integrity for Android). Example initialization for web:
import { initializeApp } from "firebase/app";
import { initializeAppCheck, ReCaptchaV3Provider } from "firebase/app-check";
const firebaseApp = initializeApp({ /* your config */ });
const appCheck = initializeAppCheck(firebaseApp, {
provider: new ReCaptchaV3Provider('your-recaptcha-key'),
isTokenAutoRefreshEnabled: true
});3. Use Custom Domains with Strict SSL: Configure a custom domain in Firebase Hosting that proxies to Firestore. Firebase Hosting enforces HTTPS and manages certificates, reducing reliance on client-side validation. Ensure your DNS points exclusively to Firebase's IPs and that HSTS is enabled.
4. Validate Server Identity at Runtime: In custom clients, after obtaining the Firestore endpoint URL, programmatically verify the server's certificate matches Google's expected fingerprints. This is advanced but adds defense-in-depth.
5. Network Segmentation: While not Firestore-specific, advise users to avoid public Wi-Fi for sensitive operations or use a VPN to prevent local ARP spoofing.