Cloud Functions Without Validation
Firebase Cloud Functions exposed as HTTP endpoints accept and process requests without verifying authentication tokens or validating input data.
How It Works
Firebase Cloud Functions can be deployed as HTTP endpoints accessible from the internet. Unlike callable functions that automatically verify Firebase Auth tokens, HTTP functions receive raw requests with no built-in authentication. If the function does not manually verify the Authorization header or Firebase ID token, anyone can invoke it. This is especially dangerous for functions that modify data, send emails, process payments, or access admin resources. The function URL is often discoverable from client-side code.
exports.deleteUser = functions.https.onRequest(async (req, res) => {
const { userId } = req.body;
await admin.auth().deleteUser(userId);
await admin.firestore().collection('users').doc(userId).delete();
res.json({ success: true });
});exports.deleteUser = functions.https.onCall(async (data, context) => {
if (!context.auth) {
throw new functions.https.HttpsError('unauthenticated', 'Must be signed in');
}
if (context.auth.uid !== data.userId) {
throw new functions.https.HttpsError('permission-denied', 'Cannot delete other users');
}
await admin.auth().deleteUser(context.auth.uid);
await admin.firestore().collection('users').doc(context.auth.uid).delete();
return { success: true };
});Real-World Example
In 2023, an e-commerce app had an HTTP Cloud Function for applying discount codes that lacked authentication. Attackers discovered the endpoint URL and applied unlimited discounts to orders, causing significant financial losses before the function was secured.
How to Prevent It
- Use onCall instead of onRequest for functions called from your app
- For HTTP functions, always verify the Firebase ID token from the Authorization header
- Validate and sanitize all input data with a schema validator
- Apply rate limiting using Firebase App Check or a middleware
Affected Technologies
Data Hogo detects this vulnerability automatically.
Scan Your Repo FreeRelated Vulnerabilities
Firestore Rules Allow Read/Write True
criticalFirestore security rules set to 'allow read, write: if true' give any user — authenticated or not — full access to read, create, modify, and delete all documents.
Realtime Database Without Authentication
criticalFirebase Realtime Database rules set '.read: true' and '.write: true' at the root level, allowing anyone on the internet to read and modify all data.
Firebase Storage Rules Permissive
highFirebase Cloud Storage rules allow any user to read, write, or delete files without authentication, exposing uploaded content and enabling file tampering.
Cascading Rules Misconfigured
highParent-level Firebase rules override restrictive child rules, unintentionally granting broader access than intended to nested collections and documents.