Skip to content

Does SimulateCustomPolicy evaluate lambda:SourceFunctionArn context for S3 identity policies?

0

I am investigating an unexpected IAM Custom Policy Simulator result involving lambda:SourceFunctionArn. I am not using simulation results as live permission proof, and I do not want to remove the source-function condition as a workaround.

The inputs below are an anonymized reconstruction. The decision table summarizes the original captured tests, NOT a fresh execution using these placeholder identifiers. Account, resource names and the object path have been replaced. No AWS request IDs, private policies, credentials or raw captures are published.

Minimal identity policy: { "Version": "2012-10-17", "Statement": [ { "Sid": "ExactDiagnosticRead", "Effect": "Allow", "Action": "s3:GetObjectVersion", "Resource": "arn:aws:s3:::example-simulator-bucket/example.png", "Condition": { "ArnEquals": { "lambda:SourceFunctionArn": "arn:aws:lambda:us-east-1:123456789012:function:example-source-function" } } } ] }

SimulateCustomPolicy input: { "PolicyInputList": [ "{"Version":"2012-10-17","Statement":[{"Sid":"ExactDiagnosticRead","Effect":"Allow","Action":"s3:GetObjectVersion","Resource":"arn:aws:s3:::example-simulator-bucket/example.png","Condition":{"ArnEquals":{"lambda:SourceFunctionArn":"arn:aws:lambda:us-east-1:123456789012:function:example-source-function"}}}]}" ], "ActionNames": [ "s3:GetObjectVersion" ], "ResourceArns": [ "arn:aws:s3:::example-simulator-bucket/example.png" ], "ContextEntries": [ { "ContextKeyName": "lambda:SourceFunctionArn", "ContextKeyValues": [ "arn:aws:lambda:us-east-1:123456789012:function:example-source-function" ], "ContextKeyType": "string" } ], "MaxItems": 1000 }

For the missing-source-deny control, append this statement to the same identity policy and keep the exact same ContextEntries: { "Sid": "DenyMissingSource", "Effect": "Deny", "Action": "s3:GetObjectVersion", "Resource": "arn:aws:s3:::example-simulator-bucket/example.png", "Condition": { "Null": { "lambda:SourceFunctionArn": "true" } } }

Original observed results: Variant Decision Unconditional allow (condition omitted) allowed ArnEquals lambda:SourceFunctionArn, exact string implicitDeny Same exact context using type stringList implicitDeny Exact-source allow plus Null:true deny explicitDeny Equivalent diagnostic policy/context: aws:SourceArn allowed Source context omitted from exact-source allow implicitDeny Wrong source ARN supplied to exact-source allow implicitDeny

In the exact-context cases, MissingContextValues was EMPTY. The explicit-deny response's matched-statement positions map to DenyMissingSource in the original policy. I am not claiming AWS returned that Sid directly or explicitly reported the supplied key as missing. Only the omitted-context control explicitly listed lambda:SourceFunctionArn in MissingContextValues.

The aws:SourceArn row is an in-memory simulator control, not a proposed production substitute: it is a different context key with different semantics. No policies were installed or loosened.

For the original run:

  • Context discovery on the original policy recognized lambda:SourceFunctionArn.
  • The final serialized Query bodies were captured before send and compared with the intended inputs. The exact key, unqualified ARN and string type were present.
  • Raw response XML was preserved privately; responses were HTTP 200, with zero retries and no truncated simulation results.
  • SDK versions were boto3 1.43.83 and botocore 1.43.97.
  • The endpoint was https://iam.amazonaws.com/.
  • No ResourcePolicy or CallerArn was supplied for the minimal tests.
  • The original source function and bucket were proposed, not installed. No actual S3 action or Lambda invocation was performed.

AWS's Lambda guide documents ArnEquals with an unqualified source-function ARN for identity-based S3 permissions: https://docs.aws.amazon.com/lambda/latest/dg/permissions-source-function-arn.html

The simulator reference describes ContextEntries and permits simulated resources that do not exist; it also warns that simulation may differ from live behavior: https://docs.aws.amazon.com/IAM/latest/APIReference/API_SimulateCustomPolicy.html

The ContextEntry type reference lists string/stringList but no separate ARN type: https://docs.aws.amazon.com/IAM/latest/APIReference/API_ContextEntry.html

Questions:

  1. Is lambda:SourceFunctionArn supported as a supplied ContextEntry for this custom identity-policy simulation, or is it handled specially?
  2. Does the source Lambda ARN itself need to refer to an existing function, even when the simulated S3 resource may be nonexistent?
  3. Why would Null:true match when the exact key/value is present in the finalized request, while MissingContextValues remains empty?
  4. Is there a documented request form or limitation that explains this result without removing the source-function guard?

I can provide the original request IDs and raw evidence privately to AWS through an approved private channel. I will not attach account-specific captures to a public forum.

  • We observed a similar result for dynamodb:GetItem in a completed, bounded SimulateCustomPolicy diagnostic. The unconditional allow returned allowed; adding only ArnEquals on lambda:SourceFunctionArn returned implicitDeny, with MissingContextValues empty. The supplied ContextKeyType was string. Offline checks confirmed that the supplied value exactly matched the policy's unqualified function ARN, with no alias, version, whitespace or non-ASCII characters.

    Separate condition-isolation cases for DynamoDB LeadingKeys, Null on LeadingKeys, and DateLessThan each returned allowed. These are existing results, not new tests. No live function invocation was used to establish effective access. We have not performed the Null-on-SourceFunctionArn test described in this thread.

    Can AWS confirm whether SimulateCustomPolicy accepts supplied lambda:SourceFunctionArn context when evaluating DynamoDB actions, or whether this credential-derived key has a simulator limitation? Is there a documented validation route that preserves the exact source-function restriction without deploying permissions or invoking a function? We are retaining the restriction and treating effective access as unverified. We can share only anonymized details publicly; no account identifiers or raw captures are included here.

1 Answer
0

Your control results narrow it down to one thing: the simulator treated the key you supplied as absent.

Why your results point there

  • Null: true produced an explicit deny even though you supplied the exact key and value. A Null: true condition only matches when the key is absent from the evaluated context.
  • With that in mind, everything else fits. ArnEquals gave implicit deny because there was nothing to compare against. string and stringList behaved the same. A correct ARN and a wrong ARN gave identical results.
  • The aws:SourceArn control worked, so your request formatting and context handling aren't the cause. The difference is the key itself.

Your questions

  1. Is the key supported as a supplied context entry? It looks like it's handled specially. Lambda's documentation says it "injects the source function ARN into the credentials context" for API requests made from inside the execution environment. That means the key comes from the session credentials, not from the request. My guess, which AWS hasn't confirmed, is that the simulator doesn't let ContextEntries set credential-derived keys, or that it drops supplied keys whose prefix isn't aws: and isn't the service of the action being simulated. In this case the action is s3: and the key is lambda:.
  2. Does the function need to exist? Probably not. The result looks like a missing key, not a mismatched value, so whether the ARN refers to a real function wouldn't change it.
  3. Why does Null: true match while MissingContextValues is empty? MissingContextValues appears to be calculated by comparing the keys your policy references against the keys you supplied in the request. It doesn't reflect what the evaluator actually used. If the evaluator drops the key afterwards, you get exactly this inconsistency.
  4. Is this documented? I couldn't find it documented. The same pattern has been reported for ec2:SourceInstanceARN with sqs:SendMessage. EC2 also injects that key from the platform, and it also wasn't evaluated even with matching context. These are two cases with the same shape.

A test to tell the two guesses apart

Keep the same condition and context but change the simulated action to a Lambda action, for example lambda:GetFunction on *.

  • If that returns allowed, the simulator evaluates the key only for its own service.
  • If it's still denied, the simulator is ignoring credential-injected keys entirely.

Either result is useful to include when you send AWS your request IDs.

Validating the policy without removing the guard

Since the simulator can't test this key, test it live with throwaway resources:

  • Positive case: a test function using the role reads the test object, and the read succeeds.
  • Negative case, key absent: assume the same role outside Lambda and attempt the same read. It should get AccessDenied, and your DenyMissingSource statement should be what denies it.
  • Negative case, wrong value: a second function using the same role should also be denied.

Use the unqualified function ARN in the policy. Lambda's documentation says ARNs with a version or alias don't match. Before deploying, IAM Access Analyzer ValidatePolicy can check the policy's syntax and key names.

Sources:

EXPERT

answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.