Most AWS network exposure is not a missing firewall but an accumulation of small defaults: security groups that allow all outbound traffic, VPC endpoints with full-access policies, subnets that can reach the internet and flow logs nobody reads. Amazon VPC gives you several overlapping controls, and knowing exactly what each one evaluates, and what it cannot see, is what separates a real network baseline from a diagram. This guide covers the AWS-specific detail: security group and network ACL behaviour, VPC Block Public Access, VPC endpoint policies, flow log formats and analysis, the identities that can change the network, and a rollout baseline. It is written for cloud network and security engineers and for reviewers assessing AWS estates. For cross-cloud network design, peering and hub-and-spoke patterns, see the cloud network security guide.
This is an independent guide from NHI Mgmt Group, based on AWS's public documentation as of November 2026. It is not sponsored or reviewed by AWS. Product features change, so confirm settings against AWS's current documentation.
Key takeaways
- Security groups are stateful allow lists; NACLs are stateless and ordered: a new security group allows no inbound and all outbound traffic, so egress is open until you remove that rule.
- VPC Block Public Access is the account-wide backstop: in bidirectional or ingress-only mode it blocks internet gateway traffic in a Region regardless of individual route tables and security groups, with explicit exclusions.
- Endpoint policies are part of your data perimeter: the default policy grants full access, and an endpoint policy never overrides identity or resource policies, it only further limits what passes through the endpoint.
- Flow logs need a custom format to be useful: the default version 2 fields lack VPC, subnet, instance, TCP flags, flow direction and the reject reason that newer versions add.
- Know the blind spots: flow logs do not capture traffic to the Amazon DNS resolver or the instance metadata service, and security groups cannot block DNS queries to the Route 53 Resolver.
How identity and access work in Amazon VPC
Every VPC control is an API-managed resource, so network security is also an IAM problem. The permissions that matter most are the ones that change reachability.
| Permission or action | What it changes | Why it is sensitive |
|---|---|---|
ec2:AuthorizeSecurityGroupIngress and AuthorizeSecurityGroupEgress | Security group rules | Opens a service to the internet in one call; AWS checks only that a referenced group exists, not that you have rights over it |
ec2:CreateRoute, ReplaceRoute, AttachInternetGateway | Routing | Creates a path to the internet or to another network |
ec2:CreateNetworkAclEntry, ReplaceNetworkAclAssociation | Subnet-level allow and deny | Removes coarse deny rules |
ec2:ModifyVpcEndpoint | Endpoint policy and settings | Restores full-access policies and widens the data perimeter |
| VPC Block Public Access settings and exclusions | Account-wide internet blocking | An exclusion silently re-opens a VPC or subnet |
ec2:DeleteFlowLogs | Network telemetry | Removes the evidence trail |
| Peering, Transit Gateway attachments and RAM sharing | Inter-VPC and cross-account paths | Joins trust zones that were designed to be separate |
Workload identities matter too: an interface endpoint, a NAT gateway and a security group decide whether a stolen role credential can be used from outside your network, because endpoint policies and resource policies can require that requests arrive through your VPC. See the AWS Resource Control Policies and Data Perimeter Guide and the AWS IAM Policies and Roles Guide.
Admin roles and privileged access
- Central network ownership: in multi-account estates, keep VPCs, Transit Gateways and shared subnets in a network account and share subnets to workload accounts with AWS RAM. Workload teams then manage their own security groups but cannot create internet gateways or routes.
- Guardrails: use service control policies to deny creating internet gateways, changing VPC Block Public Access, deleting flow logs and creating peering connections outside the network account. See the AWS Organizations and SCPs Guide.
- Administrative access paths: SSH (TCP 22) and RDP (TCP 3389) open to
0.0.0.0/0remain the most common high-risk finding. Replace inbound administration with Session Manager or a controlled bastion, and see the AWS Systems Manager Security Guide. - Change through code: manage security groups and NACLs as infrastructure as code with review, and treat console changes in production as exceptions that raise alerts.
Integrations, API tokens and service accounts
VPC endpoints are where network controls and machine credentials meet. An endpoint policy is a resource-based policy attached to a VPC endpoint that controls which principals can use it to reach an AWS service. Key mechanics from the AWS documentation:
- Default: without a custom policy the endpoint allows
"Principal": "*","Action": "*","Resource": "*". Services that do not support endpoint policies, and endpoints to non-AWS endpoint services, always allow full access. - No override: an endpoint policy does not override or replace identity-based or resource-based policies. Access needs every applicable policy to allow it.
- Gateway endpoints (S3 and DynamoDB): the
Principalelement must be*; to restrict principals use theaws:PrincipalArncondition key. Writing"AWS": "account_id"as a principal grants access to the account root user only, not to all roles in the account. - Limits: one policy per endpoint, up to 20,480 characters, and changes can take a few minutes to apply. Wildcards and numeric operators cannot be used with system-generated identifiers such as
aws:SourceVpc. - Pairing: use endpoint policies to restrict which accounts' resources can be reached (for example only buckets in your organisation), and bucket or key policies conditioned on the endpoint or VPC to restrict where requests can come from. Interface endpoints also take security groups, which should allow only the application subnets on TCP 443.
| Endpoint type | Services | Policy support | Network controls |
|---|---|---|---|
| Gateway endpoint | Amazon S3, DynamoDB | Yes; Principal must be * | Route table entries; no security group |
| Interface endpoint (PrivateLink) | Most AWS services, partner and your own endpoint services | Where the service supports it; otherwise full access | Security groups on the endpoint network interfaces; private DNS |
For private connectivity patterns across clouds, see the Cloud Private Connectivity Guide.
Logging and detection
Flow log formats
The default flow log format is fixed at version 2: version account-id interface-id srcaddr dstaddr srcport dstport protocol packets bytes start end action log-status. Create flow logs with a custom format that adds the fields you need for investigation, because a flow log's format cannot be changed after creation.
| Version | Useful fields | Why add them |
|---|---|---|
| 3 | vpc-id, subnet-id, instance-id, tcp-flags, pkt-srcaddr, pkt-dstaddr | Attribute flows to resources; pkt- addresses show the original source and destination where srcaddr shows a primary private IP; TCP flags (SYN=2, SYN-ACK=18) separate scans from sessions |
| 4 | region, az-id | Multi-Region analysis |
| 5 | flow-direction, traffic-path, pkt-src-aws-service, pkt-dst-aws-service | Distinguish ingress from egress and identify traffic to AWS services |
| 7 | ECS cluster, service and task fields | Attribute container traffic (awsvpc mode only) |
| 8 | reject-reason | Shows BPA when Block Public Access rejected a flow |
| 11 | Instance and interface tag fields, next-hop-* fields | Map flows to owners and routing paths |
action is ACCEPT or REJECT; log-status is OK, NODATA or SKIPDATA (records skipped for capacity reasons). The default maximum aggregation interval is 10 minutes, with 1 minute available; on Nitro-based instances it is always 1 minute or less. Delivery is best effort, typically about 5 minutes to CloudWatch Logs and about 10 minutes to S3, so flow logs are not a real-time control.
What flow logs do not show
Flow logs do not capture traffic to the Amazon DNS server, to 169.254.169.254 (instance metadata), to 169.254.169.123 (Time Sync), DHCP, ARP, Windows licence activation, traffic to the default router's reserved address, or traffic between an endpoint interface and a Network Load Balancer. DNS-based exfiltration through the Route 53 Resolver and metadata credential theft therefore need other telemetry: Route 53 Resolver query logs, Route 53 Resolver DNS Firewall and GuardDuty, whose foundational threat detection includes VPC flow logs. See the DNS Security Guide and the EC2 Instance Metadata Service Hardening Guide.
| Behaviour | Signal | ATT&CK v20 |
|---|---|---|
| Internal port scanning | Many REJECT records or SYN-only flows from one source to many ports | T1046 Network Service Discovery |
| Exposed service probed from the internet | Inbound ACCEPT from public addresses to admin ports | T1190 Exploit Public-Facing Application, T1133 External Remote Services |
| Large egress to unknown destinations | High bytes on egress flows not via NAT or proxy | T1048 Exfiltration Over Alternative Protocol |
| DNS tunnelling | Resolver query logs (not flow logs) | T1071.004 DNS |
| Security group opened or flow log deleted | CloudTrail EC2 API events | T1686 Disable or Modify System Firewall, T1685 Disable or Modify Tools |
Metrics: security groups with inbound 0.0.0.0/0 or ::/0 on ports other than 80 and 443; percentage of VPCs with flow logs in a custom format; VPC endpoints still on the default full-access policy; VPC Block Public Access mode per Region and number of exclusions; mean time to close a public exposure finding; Network Access Analyzer findings open.
Hardening baseline
Security groups and network ACLs
| Characteristic | Security group | Network ACL |
|---|---|---|
| Level | Network interface (instance level) | Subnet |
| Rules | Allow only | Allow and deny |
| Evaluation | All rules evaluated; multiple groups on one resource are aggregated | Lowest rule number first (1 to 32766); first match applies |
| Return traffic | Automatically allowed (stateful) | Must be explicitly allowed (stateless) |
| Defaults | A new group has no inbound rules and one outbound allow-all rule | Each subnet must have exactly one NACL; the default NACL allows all traffic |
| Best use | Fine-grained, application-level allow lists using security group references | Coarse subnet guardrails, such as denying known bad ranges or admin ports from outside |
- Reference groups, not addresses: allow traffic from the security group of the calling tier. A referencing rule counts as one rule regardless of group size. References work within a VPC, across peering and, for inbound rules, across Transit Gateway; they become stale when the peer group or peering is deleted, so clean up stale rules.
- Restrict egress: replace the default outbound allow-all rule with the destinations each tier needs, and route remaining internet egress through a NAT gateway with inspection or a proxy. See the Agent Egress Control and Network Isolation Guide for the same pattern applied to AI workloads.
- Prefix lists with care: a rule that references a customer-managed prefix list counts as the list's maximum size against quotas, so oversized lists exhaust rule limits.
- NACLs as backstop: number rules in increments of 10 or 100, remember that stateless rules must allow return traffic on ephemeral ports, and keep NACLs simple enough that nobody is afraid to change them.
- Default security group: remove its rules and do not use it for resources, so anything launched without an explicit group gets no access.
Internet exposure and inspection
- VPC Block Public Access: bidirectional mode blocks all traffic to and from internet gateways and egress-only internet gateways in the Region; ingress-only mode blocks inbound internet traffic while still allowing NAT gateway and egress-only gateway traffic. Exclusions exempt a single VPC or subnet, either bidirectionally or egress-only. Set ingress-only as the default for workload accounts and keep exclusions to named edge VPCs.
- Private subnets by default: place workloads in subnets with no route to an internet gateway, and publish them through load balancers in dedicated public subnets.
- Inspection: AWS Network Firewall filters inbound and outbound traffic, and Route 53 Resolver DNS Firewall filters DNS queries that security groups cannot block.
- Find unintended paths: AWS recommends Network Access Analyzer to identify unintended network access; run it against scopes such as "internet to database subnets" after every major change.
Decision guidance
Choose security groups as the primary control in almost every case, because they are stateful, attach to the resource and can reference other groups. Add NACLs only for coarse, rarely changing subnet rules. Choose gateway endpoints for S3 and DynamoDB where traffic stays in-Region (no hourly charge, but no security group), and interface endpoints where you need security groups, on-premises access or services that only support PrivateLink. A small organisation with one or two VPCs can get most of the value from four controls: private subnets, no admin ports open, VPC Block Public Access in ingress-only mode and flow logs with a custom format. A large organisation should centralise the network account, enforce guardrails with SCPs, and add Network Firewall, DNS Firewall and endpoint policies as part of a data perimeter. See the Cloud Network Security Guide for the cross-cloud view.
Phased rollout
- Discover: list every security group rule open to the internet, every internet gateway and route, every endpoint policy and every VPC without flow logs. Run Network Access Analyzer for internet-facing paths.
- Turn on telemetry first: create flow logs with a custom format (version 5 fields or later, plus
reject-reason) to S3 or CloudWatch Logs in the log archive account, and enable Route 53 Resolver query logging. - Observe before blocking: use two to four weeks of flow logs to build the real allow list per tier, especially for egress.
- Pilot ring: in a non-production account, enable VPC Block Public Access in ingress-only mode, replace allow-all egress, and apply custom endpoint policies. Watch for
REJECTrecords withreject-reasonBPA. - Enforce: roll out account by account, add SCP guardrails, and alert on security group changes that open admin ports.
- Roll back: security group and NACL changes take effect immediately and can be reverted from code; Block Public Access can be relaxed per VPC or subnet with an exclusion while a fix is made; endpoint policies can be reset to full access. Record every rollback as an exception with an owner and expiry.
Framework mapping
| VPC control | NIST SP 800-53 Rev. 5 | NIST CSF 2.0 | CIS Controls v8.1 | ISO/IEC 27001:2022 |
|---|---|---|---|---|
| Security groups, NACLs, deny by default | SC-7, SC-7(5), AC-4 | PR.IR-01 | 4, 12 | A.8.20, A.8.22 |
| Block Public Access, private subnets | SC-7 | PR.IR-01 | 12 | A.8.20 |
| Endpoint policies, data perimeter | AC-4, CA-3 | PR.DS-02, PR.AA-05 | 3, 12 | A.8.21 |
| Flow logs, DNS query logs | AU-2, AU-12, SI-4 | DE.CM-01 | 8, 13 | A.8.15, A.8.16 |
| Network change control | CM-3, CM-6 | PR.PS-01 | 4 | A.8.9, A.8.32 |
Common misconfigurations
- Egress left at allow-all: the default outbound rule lets any compromised instance reach command and control servers or upload data anywhere.
- Endpoints on the default policy: an S3 gateway endpoint with full access lets workloads write to any bucket in any account, which is a ready-made exfiltration path (T1537 Transfer Data to Cloud Account).
- Assuming flow logs see everything: teams rely on flow logs to detect DNS tunnelling or metadata abuse, neither of which appears in them.
- Default-format flow logs: without
vpc-id,instance-id,flow-directionandpkt-addresses, investigations stall on mapping IPs to resources after the fact. - NACLs that block return traffic: a stateless deny on ephemeral ports breaks applications intermittently, and the NACL is then opened to allow everything.
- Block Public Access exclusions that never expire: an exclusion created for a migration remains years later and quietly exposes a VPC.
Practitioner checklist
- No security group allows SSH, RDP or database ports from
0.0.0.0/0or::/0; administrative access uses Session Manager or a controlled bastion. - Default security groups have no rules and are not attached to resources.
- Each tier's security group restricts egress to what it needs, with remaining internet egress through NAT and inspection.
- VPC Block Public Access is set per Region, with a small, reviewed list of exclusions.
- Every VPC endpoint has a custom policy where the service supports it, and interface endpoint security groups allow only application subnets.
- Flow logs exist for every VPC in a custom format including
vpc-id,instance-id,tcp-flags,flow-direction,pkt-srcaddr,pkt-dstaddrandreject-reason, delivered to the log archive account. - Route 53 Resolver query logging and DNS Firewall cover the DNS gap in flow logs.
- SCPs prevent creating internet gateways, deleting flow logs or changing Block Public Access outside the network account.
- Network Access Analyzer scopes run after major changes, and findings have owners.
Standards and references
- AWS: Security best practices for your VPC
- AWS: Security group rules
- AWS: Control subnet traffic with network access control lists
- AWS: Block public access to VPCs and subnets
- AWS: Control access to VPC endpoints using endpoint policies
- AWS: Flow log records
- AWS: Flow log limitations
- MITRE ATT&CK: Network Service Discovery
Related NHI Mgmt Group resources: Cloud Network Security Guide · AWS Security Guide · Network Segmentation Guide · Top 10 Network Security Misconfigurations