Skip to main content

More Info:

Ensure network firewall rule groups are stateful or stateless

Risk Level

Medium

Address

Operational Maturity, Reliability, 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)
  • 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
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the network firewall rule groups to be either stateless or stateful for AWS EC2 using the AWS console, follow these step-by-step instructions:
  1. Login to AWS Console: Go to the AWS Management Console (https://aws.amazon.com/console/) and login to your AWS account.
  2. Navigate to EC2 Service: Click on the “Services” dropdown menu at the top left corner of the console, then select “EC2” under the Compute section.
  3. Select Security Groups: In the EC2 dashboard, click on “Security Groups” in the left-hand navigation pane.
  4. Identify the Security Group: Identify the security group associated with your EC2 instance that you want to update the firewall rules for.
  5. Review Rules: Click on the security group to view its inbound and outbound rules.
  6. Edit Rules: To make the rules stateful or stateless, you will need to edit the existing rules.
  7. Update Rule: For each rule, determine whether it needs to be stateful or stateless. Stateless rules do not keep track of the state of the connection, while stateful rules keep track of the state of the connection.
  8. Edit Inbound Rules:
    • To make a rule stateful: Click on the “Edit inbound rules” button, then edit the rule and ensure the “Stateful” option is selected.
    • To make a rule stateless: Click on the “Edit inbound rules” button, then edit the rule and ensure the “Stateless” option is selected.
  9. Edit Outbound Rules:
    • Repeat the same process for outbound rules if necessary.
  10. Review and Save Changes: Review the changes you have made to ensure that the rules are now either stateful or stateless as required. Click on the “Save rules” or “Apply changes” button to save the updated rules.
  11. Verify Changes: Verify that the changes have been applied successfully by testing the network connectivity to and from the EC2 instance.
By following these steps, you can remediate the network firewall rule groups to be either stateless or stateful for AWS EC2 using the AWS console.

To remediate the issue of network firewall rule groups being stateless or stateful in AWS EC2 using AWS CLI, follow these steps:
  1. Open your terminal or command prompt and ensure that you have the AWS Command Line Interface (CLI) installed and configured with the necessary permissions to make changes to your AWS resources.
  2. Identify the security group associated with the EC2 instance for which you want to make the firewall rule group stateful.
  3. Use the following AWS CLI command to describe the inbound and outbound rules for the security group:
Replace YOUR_SECURITY_GROUP_ID with the actual ID of the security group you want to modify.
  1. Identify the rules that are currently configured as stateless and need to be made stateful.
  2. Use the following AWS CLI command to modify the inbound or outbound rules of the security group to make them stateful:
Replace YOUR_SECURITY_GROUP_ID with the actual ID of the security group you want to modify. Replace YOUR_INGRESS_RULES and YOUR_EGRESS_RULES with the desired stateful rules in the JSON format.
  1. Verify that the changes have been successfully applied by using the describe-security-groups command again.
By following these steps and using the AWS CLI commands provided, you can remediate the issue of network firewall rule groups being stateless or stateful in AWS EC2.
To remediate the issue of network firewall rule groups being stateless or stateful in AWS EC2 using Python, you can utilize the Boto3 library, which is the AWS SDK for Python. Here are the step-by-step instructions to remediate this misconfiguration:
  1. Install Boto3 library: Make sure you have the Boto3 library installed. You can install it using pip:
  2. Write a Python script to update the security group rules: Create a Python script (e.g., fix_security_group_rules.py) with the following code:
  3. Replace ‘YOUR_SECURITY_GROUP_ID’ with the actual Security Group ID that you want to update.
  4. Run the Python script: Execute the Python script using the following command:
  5. Verify the changes: After running the script, verify that the security group rules have been updated to be stateful by checking the AWS Management Console or by running the describe_security_groups API call.
By following these steps, you can remediate the misconfiguration of network firewall rule groups being stateless in AWS EC2 using Python and Boto3.
This configuration models the CLI remediation by ensuring the Network Firewall policy includes at least one stateless_rule_group_reference or stateful_rule_group_reference, pointing at a valid rule group. It does not force replacement of the firewall or policy; Terraform will update the existing policy in place.For verification, terraform plan should show:
  • creation (if new) of aws_networkfirewall_rule_group.STATEFUL_OR_STATELESS_RULE_GROUP
  • an in-place update of aws_networkfirewall_firewall_policy.FIREWALL_POLICY adding stateful_rule_group_reference and/or stateless_rule_group_reference
  • no destroy/create cycle for the firewall itself.