Join our Newsletter — 33% off our NHI Course
Home› Guides› Amazon VPC Security Guide: Security Groups, NACLs, Endpoints…
Guide Cloud Security

Amazon VPC Security Guide: Security Groups, NACLs, Endpoints and Flow Logs

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, edited by Lalit Choda Updated 8 November 2026 14 min read
On this page

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 actionWhat it changesWhy it is sensitive
ec2:AuthorizeSecurityGroupIngress and AuthorizeSecurityGroupEgressSecurity group rulesOpens 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, AttachInternetGatewayRoutingCreates a path to the internet or to another network
ec2:CreateNetworkAclEntry, ReplaceNetworkAclAssociationSubnet-level allow and denyRemoves coarse deny rules
ec2:ModifyVpcEndpointEndpoint policy and settingsRestores full-access policies and widens the data perimeter
VPC Block Public Access settings and exclusionsAccount-wide internet blockingAn exclusion silently re-opens a VPC or subnet
ec2:DeleteFlowLogsNetwork telemetryRemoves the evidence trail
Peering, Transit Gateway attachments and RAM sharingInter-VPC and cross-account pathsJoins 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/0 remain 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 Principal element must be *; to restrict principals use the aws:PrincipalArn condition 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 typeServicesPolicy supportNetwork controls
Gateway endpointAmazon S3, DynamoDBYes; Principal must be *Route table entries; no security group
Interface endpoint (PrivateLink)Most AWS services, partner and your own endpoint servicesWhere the service supports it; otherwise full accessSecurity 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.

VersionUseful fieldsWhy add them
3vpc-id, subnet-id, instance-id, tcp-flags, pkt-srcaddr, pkt-dstaddrAttribute 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
4region, az-idMulti-Region analysis
5flow-direction, traffic-path, pkt-src-aws-service, pkt-dst-aws-serviceDistinguish ingress from egress and identify traffic to AWS services
7ECS cluster, service and task fieldsAttribute container traffic (awsvpc mode only)
8reject-reasonShows BPA when Block Public Access rejected a flow
11Instance and interface tag fields, next-hop-* fieldsMap 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.

BehaviourSignalATT&CK v20
Internal port scanningMany REJECT records or SYN-only flows from one source to many portsT1046 Network Service Discovery
Exposed service probed from the internetInbound ACCEPT from public addresses to admin portsT1190 Exploit Public-Facing Application, T1133 External Remote Services
Large egress to unknown destinationsHigh bytes on egress flows not via NAT or proxyT1048 Exfiltration Over Alternative Protocol
DNS tunnellingResolver query logs (not flow logs)T1071.004 DNS
Security group opened or flow log deletedCloudTrail EC2 API eventsT1686 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

CharacteristicSecurity groupNetwork ACL
LevelNetwork interface (instance level)Subnet
RulesAllow onlyAllow and deny
EvaluationAll rules evaluated; multiple groups on one resource are aggregatedLowest rule number first (1 to 32766); first match applies
Return trafficAutomatically allowed (stateful)Must be explicitly allowed (stateless)
DefaultsA new group has no inbound rules and one outbound allow-all ruleEach subnet must have exactly one NACL; the default NACL allows all traffic
Best useFine-grained, application-level allow lists using security group referencesCoarse 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

  1. 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.
  2. 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.
  3. Observe before blocking: use two to four weeks of flow logs to build the real allow list per tier, especially for egress.
  4. 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 REJECT records with reject-reason BPA.
  5. Enforce: roll out account by account, add SCP guardrails, and alert on security group changes that open admin ports.
  6. 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 controlNIST SP 800-53 Rev. 5NIST CSF 2.0CIS Controls v8.1ISO/IEC 27001:2022
Security groups, NACLs, deny by defaultSC-7, SC-7(5), AC-4PR.IR-014, 12A.8.20, A.8.22
Block Public Access, private subnetsSC-7PR.IR-0112A.8.20
Endpoint policies, data perimeterAC-4, CA-3PR.DS-02, PR.AA-053, 12A.8.21
Flow logs, DNS query logsAU-2, AU-12, SI-4DE.CM-018, 13A.8.15, A.8.16
Network change controlCM-3, CM-6PR.PS-014A.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-direction and pkt- 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/0 or ::/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-dstaddr and reject-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

Related NHI Mgmt Group resources: Cloud Network Security Guide · AWS Security Guide · Network Segmentation Guide · Top 10 Network Security Misconfigurations

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Researched and written by the NHI Mgmt Group editorial team using AI tools, under the editorial direction of Lalit Choda. Facts are drawn from the sources listed on this page and checked by our automated quality process. Last updated 8 November 2026. Spotted an error? Use our contact page.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM and Agentic AI security. nhimg.org

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick the PDF box to continue.