Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
A serverless function has two permission sets: the identity it uses to call other services, and the policy controlling who may invoke it. Getting either wrong converts a small bug into a cloud breach.

What Are Serverless Function Permissions?
Every serverless function carries two distinct sets of permissions, and conflating them causes most of the trouble. The first is the identity the function runs as — an execution role on AWS Lambda, a managed identity on Azure Functions, a service account on Google Cloud Functions — which determines what the code can reach. The second is the policy governing who or what may invoke the function in the first place. The first decides the damage; the second decides who gets to cause it.
When a function calls another service, it does so with credentials the platform injects at runtime. Those credentials are short-lived, which is genuinely better than an embedded access key, but their scope is whatever the role says. A function that processes uploaded invoices and holds s3:* on Resource: "*" can read every bucket in the account, including the one holding database backups.
Default behaviour makes this worse on some platforms than others. On Google Cloud, functions historically defaulted to the App Engine or Compute Engine default service account, which carries the Editor role across the project — close to administrative access for anything that bothers to use it. On AWS, the managed AWSLambdaBasicExecutionRole is appropriately narrow, but teams routinely attach broad managed policies alongside it because determining the exact actions needed is tedious.
The consequence is predictable. An injection flaw, a vulnerable dependency, or a server-side request forgery in a function with a narrow role produces a contained incident. The same flaw in a function with a wide role produces a breach of the account. This is the mechanism behind a great many cloud incidents: the application weakness was ordinary, and the identity attached to it was not.
Resource-based policies control the other direction. On Lambda, every event source — API Gateway, an S3 bucket, EventBridge, SNS — needs an explicit permission statement naming it. Two mistakes recur:
lambda:InvokeFunction to "*" without a source account or source ARN condition lets any AWS account trigger your function, with whatever payload they choose.AuthType: NONE are public HTTPS endpoints with no gateway, no throttling, and no authentication. They are useful for a demonstration and dangerous in an account that also holds data.The equivalent on Azure is the function access key and the authorisation level set per trigger; on Google Cloud it is the roles/cloudfunctions.invoker binding, where granting it to allUsers has the same effect as a public URL.
The honest difficulty is that nobody knows which actions a function needs until it has run. Three approaches make this tractable:
One function, one role. Sharing a role across several functions means the union of everything any of them needs, which is how roles become administrative by accretion.
Permissions sit next to a few other habits worth correcting at the same time. Secrets placed in environment variables are visible to anyone with lambda:GetFunctionConfiguration and appear in the console, in deployment artefacts, and often in logs; a secrets manager reference costs little and removes the exposure. Logging permissions should be mandatory rather than optional, because a function with no write access to its log group is invisible during an investigation. And functions deployed into a VPC inherit security group rules that frequently allow far more egress than the workload needs, which is what lets an attacker exfiltrate once they have the credentials.
For an existing estate, start by listing every function with its role and sorting by the breadth of that role. Wildcard actions, wildcard resources, and attached administrator policies go to the top. Separately, list every function with a public URL or an unconditioned resource policy, since those are the entry points. Where the two lists intersect you have an internet-reachable function with wide permissions, and that is where to spend the first week.
This work belongs alongside broader serverless security and identity and access management practice. If you want the attack paths traced rather than the policies merely listed, our cloud security services test exactly that.
On Google Cloud the default compute and App Engine service accounts have historically held the Editor role across the whole project, which permits reading and modifying almost every resource in it. A function left on that identity hands project-wide access to anyone who compromises the code. Create a dedicated service account per function with only the bindings it needs, and disable automatic role grants for default accounts.
They are safe when the authentication type is AWS_IAM and the resource policy names specific principals. With AuthType set to NONE the endpoint is publicly invokable by anyone who learns the URL, with no gateway in front to provide throttling, request validation, or a web application firewall. For anything internet-facing that matters, put API Gateway or CloudFront in front of the function instead.
Start with policy analysis: list roles containing wildcard actions, wildcard resources, or attached administrator policies, which most cloud posture tools will do for you. Then use access advisor data or unused-access findings to compare granted permissions against what each role has actually used over the last ninety days. The difference between the two is usually most of the policy.
No. Environment variables are readable through the management API by anyone who can describe the function, appear in infrastructure-as-code repositories, and often end up in logs or error output. Store the value in a secrets manager or parameter store, grant the execution role permission to read that one secret, and fetch it at cold start with caching. Rotation then happens in one place.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.