Skip to main content

DVA-C02 practice question · Security

A Lambda function's resource-based policy allows the s3.amazonaws.com service principal to invoke the function in…

A Lambda function's resource-based policy allows the s3.amazonaws.com service principal to invoke the function in response to S3 event notifications. Which risk does adding an aws:SourceArn condition for the team's bucket to this policy mitigate?

  • AA different bucket, possibly owned by another account, using S3 to invoke the function (confused deputy)
  • BEvent payloads being modified in transit between S3 and Lambda before the function receives them
  • CThe function's execution role granting more permissions than the code needs once it is invoked
  • DAnonymous internet clients invoking the function through a function URL that uses auth type NONE
Show the answer and explanation

Correct answer: A) A different bucket, possibly owned by another account, using S3 to invoke the function (confused deputy)

Adding aws:SourceArn to an S3 invoke permission limits invocation to the intended bucket, which prevents the confused deputy problem. Because S3 bucket ARNs don't include an account ID, AWS recommends also adding aws:SourceAccount.

Why each option is right or wrong

  • A) Correct. If the policy only names the S3 service principal, any bucket configured to notify the function can invoke it through S3. Restricting aws:SourceArn to the expected bucket prevents this confused deputy scenario. Bucket ARNs don't contain an account ID, and a deleted bucket name could be reused by another account, so AWS also recommends adding aws:SourceAccount.
  • B) Incorrect. aws:SourceArn controls which source resource is authorized to invoke the function. It doesn't sign the event payload or check its integrity.
  • C) Incorrect. What the function can do after it is invoked depends on its execution role. The resource-based policy controls who can invoke the function, not what the function can access.
  • D) Incorrect. Function URL access is governed by the URL's auth type and lambda:InvokeFunctionUrl permissions. A SourceArn condition on an S3 invoke statement doesn't address that path.
Exam domain
Security · 26% of DVA-C02
Question type
Multiple choice (one answer)

Practise the full DVA-C02 exam

This question is one of a small free sample from the CertRidge DVA-C02 bank. Full practice exams match the real exam's length, time limit and domain weights, explain every option, and Review Mode re-drills the questions you miss.

Original question written from the official exam guide. Not affiliated with AWS; never copied from the real exam.

Worth reading: DVA-C02 cheat sheet, Lambda, DynamoDB, API Gateway, IAM and Cognito, messaging, CI/CD and X-Ray in tables, plus what DVA-C03 changes.