Skip to main content

More Info:

Your AWS CloudFormation stacks should be using policies as a fail-safe mechanism in order to prevent accidental updates to stack resources.

Risk Level

Low

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • StateRAMP
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “CloudFormation Stack Policy Should Use A Fail-Safe Mechanism” in AWS using the AWS console, you can follow the below steps:
  1. Login to the AWS Management Console.
  2. Go to the CloudFormation service.
  3. Click on the Stack for which you want to remediate the misconfiguration.
  4. Click on the “Permissions” tab.
  5. Scroll down to the “Stack Policy” section.
  6. Click on the “Edit” button.
  7. Add the following statement to the policy:
This statement will deny any update that deletes a resource in the stack, unless the resource has a tag with the key “aws:cloudformation:stack-name” set to a non-null value.
  1. Click on the “Save” button to save the updated Stack Policy.
By adding this statement to the Stack Policy, you have implemented a fail-safe mechanism that prevents accidental deletion of resources in the stack.

To remediate the misconfiguration “CloudFormation Stack Policy Should Use A Fail-Safe Mechanism” in AWS using AWS CLI, follow the below steps:
  1. Open the AWS CLI on your local machine or AWS CLI shell.
  2. Run the following command to create a stack policy with a fail-safe mechanism:
Note: Replace <stack-name> with the name of the stack that you want to apply the policy to and <path-to-policy-file> with the path to the policy file on your local machine.
  1. Verify that the stack policy has been set successfully by running the following command:
Note: Replace <stack-name> with the name of the stack that you applied the policy to.
  1. If the output of the above command shows the policy that you set, then the remediation is successful.
By following the above steps, you can remediate the misconfiguration “CloudFormation Stack Policy Should Use A Fail-Safe Mechanism” in AWS using AWS CLI.
To remediate the misconfiguration “CloudFormation Stack Policy Should Use A Fail-Safe Mechanism” in AWS using Python, you can follow the below steps:
  1. Install the AWS SDK for Python (Boto3) using the following command:
  1. Use the following Python code to remediate the misconfiguration:
Replace STACK_NAME with the name of the stack for which you want to remediate the misconfiguration.This code will retrieve the stack policy for the specified stack, check if it contains a fail-safe mechanism (a deny statement with action ”*”), and remove it if found. Finally, it will update the stack policy with the new policy that includes the fail-safe mechanism.
This matches the CLI remediation by applying a stack policy that denies all Update:* actions on all resources in the stack, acting as a strict fail-safe against accidental updates; it does not force stack replacement, but future stack updates that require resource changes will be blocked unless the policy is temporarily relaxed via another mechanism.terraform plan should show either creation of the aws_cloudformation_stack with stack_policy_body set as above, or (for an existing stack) an in-place update adding/modifying stack_policy_body to this restrictive policy.

Additional Reading: