Securing cloud networks requires more than just blocking external threats – it also demands comprehensive cloud network visibility, careful monitoring and restriction of internal connections. Even if an attacker breaches your perimeter, a well-architected and properly segmented internal network can contain lateral movement and significantly mitigate the impact of the breach. This is why enforcing tight network controls on both inbound (ingress) and outbound (egress) traffic for external-facing and internal workloads is crucial to maintaining a strong security posture.
Unlike traditional on-premise firewalls, security group rules do not come with a 'hit counters' or 'last used' timestamps. This lack of cloud visibility makes it difficult for DevSecops or security engineers to identify unused access rules and remove them, as highlighted in numerous security forums and discussions.
Security group rules are often misconfigured to allow "All traffic" or an excessively wide range of ports, creating an easy paths for attackers to move laterally within the network or exfiltrate sensitive data.
While VPC Flow Logs provide detailed records of accepted and rejected network traffic, they do not indicate which security group rule was responsible for allowing or denying that traffic. This limitation makes it difficult for security teams to determine whether an overly permissive rule is actually being used, or if it can be safely tightened or removed.
VPC Flow Logs enable you to capture information about the IP traffic going to and from network interfaces in your VPC. This data provides crucial visibility into your cloud network communications.
A typical VPC flow log record contains these fields:
account-id action az-id bytes dstaddr dstport end flow-direction instance-id interface-id log-status packets pkt-dst-aws-service pkt-dstaddr pkt-src-aws-service pkt-srcaddr protocol region srcaddr srcport start sublocation-id sublocation-type subnet-id tcp-flags traffic-path type version vpc-id
To determine if a communication is successfully established—and therefore if a security group rule is actively used by a specific workload—focus on these fields:
002244369527 ACCEPT use1-az6 11814 10.10.0.73 4000 1738854253 ingress i-03efaa125b5acbd69 eni-027ce9d7c95605b1d OK 22 - 10.10.0.73 - 100.64.0.39 6 us-east-1 100.64.0.39 18762 1738854240 - - subnet-081cfbbbb8bfeb867 2 - IPv4 5 vpc-0d585d9ae3c06759b
This record shows:
In other words, 100.64.0.39 (pkt-srcaddr) is trying to establish (TCP Flag 2, SYN) a communication with 10.10.0.73 (pkt-dstaddr) on port 4000 (dstport).
At this point, we cannot confirm that communication is fully established or that the security group rule allowing port 4000 to this ENI (eni-027ce9d7c95605b1d) is actually being used. We need to observe the reply.
002244369527 ACCEPT use1-az6 9025 100.64.0.39 18762 1738854253 egress i-03efaa125b5acbd69 eni-027ce9d7c95605b1d OK 17 - 100.64.0.39 - 10.10.0.73 6 us-east-1 10.10.0.73 4000 1738854240 - - subnet-081cfbbbb8bfeb867 18 1 IPv4 5 vpc-0d585d9ae3c06759b
This record shows:
In other words, the host at 10.10.0.73 (pkt-srcaddr) is replying (TCP Flag 18, SYN-ACK) to 100.64.0.39 (pkt-dstaddr) from port 4000.
With this response, we can confirm that the security group rule allowing TCP port 4000 on this workload's ENI (eni-027ce9d7c95605b1d) is actively being used.
For a comprehensive list of TCP flags in vpc flow logs see here (FIX ME article about vpc flow logs flags).
The overall process to analyze VPC flow logs and correlate against security group rules should look like the below
By systematically analyzing VPC Flow Logs, you can:
Although you can manually analyze VPC Flow Logs by following the steps above—with a custom function or via AWS Athena—this approach is time‑consuming, error‑prone, and still requires you to correlate flow logs with your security group configuration.
The CloudFence team has developed an automated cloud network security and visibility solution that simplifies VPC Flow Log and Security Group analysis.
Rather than managing complex queries and manual correlation, CloudFence provides:
CloudFence automates VPC Flow Log and security‑group analysis to continuously enforce least‑privilege across your cloud footprint—dramatically narrowing attack pathways and virtually eliminating lateral‑movement for attackers. It also streamlines compliance audits and significantly reduces the time required to demonstrate and maintain your security posture.
Looking to dive deeper? Check out these handpicked articles related to cloud visibility, threat detection, and workload protection.