-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secrets Manager: raises a security issue when adding rotationLambda #28406
Comments
OK I can see the violation messaegs now. export class DemoStack extends MyStack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
// get a dummy func
const fn = getLambdaFunction(this);
const secret = new secrets.Secret(this, 'Secret');
secret.addRotationSchedule('Schedule', {
rotationLambda: fn,
})
}
} And the violation report:
And the affected CFN resource "FuncInvokeN0a2GKfZP0JmDqDEVhhu6A0TUv3NyNbk4YMFKNcA632017C": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"Func217E03A4",
"Arn"
]
},
"Principal": "secretsmanager.amazonaws.com"
},
"Metadata": {
"aws:cdk:path": "DemoStack2/Func/InvokeN0--a2GKfZP0JmDqDE--Vhhu6+A0TUv3NyNbk4YM+FKNc="
}
}, And due to this message:
It will need the And according to the document, the Yes I think we should include that as it's recommended. Maybe we should fix this with a tiny PR like const grantee = new iam.ServicePrincipal('secretsmanager.amazonaws.com', {
conditions: {
'SourceAccount': Aws.ACCOUNT_ID,
}
});
const grant = props.rotationLambda.grantInvoke(grantee); |
Describe the bug
The following cloudformation guard rule fails https://docs.aws.amazon.com/controltower/latest/userguide/lambda-rules.html#ct-lambda-pr-2-description
This is due to the fact that it is missing a SourceAccount in the service principal
A resource policy for rotation lambda is created here and this causes the cfn guard rule to fail.
https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-secretsmanager/lib/rotation-schedule.ts#L107
Expected Behavior
I should be allowed to add or override the service principal created here, to address cfn guard rule failing
Current Behavior
I have no way to address the cloudformation guard rule, created due to this line
Reproduction Steps
add a rotation lambda to secrets manager, and run cdk cfn guard validator
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.104.0
Framework Version
No response
Node.js Version
v16.20.0
OS
mac
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: