Skip to content
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

(aws-cdk): (Disallow CDK Bootstrap to default AdministratorAccess for cfn-exec-role) #27097

Open
2 tasks
smislam opened this issue Sep 11, 2023 · 5 comments
Open
2 tasks
Labels
feature-request A feature should be added or improved. p2 package/tools Related to AWS CDK Tools or CLI

Comments

@smislam
Copy link

smislam commented Sep 11, 2023

Describe the feature

By default, CDK Bootstrap uses AdministratorAccess for cfn-exec-role when we run the cdk bootstrap command. This allows CDK to have higher privileges that the user is authorized to perform and poses a security concern. Feature request is to make '--cloudformation-execution-policies' parameter mandatory.

Use Case

In my account, the account administrator disabled using AdministratorAccess. The account also has Config rules to remove AdministratorAccess access if found. We also have a security policy that removes the CDK S3 bucket first day of a month. Since we require re-bootstrapping the account each month, it would be ideal to make cdk bootstrap '--cloudformation-execution-policies' parameter mandatory. That way, it will force us to pass the right cfn-exec-role than to have CDK default to AdministratorAccess role.

Proposed Solution

Make '--cloudformation-execution-policies' parameter mandatory

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.94.0 (build 987c329)

Environment details (OS name and version, etc.)

AWS Workspace (Microsoft Windows Server 2016 DataCenter 10.0.14393 Build 14393)

@smislam smislam added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 11, 2023
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Sep 11, 2023
@indrora
Copy link
Contributor

indrora commented Sep 11, 2023

@indrora indrora added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 11, 2023
@smislam
Copy link
Author

smislam commented Sep 11, 2023

Hi @indrora, Thank you for sending the permission boundary information. We are actually enforcing a few things to securing the accounts that also include permission boundaries:

  1. Have IAM role with restricted permissions for users
  2. Have AWS Config Rule to flag and remove AdministratorAccess role
  3. Implement Permission Boundary to restrict users to allowed policies --> We haven't implemented this yet

As you already called out, the Permission Boundary will restrict users and cdk to only the permission they should have. However, we still need to remove the default AdministratorAccess role when bootstrapped without the --cloudformation-execution-policies' parameter. Our Security and Policy scanning tool finds the AdministratorAccess role and flagging the accounts status as violation. The Config Rules then removes that entry making CDK unusable.

if (trustedAccounts.length === 0 && cloudFormationExecutionPolicies.length === 0) {

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Sep 11, 2023
@scanlonp scanlonp added the p2 label Apr 22, 2024
@otaviomacedo
Copy link
Contributor

@smislam this is a possible solution, but keep in mind that it would degrade the bootstrapping experience for all the user who currently have no such constraints as you do.

Without knowing more about your specific circumstances, it's hard to tell, but couldn't you automate this process yourself, to make sure that the role has the right policies? Given that you do it monthly, I'm assuming you already have some CI/CD or bash script triggered by a cron job or something that does the bootstrap for you.

@otaviomacedo otaviomacedo added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Nov 7, 2024
Copy link

github-actions bot commented Nov 9, 2024

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 9, 2024
@smislam
Copy link
Author

smislam commented Nov 9, 2024

@otaviomacedo , thank you for responding. Yes, I agree there are multiple ways of fixing this.

I am focusing on least privileged access as part of AWS best practices. Adding a requirement of cdk bootstrap '--cloudformation-execution-policies' is one way of enforcing best practices. This way the user can pass whatever role they want (including admin role - ideally they shouldn't) rather than CDK assuming that current user is admin and use admin by default. This approach will also enforce creation of non-admin roles for all users which to me may be ideal to do.

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p2 package/tools Related to AWS CDK Tools or CLI
Projects
None yet
Development

No branches or pull requests

4 participants