Course contentsShow
← Security
Lesson 895 of 3,05218. Web Security - CSRF and Request ForgeryFree lesson

Network-Level SSRF Defenses

Use network segmentation, firewall rules, and egress filtering to restrict server outbound connections to necessary destinations only.

Network-Level SSRF Defenses

You'll learn how to use network architecture and infrastructure controls to limit the damage attackers can do even if they find an SSRF vulnerability in your application.

The Perimeter Defense Concept

Even with perfect input validation (which is hard to achieve), defense-in-depth means preparing for the worst. Network-level SSRF defenses work like building walls around your vulnerable server—if an attacker does manage to make your server send malicious requests, these controls limit where those requests can actually go.

Think of it like giving your delivery driver strict route instructions: even if someone tricks them into carrying a dangerous package, they can only deliver to approved addresses.

Core Network-Level Controls

Network Segmentation

Isolate your application servers from sensitive internal resources. Your web server shouldn't be in the same network segment as your database, internal APIs, or cloud metadata services. Use VLANs or separate subnets to create boundaries.

Egress Filtering

Configure your firewall to block outbound connections by default, then whitelist only necessary destinations. Your application server probably doesn't need to contact arbitrary internet hosts—it might only need to reach specific external APIs on specific ports.

Firewall Rules

Create explicit rules:

  • Block access to cloud metadata services (169.254.169.254, fd00:ec2::254)
  • Block RFC 1918 private IP ranges unless specifically needed
  • Block localhost/127.0.0.0/8 connections
  • Allow only specific destination IPs/domains on required ports

DNS Controls

Use DNS firewalls or resolvers that prevent resolution of internal hostnames from application servers, stopping attackers from reaching internal resources by name.

Key Takeaway: Network-level SSRF defenses limit where your server can connect, creating multiple layers of protection so that even if application-level validation fails, infrastructure controls prevent access to sensitive resources.