Identity and Access Management

A review finds that a Lambda function's resource-based policy allows the s3.amazonaws.com service principal to invoke the function with no conditions. Only the company's bucket uploads-prod in account 111122223333 should be able to trigger it. Which correction removes the unintended authorization while keeping the trigger working?

Show the answer

Correct answerA. Add aws:SourceArn for the bucket and aws:SourceAccount for 111122223333 to the statement.

AWhy this is right: The source conditions restrict the S3 service principal to invocations caused by that one bucket in that account.

BWhy not this: The execution role governs the function's own calls, not invocations of the function.

CWhy not this: Archiving a finding only changes how it is tracked; the policy still grants the access.

DWhy not this: S3 invokes the function as its service principal, so an account-principal grant would break the trigger.

Without conditions, any bucket in any account could cause S3 to invoke the function (a confused deputy). Adding aws:SourceArn for the bucket and aws:SourceAccount for the owning account limits the grant to that bucket. The execution role controls what the function can do, not who can invoke it, and archiving a finding changes nothing.