<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1091895793769148&amp;ev=PageView&amp;noscript=1">

How AI Agents Escalate Privileges Through AWS Lambda (and How to Audit for It)

Kiran Elengickal Oct 8, 2026, 1:43:16 PM 8 min read

A single dispatcher Lambda with too many permissions can give a sandboxed AI agent the same reach as an account admin. Below are six IAM controls, each with a policy example, that shut that path on AWS.

How a setup function turned into an escalation path

CVE-2026-94384 is a useful case study for two reasons. It shows how privilege escalation through Lambda works in practice, and it shows a design that AI coding agents are prone to rebuild.

Any Lambda function your agent (or any other automation) can invoke is part of that agent's attack surface, especially if the function runs with broad permissions. Reviewing only the agent's own IAM role misses this.

The practical takeaways come down to three things: allow only named callers to invoke setup and dispatcher functions, require a permissions boundary on every role an agent can create, and delete setup functions once setup is finished.

AWS published its security bulletin for CVE-2026-94384 on September 22. The flaw, rated 8.1 under CVSS 3.1, is a missing authorization check in sfExecuteAWSService, a function included in AmazonConnectSalesforceLambda. That Serverless Application Repository app integrates Amazon Connect with Salesforce. Versions 5.15 to 5.24.16 are affected. Version 5.26, which contains the fix, came out on June 29, close to three months before the issue was made public.

How the flaw works is simple. sfExecuteAWSService exists for initial setup only. It receives parameters from its caller, hands them to AWS service APIs and makes those calls with its own execution role. At no point does it check whether the caller is entitled to make the request.

That means any IAM principal allowed to call lambda:InvokeFunction on this one function can perform actions its own identity is explicitly denied, limited only by what the function's execution role allows. In effect, the function acts as a privilege escalation proxy.

Version 5.26 adds a SalesforceExecuteAWSServiceUser parameter that controls which principal may invoke the function. AWS also recommends deleting or disabling sfExecuteAWSService after setup.

A human built this function, not an AI model. Still, it matches the design AI coding agents tend to generate on their own, and they generate it far more often.

Why AI coding agents keep building this pattern

Give a coding agent the job of automating infrastructure setup or connecting an internal workflow, and it may well arrive at nearly this design. Each decision it makes along the way looks sensible from where it sits.

A generic dispatcher takes the least effort. One handler that receives a service name, an action and a payload deals with every case in a few lines, and reviewers see neat code.

If setup hits AccessDenied, widening the execution role is the quickest way through. Working out the least privilege needed is slower, and nothing in the agent's loop rewards it for questioning whether the bigger grant is safe.

Once the task reports success, the agent moves on. Unless someone instructed it to, it won't delete the setup function or revisit the trust policy it wrote.

The second half of the risk appears when the agent is the one making the call. Teams often assume that a narrow agent role, such as lambda:InvokeFunction inside a sandbox, keeps the blast radius small. This CVE shows where that assumption fails.

When an over-privileged function that doesn't validate input is within reach, the agent needs no admin rights of its own. The function's ARN and a well-formed payload are enough. Those can arrive through prompt injection, a hijacked goal, or a CI job aimed at the wrong ARN. One generic dispatcher with a privileged role gives a low-privilege agent the full power of that role.

How to secure IAM permissions for AI agents and Lambda dispatcher functions

The examples below use placeholder account IDs and resource names. Test them in a sandbox account before you roll them out.

1. Don't allow generic API dispatchers

No agent or developer should ship a Lambda that takes free-form service and action parameters. This simplified handler shows the pattern behind the CVE:

import boto3

def handler(event, context):
    # The caller chooses the service, the API and the arguments
    client = boto3.client(event["service"])
    return getattr(client, event["action"])(**event["params"])

Every action the execution role permits is now available to every caller. A safer handler performs one specific operation and checks its input before acting:

import json
import re
import boto3

s3 = boto3.client("s3")
BUCKET = "app-config-bucket"
KEY_PATTERN = re.compile(r"config/[a-z0-9-]{1,64}\.json")

def handler(event, context):
    key = event.get("key", "")
    if not KEY_PATTERN.fullmatch(key):
        raise ValueError("invalid key")
    s3.put_object(Bucket=BUCKET, Key=key, Body=json.dumps(event["config"]))

Add this rule to your agent instructions, then back it up in CI. A static analysis rule, in Semgrep for example, can catch dynamic calls such as getattr on SDK clients.

2. Control which roles an agent can pass to Lambda

An agent can deploy a function with a privileged role only if it has permission to pass that role. Scope iam:PassRole to a short list of pre-approved roles, and allow passing them to Lambda only:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PassOnlyApprovedLambdaRoles",
      "Effect": "Allow",
      "Action": "iam:PassRole",
      "Resource": "arn:aws:iam::111122223333:role/agent-lambda-*",
      "Condition": {
        "StringEquals": { "iam:PassedToService": "lambda.amazonaws.com" }
      }
    }
  ]
}

This blocks the problem at deployment time, before a privileged dispatcher can exist.

3. Put permissions boundaries on the roles your agents create

In this CVE, the excess privilege sat in the dispatcher's execution role rather than the caller's role. A boundary on the agent's own role therefore doesn't go far enough. Each role an agent creates for a function needs a boundary too, and the agent must have no way to remove or change it.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ManageRolesOnlyWithBoundary",
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole",
        "iam:PutRolePolicy",
        "iam:AttachRolePolicy",
        "iam:PutRolePermissionsBoundary"
      ],
      "Resource": "arn:aws:iam::111122223333:role/agent-lambda-*",
      "Condition": {
        "StringEquals": {
          "iam:PermissionsBoundary": "arn:aws:iam::111122223333:policy/agent-boundary"
        }
      }
    },
    {
      "Sid": "ProtectTheBoundary",
      "Effect": "Deny",
      "Action": [
        "iam:DeleteRolePermissionsBoundary",
        "iam:CreatePolicyVersion",
        "iam:DeletePolicyVersion",
        "iam:SetDefaultPolicyVersion",
        "iam:DeletePolicy"
      ],
      "Resource": [
        "arn:aws:iam::111122223333:role/*",
        "arn:aws:iam::111122223333:policy/agent-boundary"
      ]
    }
  ]
}

The first statement lets the agent create or modify only roles that carry the boundary. The second blocks it from deleting the boundary or editing the boundary policy. To catch problems before deployment, IAM Access Analyzer custom policy checks can fail a CI build whenever a policy grants access you've ruled out.

4. Remove wildcard invoke grants

Developers shouldn't get lambda:InvokeFunction by default. Narrowing the function's resource policy won't solve this on its own. Inside one account, a call goes through if either the caller's identity policy or the function's resource policy allows it, and Lambda resource policies can't deny.

So remove lambda:InvokeFunction on "*" from identity policies. Then add a Service Control Policy in AWS Organizations that denies invoking setup functions to every principal except your deployment pipeline:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "OnlyPipelineInvokesSetupFunctions",
      "Effect": "Deny",
      "Action": "lambda:InvokeFunction",
      "Resource": "arn:aws:lambda:*:*:function:setup-*",
      "Condition": {
        "ArnNotLike": {
          "aws:PrincipalArn": "arn:aws:iam::*:role/deploy-pipeline"
        }
      }
    }
  ]
}

This relies on a consistent naming convention for setup functions. SCPs also don't apply to the management account, so don't run workloads there.

5. Treat setup functions as temporary

If an agent creates a bootstrap function to seed a database or configure resources, the deployment script should delete that function when the run finishes. A helper that has to remain should be invocable only by the one principal that needs it, which is exactly what the SalesforceExecuteAWSServiceUser parameter does in 5.26. If it's rarely needed, keep it disabled until someone intentionally turns it back on.

6. Clean up setup leftovers now

If you run AmazonConnectSalesforceLambda 5.15 through 5.24.16, upgrade to 5.26 or later. Once setup is complete, delete or disable sfExecuteAWSService. The deployed function's name normally contains sfExecuteAWSService, so this command locates it in a region:

aws lambda list-functions \
  --query "Functions[?contains(FunctionName, 'sfExecuteAWSService')].[FunctionName, LastModified]" \
  --output table

Repeat it in each region where the integration is deployed. More broadly:

  • Use IAM Access Analyzer unused access findings to find roles that hold broad permissions but rarely use them.
  • Turn on CloudTrail data events for Lambda to see which principals invoke which functions. These events aren't logged by default and are billed separately, so begin with your setup and admin functions.
  • Search your repos for setup scripts an agent wrote during prototyping that were never removed after the demo.

The real risk is repetition, not invention

Agents are unlikely to invent new attack techniques inside your AWS account. The more realistic risk is that they repeat design mistakes people have made for years, only faster and in more places. And when a CVE like this one finally surfaces, the cleanup has usually become someone else's job.

References

About the author

Vice President of Global Alliances & Business Development at Siemba, leading strategic partnerships across hyperscalers, OEMs, ISVs, and emerging technology providers. With 20+ years of experience in cloud-native architectures, AI infrastructure, cybersecurity, and platform engineering, he focuses on building high-impact ecosystems, scaling joint solutions, and driving go-to-market execution. Kiran also serve as an Advisor at Abilytics, supporting strategy and growth in AI and platform engineering.

Kiran Elengickal