Join our Newsletter — 33% off our NHI Course
Home› Guides› AWS VPC Flow Logs Detection Guide: Exfiltration, Scanning…
Guide SOC & Detection Engineering

AWS VPC Flow Logs Detection Guide: Exfiltration, Scanning and C2 Patterns

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 19 November 2026 17 min read
On this page

AWS VPC Flow Logs tell you who talked to whom, on which port, how much and whether it was allowed, which is enough to catch scanning, data exfiltration and command and control patterns if you collect the right fields and read them with their limits in mind. This guide covers the record format, the custom fields worth adding, the blind spots that matter for detection, and a set of illustrative detections for exfiltration, scanning, beaconing and lateral movement inside a VPC.

It is written for detection engineers and cloud security teams who already have flow logs switched on, or are about to, and want them to produce alerts rather than an expensive archive. For configuration and hardening of the VPC itself, see the Amazon VPC Security Guide; this page stays on detection and response.

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

  • The default record has 14 fields. For detection, use a custom format that adds at least vpc-id, subnet-id, instance-id, tcp-flags, pkt-srcaddr, pkt-dstaddr, flow-direction, traffic-path and pkt-dst-aws-service. A flow log's format cannot be changed after creation, so decide before you deploy.
  • Flow logs are metadata, not packet content. They never show what was sent, only how much and to where.
  • Several traffic types are not captured at all, including queries to the Amazon DNS server and traffic to the instance metadata address 169.254.169.254. DNS tunnelling and metadata credential theft need other telemetry.
  • Records are aggregated over 1 or 10 minute windows and delivered on a best effort basis, roughly 5 minutes to CloudWatch Logs and 10 minutes to Amazon S3. Treat flow log detections as near real time at best.
  • Behind NAT gateways, transit gateways and load balancers, srcaddr and dstaddr show the intermediate hop. Use pkt-srcaddr and pkt-dstaddr to attribute traffic to the real workload.
  • The strongest detections join flow data to identity: which instance, task or role was behind the flow, and what that workload is expected to talk to.

What a flow log record contains

AWS describes flow logs as records of IP traffic going to and from network interfaces in a VPC. You can create them at VPC, subnet or network interface level and publish them to Amazon CloudWatch Logs, Amazon S3 or Amazon Data Firehose. Collection happens outside the traffic path, so enabling them does not affect throughput or latency.

The default format, version 2, contains these fields in this order: version account-id interface-id srcaddr dstaddr srcport dstport protocol packets bytes start end action log-status. A few of them carry most of the detection value:

  • action is ACCEPT or REJECT. A reject means a security group or network ACL blocked the traffic.
  • bytes and packets are totals for the flow within the aggregation interval, which is the basis of every volume detection.
  • start and end are Unix seconds for the first and last packet seen in the interval. AWS notes they can be up to 60 seconds away from actual packet times.
  • log-status is OK, NODATA (no traffic in the interval) or SKIPDATA (records skipped because of internal capacity limits or errors). A SKIPDATA record can stand for several lost flows.
  • protocol is the IANA protocol number, so TCP is 6, UDP is 17 and ICMP is 1.

Custom fields worth adding

Custom formats can include any of the documented fields in any order. The ones that change detection quality most are:

FieldVersionWhy it matters for detection
vpc-id, subnet-id, instance-id3Attributes a flow to a workload without a separate lookup. instance-id is - for requester-managed interfaces such as NAT gateway interfaces.
tcp-flags3Bitmask of FIN (1), SYN (2), RST (4) and SYN-ACK (18), combined across the interval. Separates connection attempts from completed sessions.
pkt-srcaddr, pkt-dstaddr3The original packet addresses, which reveal the real endpoints behind NAT, transit gateways and other intermediate hops.
flow-direction5ingress or egress relative to the capturing interface. Removes guesswork from exfiltration logic.
traffic-path5For egress only, how the traffic left: for example 8 for an internet gateway, 4 or 5 for VPC peering, 3 for a virtual private gateway.
pkt-src-aws-service, pkt-dst-aws-service5Names the AWS service, such as S3 or DYNAMODB, behind a public AWS address. Useful to separate traffic to AWS services from traffic to arbitrary internet hosts.
ECS fields such as ecs-task-arn and ecs-service-name7Attributes flows to containers in awsvpc network mode tasks.
reject-reason8Reports BPA for VPC Block Public Access or EC for VPC Encryption Controls. Other reasons show -.
Tag fields such as instance-tag and interface-type11Bring owner or environment tags straight into the record, so rules can scope by environment.

AWS documents that metadata fields not taken from the packet header, such as the AWS service names, tags and ECS fields, are best effort approximations and can be missing or inaccurate. Use them for enrichment and scoping, not as the only condition in a high severity rule.

Collecting flow logs for detection

Collection choices decide which detections are possible later. The points below come from AWS documentation, with NHI Mgmt Group recommendations marked as such.

  • Scope. A VPC level flow log covers every interface, including those created by AWS services. NHI Mgmt Group recommends VPC level logging for every production VPC, with interface level logs reserved for targeted investigations.
  • Aggregation interval. The default is 10 minutes and 1 minute is available. Interfaces on Nitro based instances always use 1 minute or less. A 1 minute interval produces more records and costs more, but beaconing and short bursts are far easier to see.
  • Format is fixed. After creation you cannot change a flow log's configuration or record format. To add fields, create a new flow log and delete the old one, and check that your parsers handle the overlap.
  • Destination. S3 suits Athena or data lake analytics and long retention. CloudWatch Logs suits metric filters and Logs Insights. Firehose suits streaming into a SIEM. Charges for vended logs apply, and you can tag destination resources for cost allocation.
  • Cross account. Flow logs cannot be enabled for a peered VPC unless the peer VPC is in your account, so the owner of each VPC has to log its side.
  • Health monitoring. Alert on a VPC or subnet that stops producing records and on rising SKIPDATA counts. A flow log that quietly stopped is a blind spot no detection will report.

Deleting or altering flow logs is itself a signal. Those changes are management events in AWS CloudTrail, covered in the AWS CloudTrail Guide, and a rule on flow log deletion belongs in the same detection pack as the flow log rules.

What flow logs do not show

Every detection built on flow logs inherits their blind spots. AWS lists traffic that is not captured, including:

  • traffic from instances to the Amazon DNS server (traffic to your own DNS server is logged);
  • traffic to and from 169.254.169.254, the instance metadata service, and 169.254.169.123, the Amazon Time Sync Service;
  • DHCP and ARP traffic, and traffic to the reserved address of the default VPC router;
  • Windows licence activation traffic;
  • traffic between an endpoint network interface and a Network Load Balancer interface;
  • the source side of mirrored traffic (only the mirror target traffic appears).

Two consequences matter most for detection. First, DNS tunnelling through the Amazon resolver is invisible here, so it needs Route 53 Resolver query logs. Second, an attacker stealing role credentials from the instance metadata service leaves no flow record; the trace appears later as API calls in CloudTrail from an unexpected place. Credential theft from workloads is a non-human identity problem as much as a network one, which the Detection Engineering for Non-Human Identities Guide covers.

Address fields also need care. Traffic to a secondary private IPv4 address shows the primary address in dstaddr, and AWS recommends pkt-dstaddr to capture the original destination. Where client IP preservation is enabled on an intermediate layer, the pkt- fields can show the preserved client address.

Amazon GuardDuty also analyses VPC flow data, through what AWS describes as an independent, duplicate stream. AWS states you do not need to enable flow logs for GuardDuty to use the data, that this does not affect your own flow log configuration, and that GuardDuty does not make the data available in your account. Your own flow logs are still needed for custom detections, hunting and investigations. See the Amazon GuardDuty Guide for its managed findings.

Reading flows correctly

Most false positives in flow log detections come from misreading records, not from bad logic.

Direction and who started the connection

One TCP session produces records in both directions on each interface it touches. Without tcp-flags, you cannot tell reliably which side initiated. AWS's examples show a client sending SYN (2), the server replying with SYN-ACK (18), and FIN (1) at close. Short connections opened and closed in one interval show 3 (SYN plus FIN) from the client or 19 (SYN-ACK plus FIN) from the server. Flags are combined across the interval, and flags such as ACK and PSH are not reported, so a value of 0 is normal for mid-session records.

Security groups versus network ACLs

Security groups are stateful and network ACLs are stateless. AWS's example of a ping shows an accepted inbound request and a rejected response when the outbound ACL does not allow ICMP. A reject on response traffic therefore usually points to an ACL gap, not an attack. Rejects on new inbound connections to many ports are a different matter.

Intermediate hops

For traffic through a zonal NAT gateway, the record on the NAT interface shows the NAT interface address in srcaddr or dstaddr, while pkt-srcaddr and pkt-dstaddr hold the instance and the internet host. For a regional NAT gateway, interface-id and subnet-id are - and resource-id identifies the gateway. Transit gateway traffic behaves the same way: the server's own interface shows the true addresses. Build egress detections on the workload's own interface records, or on the pkt- fields, so alerts name the instance and not the NAT gateway.

Detecting data exfiltration

Exfiltration shows up in flow logs as unusual outbound volume, unusual destinations or unusual paths. The relevant ATT&CK techniques include T1041 Exfiltration Over C2 Channel, T1048 Exfiltration Over Alternative Protocol and T1567 Exfiltration Over Web Service.

Detection ideas, each tuned against your own baselines:

  • Outbound volume per workload. Sum bytes for flow-direction = egress and traffic-path = 8 (internet gateway) per instance per hour, and alert on large departures from that instance's history.
  • New external destinations with high volume. A workload sending more than a set threshold to an address it has never contacted before is a stronger signal than volume alone.
  • Unexpected paths. Egress through VPC peering (traffic-path 4 or 5) or a virtual private gateway (3) from a workload that never uses them.
  • Volume to public storage endpoints from the wrong place. Large egress where pkt-dst-aws-service is S3 through an internet gateway, from a subnet where your design expects S3 traffic to use a gateway VPC endpoint. Flow logs cannot show which bucket or account received the data, so pair this with S3 data events in CloudTrail.
  • Asymmetry. Outbound bytes far above inbound bytes on a session to an external address, especially on ports used for web traffic.

An illustrative Athena style query for the first idea, assuming a table with the custom fields above (adjust names to your schema):

SELECT instance_id, date_trunc('hour', from_unixtime(start)) AS hr, sum(bytes) AS out_bytes, count(DISTINCT pkt_dstaddr) AS dests FROM vpc_flow_logs WHERE flow_direction = 'egress' AND traffic_path = 8 AND action = 'ACCEPT' GROUP BY 1, 2 HAVING sum(bytes) > 5000000000

The 5 GB threshold is a placeholder. Replace it with a per workload baseline, for example a multiple of the 30 day high for that instance.

Detecting scanning and reconnaissance

Scanning is the pattern flow logs show best, because each probe is a distinct flow. Relevant techniques are T1046 Network Service Discovery for scanning inside the environment and T1595 Active Scanning for reconnaissance from outside.

  • Internal horizontal scan. One internal source contacting many internal addresses on the same port within a short window, for example SSH, RDP, SMB or database ports.
  • Internal vertical scan. One source contacting many ports on one host. Count distinct dstport per source and destination pair per interval.
  • Reject bursts. A source generating many REJECT records across many destinations. Rejects are often the clearest scanning evidence because a well segmented environment blocks most probes.
  • SYN only flows. Records with tcp-flags = 2 and very few packets, with no matching SYN-ACK from the destination, indicate connection attempts that never completed.
  • External scanning of exposed assets. Internet scanning against public interfaces is constant. Do not alert on it by default. Instead, alert when an external source that scanned you later gets an ACCEPT on a port you did not expect to be open, which indicates an exposure, not just noise.

An illustrative internal horizontal scan rule: SELECT pkt_srcaddr, dstport, count(DISTINCT pkt_dstaddr) AS targets FROM vpc_flow_logs WHERE flow_direction = 'egress' AND traffic_path = 1 GROUP BY pkt_srcaddr, dstport, date_trunc('minute', from_unixtime(start)) HAVING count(DISTINCT pkt_dstaddr) > 50. Exclude known vulnerability scanners and monitoring hosts by instance ID or tag, never by a broad address range, and review those exclusions regularly.

Detecting command and control and beaconing

Command and control traffic usually hides in normal protocols, so it is hard to spot from metadata alone. Flow logs help with timing, destination and port patterns. Relevant techniques include T1071 Application Layer Protocol, T1571 Non-Standard Port and T1090 Proxy.

  • Beaconing. Regular connections from one workload to one external address with small, similar byte counts. Calculate the spread of intervals between flow start times per source and destination pair over several hours; very low variation is suspicious. A 1 minute aggregation interval makes this far more reliable than 10 minutes.
  • Rare destinations. External addresses contacted by only one workload in the whole estate over 30 days. Enrich with threat intelligence before alerting.
  • Non-standard ports. Long lived outbound sessions on ports your workloads do not normally use, especially from servers whose expected egress is limited to package repositories and AWS services.
  • Egress from workloads that should have none. Any accepted internet egress from a subnet designed to be private, or from a workload tagged as internal only.
  • Long duration sessions. Sessions that persist across many consecutive intervals to one external address, outside the profile of that workload.

Because the Amazon DNS server is not logged, flow logs will not show DNS based C2. Combine these rules with resolver query logs and with GuardDuty findings rather than relying on any single source.

Lateral movement and identity context

Inside a VPC, lateral movement appears as new east to west flows: a web server opening SSH to a database host, or a build runner connecting to production subnets. This maps to T1021 Remote Services. The Lateral Movement Guide covers the technique in more depth.

Useful rules compare flows with an allow list of expected relationships:

  • new source and destination pairs on administrative ports (22, 3389, 5985, 5986) between workloads that have never communicated;
  • connections from container tasks, identified by ecs-task-arn or ecs-service-name, to services outside their declared dependencies;
  • traffic between environments, for example a development subnet reaching a production subnet, identified by subnet-id or environment tags.

The network view becomes much stronger when joined with identity. A workload that starts scanning is usually running under an instance profile or task role. Join the instance-id or task ARN from the flow to the role it assumes, then check CloudTrail for API calls made with that role in the same window. A scan followed by unusual AssumeRole activity, or by API calls from an address outside AWS using that role's credentials, is a much higher confidence story than either signal alone. This is the same machine identity thinking behind the Cloud Detection Engineering Guide.

Rolling out and testing detections

  1. Agree the record format. Define one custom format for all production VPCs and deploy it through infrastructure as code, so every account produces the same fields.
  2. Normalise. Map fields into your SIEM schema, keep both the interface and packet level addresses, and enrich with instance, task, account and tag metadata at ingestion.
  3. Baseline before alerting. Run each rule in monitor mode for two to four weeks (an NHI Mgmt Group recommendation) and record what it would have raised.
  4. Test with safe activity. Generate a small, authorised port scan between two test instances and a controlled outbound transfer to a test endpoint, and confirm each rule fires within the expected delivery delay. Record the test in your purple team log; the Purple Teaming Guide describes the approach.
  5. Write response steps. For each rule, document how to identify the workload, isolate it (for example by moving it to a quarantine security group), preserve evidence and check the associated role in CloudTrail.
  6. Measure. Track true positive rate, time from flow to alert, and the share of production VPCs with healthy flow logs.

Common failure patterns

  • Default format only. Without tcp-flags, flow-direction and the pkt- fields, rules guess at direction and blame the NAT gateway for everything.
  • Ten minute intervals for beacon detection. Coarse aggregation flattens timing patterns and hides short bursts.
  • Assuming full coverage. Treating flow logs as complete when DNS to the Amazon resolver and instance metadata traffic are never recorded.
  • Silent gaps. No alert when a VPC stops producing records, when SKIPDATA rises or when a flow log is deleted.
  • Static thresholds. One estate wide byte threshold that is too high for quiet servers and too low for data pipelines.
  • Broad exclusions. Excluding whole address ranges to silence scanner noise, which also hides an attacker inside those ranges.
  • No identity join. Alerts that name an IP address but not the instance, task, role and owner, so triage starts from zero every time.

Practitioner checklist

  • VPC level flow logs are enabled for every production VPC, deployed through infrastructure as code with one agreed custom format.
  • The format includes vpc-id, subnet-id, instance-id, tcp-flags, pkt-srcaddr, pkt-dstaddr, flow-direction, traffic-path and pkt-dst-aws-service, plus ECS or tag fields where relevant.
  • The aggregation interval is 1 minute for VPCs where beaconing or burst detection matters.
  • Alerts exist for missing flow log data, rising SKIPDATA and flow log deletion in CloudTrail.
  • Route 53 Resolver query logs and CloudTrail cover the DNS and metadata service gaps.
  • Detections exist for egress volume, new high volume destinations, internal horizontal and vertical scans, reject bursts, beaconing and unexpected east to west flows.
  • Each alert is enriched with instance or task, role, account, owner and environment.
  • Exclusions are scoped to named workloads, documented and reviewed at least quarterly.
  • Every rule has a tested response step, including isolation and a CloudTrail check of the workload role.
  • Detection tests are rerun after any change to record format, parsers or SIEM schema.

Standards and references

Related NHI Mgmt Group resources: Amazon VPC Security Guide · Okta System Log Detection Guide · Data Exfiltration Guide · NDR Guide

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.

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 both boxes to continue.