5 VPC and Network Security Mistakes That Widen Your Attack Surface
The network misconfigurations that actually get AWS accounts breached — open security groups, public subnets, no flow logs — and how to fix each.
A lot of AWS security guides focus on IAM and stop there, but network configuration causes just as many real incidents — it's just less talked about. A security group open to the entire internet, a database sitting in a public subnet that never needed to be there, no visibility into what traffic is actually flowing. None of it requires a misconfigured policy to exploit; the network is just... open.
Here are 5 network security mistakes that show up constantly in AWS accounts, and how to fix each one.
1. Security groups open to 0.0.0.0/0
This is the network equivalent of the IAM
"Action": "*" mistake. It usually starts innocently — someone's debugging why they can't connect to something, adds a rule allowing all traffic from anywhere to get unblocked, and just... never removes it.Type: SSHProtocol: TCPPort: 22Source: 0.0.0.0/0
That rule lets literally anyone on the internet attempt to connect to port 22 on that instance. Combine it with a weak or reused password and you've got a very findable target — there are bots scanning the entire IPv4 range for open SSH and RDP ports constantly, not targeting you specifically, just sweeping everything.
Fix it:
- Scope the source to a specific IP or CIDR range — your office IP, your VPN range, whatever's actually legitimate.
- For remote access, consider AWS Systems Manager Session Manager instead of exposing SSH/RDP at all — it lets you connect to an instance without opening any inbound port, using IAM permissions instead of network exposure.
- If you truly need broad access (like a public web server on port 443), that's fine — the rule should just match what's actually meant to be public, not everything by default.
2. Databases and internal services in public subnets
A public subnet is one with a route to an internet gateway. If an RDS instance, an internal API, or anything not meant to be internet-facing sits in a public subnet — especially combined with a security group that's too open — it's reachable directly from the internet, no VPN or bastion required.
Fix it:
- Put databases, internal APIs, and anything without a genuine need for direct internet access in private subnets.
- Use a NAT gateway if those private resources still need outbound internet access (for updates, external API calls, etc.) without accepting inbound connections.
- For RDS specifically, double check the "Publicly accessible" setting at creation time — it's a separate toggle from subnet placement and easy to leave on by accident.
3. Still using the default VPC without thinking about it
Every AWS account comes with a default VPC, already configured with public subnets and permissive default settings, meant to make it easy to launch something quickly. The problem is a lot of production workloads end up staying there because it's just the path of least resistance, not because anyone deliberately decided it was the right setup.
Fix it:
- Design a purpose-built VPC for real workloads: public subnets for things that need to be public, private subnets for everything else, clear separation between environments (dev, staging, prod) — ideally in separate VPCs or accounts entirely.
- If the default VPC isn't being used deliberately, it's reasonable to just delete it in accounts where it adds no value, removing one more thing that could get used by accident.
4. No VPC Flow Logs
Without flow logs, you have no record of what traffic is actually hitting your network — no way to see rejected connection attempts, no way to investigate after the fact if something looks off. It's the network equivalent of not having S3 access logging: you don't need it until you really need it, and by then it's too late to have historical data.
Fix it:
- Enable VPC Flow Logs at the VPC level, sending them to CloudWatch Logs or S3.
- Look for patterns like repeated REJECT entries from the same source — that's often the earliest sign of a scan or probing attempt against your account.
- Combine flow logs with GuardDuty if you want automated analysis on top of the raw log data instead of reviewing it manually.
5. No segmentation between environments
Dev, staging, and production often end up in the same VPC, sometimes even the same subnet, with overlapping security groups. If dev has looser security controls (which it often does, intentionally, to make iteration faster) and it can reach production resources, dev becomes the weak link that puts prod at risk too.
Fix it:
- Separate environments into different VPCs, or ideally different AWS accounts entirely, using AWS Organizations to manage them centrally.
- If they must share a VPC, at minimum segment with different subnets and security groups that don't allow direct access between environments.
- Treat dev and staging security with the same seriousness as prod when it comes to network access — the "it's just dev" mindset is exactly what makes it a soft entry point.
The short version
Mistake | Fix |
|---|---|
Security groups open to 0.0.0.0/0 | Scope to specific IPs, use Session Manager instead of exposing SSH/RDP |
Databases in public subnets | Move to private subnets, use NAT gateway for outbound only |
Default VPC used without thinking | Design a purpose-built VPC, delete the default if unused |
No VPC Flow Logs | Enable them, watch for repeated REJECT patterns |
No segmentation between environments | Separate VPCs/accounts, don't treat dev as low-stakes |
Same theme as the rest of this series: nothing here requires deep networking expertise, just not leaving the convenient defaults in place longer than they should be. A security group rule takes seconds to fix. The hard part is remembering to check.
If you're setting up a new VPC, walk through this list before anything goes live in it — segmentation and subnet placement are a lot more annoying to retrofit once real traffic depends on the current layout.
Working through something specific — bastion hosts, VPC peering, Transit Gateway setups? Drop a comment.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article