2023-05-03 11:06:20 +02:00
== Why is this an issue?
2022-10-11 10:28:16 +02:00
include::../description.adoc[]
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2022-10-11 10:28:16 +02:00
The following policy allows an attacker to update the code of any Lambda function. An attacker can achieve privilege escalation by altering the code of a Lambda that executes with high privileges.
[source,javascript]
----
import {aws_iam as iam} from 'aws-cdk-lib'
new iam.PolicyDocument({
statements: [new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ["lambda:UpdateFunctionCode"],
resources: ["*"], // Noncompliant
})],
})
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2022-10-11 10:28:16 +02:00
Narrow the policy such that only updates to the code of certain Lambda functions are allowed.
[source,javascript]
----
import {aws_iam as iam} from 'aws-cdk-lib'
new iam.PolicyDocument({
statements: [new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: ["lambda:UpdateFunctionCode"],
resources: ["arn:aws:lambda:us-east-2:123456789012:function:my-function:1"], // Noncompliant
})],
})
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]