Concepts / Cloud security

Cloud security

Serverless injection

Also called function injection, template injection, serverless credential leak, env var exfiltration

A serverless function that folds untrusted input into a template or format string can be driven to reflect its own environment — where its role credentials live.

The function prints its own keys
The function prints its own keys

The input is not code. It is a variable name the template looks up in the function's environment, where the platform put the role's credentials.

Serverless injection makes a serverless function print its own secrets. The platform passes the function its role's credentials in environment variables. If caller input is folded into a template or format string that can resolve variables ({env.KEY}), a crafted field makes the response include them. No code execution is needed. Treat input as data, never as template, and scope the role ([[cloud-least-privilege]]). Compare [[instance-metadata-ssrf|the metadata service]].

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab