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

Add check in delete environment for create_failed stacks #1386

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

dlpzx
Copy link
Contributor

@dlpzx dlpzx commented Jul 3, 2024

Feature or Bugfix

  • Bugfix

Detail

When an environment stack fails in its creation (the CloudFormation stack is not deployed), the cdk-pivot role won't be created. Then, when a user tries to delete the environment they will get an error Data.all Environment Pivot Role does not have permissions to to get the list of attached policies to the role dataall-testenva-jv54380n: An error occurred (AccessDenied) when calling the AssumeRole operation: User: arn:aws:sts::XXXXXXX:assumed-role/tool-tst-graphql-role/tool-tst-graphql is not authorized to perform: sts:AssumeRole on resource: arn:aws:iam::1111111111:role/dataallPivotRole-cdk',

Those managed permissions do not even exist if the environment stack was never deployed successfully. This PR adds a check that verifies that the environment stack was deployed before removing env-managed policies.

Relates

Security

Please answer the questions below briefly where applicable, or write N/A. Based on
OWASP 10.

  • Does this PR introduce or modify any input fields or queries - this includes
    fetching data from storage outside the application (e.g. a database, an S3 bucket)?
    • Is the input sanitized?
    • What precautions are you taking before deserializing the data you consume?
    • Is injection prevented by parametrizing queries?
    • Have you ensured no eval or similar functions are used?
  • Does this PR introduce any functionality or component that requires authorization?
    • How have you ensured it respects the existing AuthN/AuthZ mechanisms?
    • Are you logging failed auth attempts?
  • Are you using or adding any cryptographic features?
    • Do you use a standard proven implementations?
    • Are the used keys controlled by the customer? Where are they stored?
  • Are you introducing any new policies/roles/users?
    • Have you used the least-privilege principle? How?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dlpzx dlpzx requested a review from petrkalos July 3, 2024 11:16
@dlpzx dlpzx added the type: bug Something isn't working label Jul 3, 2024
region=environment.region,
resource_prefix=environment.resourcePrefix,
).delete_all_policies()
if StackRepository.find_stack_by_target_uri(session, environment.environmentUri) not in [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case auto pivotRole creation the pivot role won't exist as well (I've come across this issue a few times) so I think that this check will fail regardless. Wdyt?

@dlpzx dlpzx merged commit 545c22a into main Jul 3, 2024
9 checks passed
@dlpzx dlpzx deleted the fix/environment-missing-delete-permissions branch July 17, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants