Most web applications make requests.
They retrieve images, validate URLs, call APIs, generate previews, process webhooks, import remote files, and communicate with internal services.
Normally, those requests are exactly what the developer intended.
But what happens when the user controls where the server sends them?
That is the foundation of Server-Side Request Forgery, or SSRF.
SSRF is particularly interesting because the vulnerable application becomes part of the attack. Instead of the attacker connecting directly to a protected resource, the attacker convinces the server to make the request on their behalf.
In some implementations, that capability can extend beyond HTTP requests and expose files from the server's local filesystem.
The vulnerability then becomes a chain:
User-controlled URL
↓
Server makes request
↓
Unexpected URI scheme accepted
↓
Local file accessed
↓
Sensitive information disclosed
Understanding why that happens requires thinking about the application from the server's perspective rather than the attacker's.
What Is SSRF?
Consider an application that retrieves an image from a URL supplied by the user.
A request might contain:
https://images.example.com/avatar.png
The application receives that value and performs the request from the server:
Browser
│
│ URL
▼
Application Server
│
│ HTTP request
▼
images.example.com
That architecture is not inherently vulnerable.
The problem appears when the application accepts a user-controlled destination without sufficiently restricting where the server is allowed to connect.
Suppose an attacker changes the destination:
http://127.0.0.1:8080/admin
The request path becomes:
Attacker
│
│ supplies URL
▼
Application Server
│
│ request originates here
▼
127.0.0.1:8080
The attacker never directly connects to the internal service.
The application does it for them.
That difference is what makes SSRF powerful.
The Server Has a Different View of the Network
From the attacker's machine, an internal service might be completely unreachable.
For example:
Attacker
│
X
│
10.0.0.15:8080
A firewall prevents external access.
But the vulnerable application may live inside the same network:
Internet
│
▼
Web Server
│
├── 10.0.0.15:8080
├── 10.0.0.20:3000
└── 127.0.0.1:9000
If the attacker controls requests made by that server, the server's network position becomes part of the attack surface.
This is one of the most important ideas behind SSRF:
The relevant question is not what the attacker can reach. It is what the vulnerable server can reach.
That might include services that were never designed to accept requests from the public Internet.
A Simple Vulnerable Pattern
Imagine an application that accepts a URL:
GET /preview?url=https://example.com/article
The server retrieves the supplied resource and returns a preview.
A simplified implementation might resemble:
url = request.args.get("url")
response = requests.get(url)
return response.textThe intended flow is:
User
↓
Application
↓
Public website
But the application has delegated an important security decision to the user:
Where should the server connect?
If there are no meaningful destination restrictions, the user may be able to answer that question with something the developer never anticipated.
For example:
http://localhost/admin
or:
http://127.0.0.1:8080
or an internal address:
http://10.0.0.15/
The functionality is still doing exactly what it was programmed to do.
It is retrieving a URL.
The security problem is that the attacker controls the destination.
SSRF Is Not Just About HTTP
URLs are often treated as though they mean:
http://
or:
https://
But software libraries may support multiple URI schemes.
Depending on the language, library, configuration, and underlying request mechanism, supported schemes can potentially include things other than HTTP.
One particularly important example is:
file://
The file URI scheme refers to local filesystem resources.
Conceptually:
file:///path/to/file
means:
Retrieve this local file
rather than:
Send an HTTP request to another server
If an application accepts arbitrary user-controlled URLs and its retrieval mechanism supports file://, SSRF-style functionality may become a path to local file disclosure.
From SSRF to Local File Disclosure
Suppose the application expects:
https://example.com/image.jpg
but receives:
file:///etc/passwd
If the underlying request mechanism accepts the scheme and the application returns the resulting content, the flow changes dramatically:
Attacker
│
│ file:///etc/passwd
▼
Application
│
│ opens local resource
▼
/etc/passwd
│
▼
Application response
│
▼
Attacker
No HTTP request needs to leave the server.
The vulnerable feature has effectively become a file-reading primitive.
On a Linux system, /etc/passwd is often useful as a harmless proof of concept because it demonstrates that local file access occurred without normally exposing password hashes.
The important finding is not that /etc/passwd itself is particularly sensitive.
The important finding is:
An unauthenticated or insufficiently privileged user may be able to cause the application to read local files.
Once that capability exists, the next question is what else the application's process can read.
Process Permissions Still Matter
SSRF does not magically bypass operating-system permissions.
If the application runs as:
www-data
then local file access generally remains constrained by what that process can access.
Conceptually:
Attacker
↓
Vulnerable application
↓
Application process permissions
↓
Readable files
A request for:
file:///root/secret.txt
may fail.
But other files might be readable.
Depending on the application and host configuration, potentially interesting targets can include:
Application configuration
Environment-related files
Source code
Logs
Service configuration
Deployment metadata
Credentials stored in files
Private application data
The vulnerability's real impact therefore depends heavily on the privileges and environment of the affected process.
Why Application Configuration Matters
Configuration files are particularly valuable because applications need credentials to communicate with other systems.
A configuration file might contain something resembling:
DB_HOST=database.internal
DB_USER=webapp
DB_PASSWORD=example-password
Or:
API_KEY=example-api-key
Or:
JWT_SECRET=example-signing-secret
A local file disclosure vulnerability can therefore become the first step in a larger attack chain:
SSRF
↓
Local file disclosure
↓
Configuration recovered
↓
Credential discovered
↓
Another service accessed
The initial vulnerability may provide read access only.
The information obtained through that read access may enable something considerably more serious.
Source Code Can Be Just as Valuable
Credentials are not the only useful target.
If application source code can be read, an attacker may gain visibility into:
Authentication logic
Authorization checks
Database queries
API endpoints
Filesystem paths
Internal services
Cryptographic implementation
Input validation
Debug functionality
Without source access, an attacker might see:
POST /login
With source access, they may see exactly how /login works.
That can transform an opaque application into a much easier target.
The impact of local file disclosure should therefore be evaluated based on what the disclosure enables, not merely on the first file successfully retrieved.
SSRF Versus Local File Inclusion
SSRF that results in local file disclosure can look similar to another vulnerability class: Local File Inclusion, or LFI.
The distinction is useful.
An LFI vulnerability typically occurs when user input influences which file the application loads or includes.
Conceptually:
?page=../../../../etc/passwd
The vulnerable operation is directly related to filesystem paths.
SSRF begins from a different primitive:
?url=https://example.com
The application is designed to retrieve a resource identified by a URI.
If the retrieval mechanism also accepts:
file://
then the SSRF-capable functionality may reach the local filesystem.
The result can look similar:
Local file contents disclosed
but the underlying vulnerability is different.
Understanding the primitive matters because it determines what other behavior should be tested.
Testing the Scheme
When examining URL-fetching functionality during an authorized security assessment, one useful question is:
Which URI schemes does the application actually accept?
A feature may correctly restrict hosts while failing to restrict protocols.
For example, developers may validate that a URL does not point to:
127.0.0.1
but never consider that:
file://
does not require a network destination at all.
Likewise, checking only whether input begins with:
http
can produce fragile security controls depending on how parsing and validation are implemented.
Security decisions involving URLs should be based on proper URL parsing and explicit policy rather than string manipulation.
Why Blacklists Are Fragile
A common SSRF defense starts with blocking known-dangerous destinations.
For example:
127.0.0.1
localhost
10.0.0.0/8
192.168.0.0/16
This can help, but destination blacklists are difficult to make comprehensive.
URL handling involves many layers:
User input
↓
URL parser
↓
Hostname resolution
↓
IP address
↓
Redirects
↓
Destination
Security checks performed at only one layer can disagree with what the networking stack ultimately does.
A hostname might resolve unexpectedly.
A permitted URL might redirect somewhere prohibited.
Different parsers may interpret unusual URL forms differently.
Alternative address representations can create edge cases.
And none of those destination checks necessarily address an unwanted URI scheme such as:
file://
The core problem is trying to enumerate every destination the application should not access.
When possible, it is safer to define exactly what the application is allowed to access.
Prefer Allowlisting
Suppose an application only needs to retrieve images from:
https://cdn.example.com/
Then the security policy can be narrow:
Scheme: HTTPS only
Host: cdn.example.com only
Port: 443 only
Everything else is rejected.
Conceptually:
User URL
↓
Parse URL
↓
Is scheme HTTPS?
│
├── No → Reject
│
└── Yes
↓
Is host approved?
│
├── No → Reject
│
└── Yes
↓
Resolve destination
↓
Validate destination
↓
Make request
This is much easier to reason about than attempting to identify every dangerous destination on the Internet.
Redirects Matter Too
Validation should not stop after the first URL.
Consider:
https://allowed.example/resource
The initial destination may be permitted.
But that server could respond:
302 Location: http://127.0.0.1/admin
If the HTTP client automatically follows redirects without revalidating the new destination, the security control may be bypassed.
The effective flow becomes:
Approved URL
↓
Validation passes
↓
Request
↓
Redirect
↓
Unapproved destination
Every redirect destination should be subject to the same security policy as the original request.
Network Architecture Is Part of the Defense
Application-level validation should not be the only control.
The vulnerable server should also have limited ability to initiate unnecessary outbound connections.
Network controls can restrict access to:
Internal management services
Cloud metadata services
Administrative interfaces
Sensitive network segments
Unnecessary Internet destinations
This creates defense-in-depth.
If the application validation fails:
Attacker input
↓
Application validation
↓
Network policy
↓
Destination
the network layer may still prevent the connection.
SSRF is a particularly strong example of why outbound network access deserves security attention.
Organizations often focus heavily on:
Who can connect to this server?
SSRF forces us to ask the opposite question:
Where is this server allowed to connect?
Reporting the Vulnerability
A useful SSRF finding should explain more than:
The application is vulnerable to SSRF.
The report should establish the actual behavior and impact.
For example:
User-controlled input
↓
Server-side resource retrieval
↓
file:// scheme accepted
↓
Local filesystem resource retrieved
↓
File contents returned to user
Then determine what that primitive exposes.
Can the application read only low-sensitivity system files?
Can it retrieve application configuration?
Can it access source code?
Can recovered information expose credentials?
Can those credentials access another service?
Can the server reach internal network resources?
The severity should follow the demonstrated impact.
SSRF is a vulnerability class.
The risk comes from what the attacker can accomplish with it.
Remediation
Effective SSRF defenses generally require several complementary controls.
Restrict URI Schemes
If the application requires HTTPS, accept only HTTPS.
Do not allow arbitrary protocols simply because the underlying library supports them.
Restrict Destinations
Where possible, maintain an explicit allowlist of hosts or services the application legitimately needs.
Validate Resolved Addresses
Security decisions should account for the actual network destination after hostname resolution.
Requests resolving to prohibited address ranges should be rejected when those destinations are not required.
Revalidate Redirects
Every redirect should be treated as a new destination requiring validation.
Restrict Outbound Network Access
Application servers should only be able to reach services they actually need.
Use Least Privilege
The application process should have access only to the files and resources necessary for its function.
This limits the impact if local file access becomes possible.
Protect Secrets
Sensitive credentials should be managed through appropriate secret-management mechanisms and scoped as narrowly as possible.
If a disclosure exposes a credential, rotate it.
The Bigger AppSec Lesson
SSRF is a useful vulnerability to study because it forces a change in perspective.
When testing an application, it is easy to think entirely from the attacker's position:
What can I reach?
SSRF introduces another question:
What can I make the application reach?
And local file disclosure extends it further:
What can I make the application retrieve?
Those questions reveal security boundaries that are easy to overlook.
A server is not merely something receiving requests.
It is also a machine with:
A network position
A filesystem
Credentials
Permissions
Trust relationships
Internal connectivity
When attacker-controlled input influences how the server uses those capabilities, the server itself can become an attack primitive.
That is the deeper lesson behind SSRF.
The vulnerability is not simply that the application fetched the wrong URL.
The vulnerability is that an external user gained control over a capability that belonged to the server.