AWS Network ACL Restricts Inbound Traffic


Description

This policy validates that Network ACLs restrict inbound traffic in some way.

Query · python

# This is a generic policy for checking inbound rules on a Network ACL.
# It is recommended to add additional logic here based on your own use cases.


def policy(resource):

    for entry in resource["Entries"]:
        if entry["RuleAction"] == "allow" and not entry["Egress"]:
            # Check if entry is set to "All Ports"
            if entry["PortRange"] is None:
                return False
    return True

Analyst notes

Add appropriate entries to the Network ACLs' IP permissions list.

Raw source AWS Network ACL Restricts Inbound Traffic · Panther Python
Esc
Published by panther-labs/panther-analysis ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
AnalysisType: policy
Filename: aws_network_acl_restricts_inbound_traffic.py
PolicyID: "AWS.NetworkACL.RestrictsInboundTraffic"
DisplayName: "AWS Network ACL Restricts Inbound Traffic"
Enabled: false
ResourceTypes:
  - AWS.EC2.NetworkACL
Tags:
  - AWS
  - PCI
  - Initial Access:Exploit Public-Facing Application
Reports:
  PCI:
    - 1.3.5
    - 1.2.1
    - 1.1.4
  MITRE ATT&CK:
    - TA0001:T1190
Severity: Medium
Description: >
  This policy validates that Network ACLs restrict inbound traffic in some way.
Runbook: >
  Add appropriate entries to the Network ACLs' IP permissions list.
Reference: https://docs.aws.amazon.com/vpc/latest/userguide/vpc-recommended-nacl-rules.html
Tests:
  - Name: Network ACL Restricts Inbound Traffic
    ExpectedResult: true
    Resource:
      {
        "Associations":
          [
            {
              "NetworkAclAssociationId": "aclassoc-abc111222333",
              "NetworkAclId": "acl-def111222333",
              "SubnetId": "subnet-111222333444",
            },
          ],
        "Entries":
          [
            {
              "CidrBlock": "0.0.0.0/0",
              "Egress": true,
              "IcmpTypeCode": null,
              "Ipv6CidrBlock": null,
              "PortRange": { "From": 1024, "To": 65535 },
              "Protocol": "6",
              "RuleAction": "allow",
              "RuleNumber": 100,
            },
            {
              "CidrBlock": "0.0.0.0/0",
              "Egress": true,
              "IcmpTypeCode": null,
              "Ipv6CidrBlock": null,
              "PortRange": null,
              "Protocol": "-1",
              "RuleAction": "deny",
              "RuleNumber": 4200,
            },
            {
              "CidrBlock": "0.0.0.0/0",
              "Egress": false,
              "IcmpTypeCode": null,
              "Ipv6CidrBlock": null,
              "PortRange": { "From": 80, "To": 80 },
              "Protocol": "6",
              "RuleAction": "allow",
              "RuleNumber": 100,
            },
          ],
        "IsDefault": false,
        "NetworkAclId": "acl-abc111222333",
        "OwnerId": "123456789012",
        "Tags": { "environment": "pci" },
        "VpcId": "vpc-abc111222333",
      }
  - Name: Network ACL Does Not Restrict Inbound Traffic
    ExpectedResult: false
    Resource:
      {
        "Associations":
          [
            {
              "NetworkAclAssociationId": "aclassoc-abc111222333",
              "NetworkAclId": "acl-def111222333",
              "SubnetId": "subnet-111222333444",
            },
          ],
        "Entries":
          [
            {
              "CidrBlock": "0.0.0.0/0",
              "Egress": true,
              "IcmpTypeCode": null,
              "Ipv6CidrBlock": null,
              "PortRange": { "From": 1024, "To": 65535 },
              "Protocol": "6",
              "RuleAction": "allow",
              "RuleNumber": 100,
            },
            {
              "CidrBlock": "0.0.0.0/0",
              "Egress": true,
              "IcmpTypeCode": null,
              "Ipv6CidrBlock": null,
              "PortRange": null,
              "Protocol": "-1",
              "RuleAction": "deny",
              "RuleNumber": 4200,
            },
            {
              "CidrBlock": "0.0.0.0/0",
              "Egress": false,
              "IcmpTypeCode": null,
              "Ipv6CidrBlock": null,
              "PortRange": null,
              "Protocol": "6",
              "RuleAction": "allow",
              "RuleNumber": 100,
            },
          ],
        "IsDefault": false,
        "NetworkAclId": "acl-abc111222333",
        "OwnerId": "123456789012",
        "Tags": { "environment": "pci" },
        "VpcId": "vpc-abc111222333",
      }


# ------ paired body: aws_network_acl_restricts_inbound_traffic.py ------

# This is a generic policy for checking inbound rules on a Network ACL.
# It is recommended to add additional logic here based on your own use cases.


def policy(resource):

    for entry in resource["Entries"]:
        if entry["RuleAction"] == "allow" and not entry["Egress"]:
            # Check if entry is set to "All Ports"
            if entry["PortRange"] is None:
                return False
    return True

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.