When a contract ends, a developer often forgets to delete a service account key that was baked into a helper script, creating a risk of credential leakage. The next team that inherits the code runs the same script, unintentionally sending the key to a downstream function that logs its input. By the time the breach is noticed, the credential has been copied to an external logging sink, giving an attacker persistent access.
Function‑as‑a‑service platforms encourage developers to treat remote procedures like ordinary library calls. The convenience hides a dangerous assumption: the caller can pass any payload, including secrets, without a guard at the network edge. When AI agents generate code or when CI pipelines invoke functions automatically, the risk of credential leakage multiplies because the payload is often built from dynamic inputs.
In many organizations the only control is an IAM policy that says, “Only this service account may invoke the function.” That policy determines *who* can start a request, but it does nothing to inspect the content of the request. The function execution itself may log the raw request, store it in a database, or forward it to another service, effectively exposing the secret to anyone who can read those downstream logs.
What to watch for in function calling
- Hard‑coded secrets in source files, templates, or environment variables that are concatenated into request bodies.
- Dynamic construction of request payloads that include tokens received from other services without validation.
- Over‑scoped service accounts that can perform privileged actions beyond the intended function scope.
- AI‑generated code that pulls credentials from the prompt context and injects them into API calls.
- Logging configurations that capture full request bodies, unintentionally persisting credentials.
Each of these patterns can turn a legitimate function call into a conduit for credential leakage. The key is to recognize that the problem is not just “who can call” but “what is being sent”.
Why typical safeguards fall short
Standard IAM checks are performed before the request reaches the function, so they cannot see the payload. Auditing tools that record who invoked a function also miss the actual data that traveled across the wire. Inline data masking, if it exists, is usually applied inside the function after the secret has already been processed and possibly logged. Approval workflows that sit downstream do not prevent a malicious payload from being executed in the first place.
Because the enforcement point is missing, organizations often discover credential leakage only after the fact, through anomalous log entries, unexpected network traffic, or a compromised downstream system.
