Skip to content
SSRF Write-up Beginner

SSRF in import file function

The application's import-by-URL feature fetched any user-supplied URL server-side without restriction, and followed redirects. An attacker could point it at a redirector that led to the cloud metadata endpoint, causing the server to return its own EC2 credentials into the attacker's account.

Rafael Silva Follow

Published on medium.com

In this post, I’ll describe how I easily managed to exploit an SSRF vulnerability on target.com, a lot of information will be redacted for privacy reasons, but I hope you enjoy reading it.

Rafael Silva., on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

While hunting with his bug bounty team, Vendetta, Rafael Silva found a feature on a target he refers to as target.com that lets a user specify a URL for an online file. The application then automatically fetches the file from that URL and uploads it to the user's account. The report redacts the real host and other identifying details for privacy.

The researcher could not include a screenshot of the application, so he describes the interface instead: a simple button labelled "Upload with a link" and a text box where the user enters the URL to be requested. That is the whole feature: a server-side fetch driven by a user-supplied URL.

Setup

No account details, roles, versions or application stack are given. The only tooling the report names is Beeceptor, which the researcher recommends for inspecting requests, customising endpoints and customising API responses. The report does not describe the account or access needed to reach the feature.

Finding it

Seeing a user-controlled URL that the server fetches, the researcher's first thought was to test for SSRF. He explains the class briefly for readers unfamiliar with it: Server-Side Request Forgery is a vulnerability that lets an attacker force an application to issue requests on the attacker's behalf to unintended resources, such as interacting with the company's internal network. He credits Shorebreak Security for that definition.

The feature is a classic SSRF sink because the server, not the browser, makes the request, so the URL can point at anything the server can reach.

Exploitation

Step 1: Build a redirector

The researcher created an endpoint on Beeceptor:

Text
https://lopseg.free.beeceptor.com/

He configured it to redirect any HTTP request to the internal AWS API endpoint that returns EC2 credentials:

HTTP
http://[redacted]/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance

The first URL is attacker-controlled and publicly reachable, and the server hit it. The second is the EC2 instance metadata service address, which is only reachable from inside the AWS environment. The redirect bridges the two: the server followed it to the metadata endpoint.

Step 2: Submit the URL to the import feature

He inserted the Beeceptor URL into the fetch function. The server requested it and followed the redirect to the internal API.

Step 3: Collect the result

After a few seconds, the credentials returned by the metadata endpoint were loaded into his account. Because the feature's normal behaviour is to store the fetched file in the user's account, the credentials were loaded into his account.

The report does not include the raw request or response, only this sequence of events.

Root cause

The application fetched a user-supplied URL server-side, and the report does not describe any restriction on where it could connect. Two gaps combine here:

  1. The server fetched the attacker's host. The server was willing to fetch the submitted host, and then followed its redirect.
  2. Redirects followed. The Beeceptor endpoint returned a redirect to [redacted], and the server followed it. Any validation applied only to the submitted URL, not to each hop, is bypassed by this pattern.

The metadata endpoint itself is the second half of the problem: it returns EC2 credentials to a caller that can reach it.

Impact

A user of the import feature could make the server issue requests to internal resources. In this case the researcher obtained AWS EC2 identity credentials and had them loaded into his own account through the normal import flow. What those credentials permitted is not described. The report notes only that the security team triaged and resolved the vulnerability quickly.

Fix

Based on the mechanism, the fix would need to cover both gaps: restrict server-side fetches to an allowlist of expected hosts, and revalidate the destination on every redirect rather than only on the submitted URL. Blocking the link-local range and other internal addresses at the HTTP client level would also help, since an allowlist alone does not help if a permitted host can redirect elsewhere.

Variants to test

  1. Direct metadata address. Submit http://[redacted]/latest/meta-data/ straight into the URL field. A positive result is metadata content appearing in the imported file.
  2. Redirect chain. Host a redirector like the one above and point it at an internal address. A positive result is the server following the redirect and returning internal content, which shows redirects are not revalidated.
  3. Alternate encodings of the metadata IP. Try decimal, octal or other representations of [redacted]. A positive result is the same metadata response, showing the blocklist only matches the dotted form.
  4. DNS rebinding. Use a hostname you control that first resolves to a public address and later to an internal one. A positive result is the fetch reaching the internal address after the initial check passed.
  5. Other internal services. Point the redirector at internal admin panels, databases or cloud APIs. A positive result is any response body from a service that should not be reachable from the internet.

Tips from the report

  1. When you see some server-side fetch functionality, try SSRF.
  2. Use Beeceptor.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

A security researcher named Rafael Silva was hunting for bugs with his team, Vendetta. On a website he calls target.com (the real name is hidden for privacy), he found a feature that lets you import a file by giving a web address instead of uploading the file from your computer. The website's own server then goes and downloads whatever is at that address and puts it into your account.

He realised that if the server will fetch any address you give it, you can ask it to fetch addresses that you yourself are not allowed to reach, such as machines inside the company's private network. He set up a small web address of his own that simply says "go look over there instead" and pointed it at a private Amazon Web Services (AWS) address that hands out secret login credentials. The website followed his instructions, fetched the credentials, and loaded them into his account. The company's security team fixed it quickly.

This article walks through the same story from the beginning, explaining every piece as it comes up.

The feature he found

Many websites let you upload a file, for example a profile picture. Some also offer a shortcut: instead of choosing a file on your computer, you paste a link to a file somewhere on the internet, and the website downloads it for you. That is convenient: you do not have to keep your browser open.

The catch is who does the downloading. When you paste a link, it is not your browser that fetches it. It is the website's server, a computer that can often reach machines you cannot. That server can reach machines that you, sitting at home, cannot reach at all.

The researcher could not show a screenshot of the real application, so he described it: a simple button labelled "Upload with a link" and a text box where you type the address to be fetched. That is the entire feature. A person types an address, and a server somewhere goes and gets it.

What SSRF means

Before going further, it helps to know what the researcher was looking for. He explains it himself for readers who have not met the term: Server-Side Request Forgery (SSRF) is a type of vulnerability that lets an attacker force an application to issue requests on the attacker's behalf, to unintended resources, such as interacting with the company's internal network. He credits that definition to Shorebreak Security.

In everyday terms: imagine a building where visitors must stay in the lobby, but the receptionist will happily walk anywhere inside and bring back whatever you ask for. If you can talk the receptionist into fetching a document from the manager's office, you have just read a document you were never allowed to see. The receptionist is the website's server, and the request you talk it into making is the forged request.

The key word is server-side. The request comes from the server, so it carries the server's privileges and the server's network position, not yours. Anything the server can reach, the forged request can reach.

Why this feature is a natural place to look

The import-by-link feature takes an address from the user and hands it to the server. That is exactly the shape of an SSRF: user-controlled input that decides where a server-side request goes. The researcher's first thought on seeing it was to test for SSRF, and that instinct is the whole lesson of the report.

Setting up a redirector

To test the idea, the researcher needed an address he controlled, one that the target's server could reach over the public internet, and that would send the server somewhere else. He used a service called Beeceptor, which he recommends for inspecting requests, customising endpoints and customising API responses. Think of it as a mailbox you can rent on the internet: anything sent to your address lands there, and you can decide what gets sent back.

He created this endpoint:

Text
https://lopseg.free.beeceptor.com/

Line by line, there is only one thing here: a web address on the beeceptor.com domain, under a name he chose (lopseg). Because it is a normal public address, any server on the internet can reach it. That matters, because the target's server has to be able to get there for the test to work.

He then configured that endpoint to redirect any HTTP request to the internal AWS API endpoint that returns EC2 credentials:

HTTP
http://[redacted]/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance

This one needs unpacking, because it is the heart of the attack.

  • http:// is the ordinary web protocol, the same one your browser uses for most pages.
  • [redacted] is a special address. It is not a normal website address on the internet. It is a fixed address that cloud servers use to talk to a small internal service running on the machine itself, called the instance metadata service. AWS is Amazon's cloud platform, and EC2 is its service for renting virtual servers (the "instances").
  • /latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance is the path that asks that internal service for the server's own identity credentials.

Credentials here means secret login material handed out by the metadata service. The metadata address is not reachable from your home computer.

An API, by the way, is simply a way for one program to ask another program for something, usually over the web, and get an answer back in a structured form rather than a pretty web page. The metadata address is an API: you ask it a question in the URL, and it answers with data.

So the plan has two halves. The Beeceptor address is public and harmless-looking, so the target's server will happily fetch it. The metadata address is private and valuable, but the target's server can reach it because the server lives inside AWS. The redirect is the bridge between the two.

Submitting the address

He inserted the Beeceptor URL into the fetch function, the text box behind the "Upload with a link" button. The server requested it and followed the redirect to the internal API.

Why does following a redirect matter so much? When a web server answers a request, it can reply with a special message that means "I do not have what you want here, go ask this other address instead". Your browser does this all the time without telling you, for example when an old link forwards to a new page. The address it sends you to is called the redirect target.

Here, the Beeceptor endpoint answered the target's server with exactly that kind of message, pointing at [redacted]. The target's server obeyed and followed the redirect to the private metadata address. If an application only checks the address the user typed, and not the address it is redirected to, the check is useless. The report does not describe the application's checking logic, so we cannot say for certain what it did or did not validate.

Collecting the result

After a few seconds, the credentials returned by the metadata endpoint were loaded into his account. This is the elegant part: the feature's normal job is to save the fetched file into your account, so the credentials were loaded into his account through the normal flow. The application did the delivery for him.

The report does not include the raw request or response, only this sequence of events.

Why it worked

Two separate weaknesses had to line up.

  1. The server fetched the attacker's address. The import feature fetched the submitted host and then followed its redirect. It was willing to fetch an arbitrary host, including the special link-local metadata address. A link-local address is one that only makes sense on the local network segment, never on the public internet.
  2. Redirects were followed. The Beeceptor endpoint answered with a redirect to [redacted], and the server followed it. Any check applied only to the address the user submitted, and not to each hop along the way, is bypassed by this trick.

The metadata service itself is the other half of the problem: it hands EC2 credentials to a caller that can reach it. That design is deliberate, since the machine needs its own credentials, but it means anything that can make a request from inside the machine can borrow them.

What the impact was

A user of the import feature could make the server issue requests to internal resources. In this case the researcher obtained AWS EC2 identity credentials and had them loaded into his own account through the ordinary import flow. What those credentials would have allowed him to do is not described in the report. He notes only that the security team triaged and resolved the vulnerability quickly.

How it would be fixed

The report does not say what change the company made. Looking at the mechanism, a fix would need to close both gaps: restrict server-side fetches to an allowlist of expected hosts, and recheck the destination on every redirect rather than only on the submitted address. Blocking the link-local range and other internal addresses at the HTTP client level would also help, because an allowlist alone does not help if a permitted host can redirect somewhere else.

Other ways to test the same idea

These are variations on the same theme, useful when you meet a similar feature.

  1. Direct metadata address. Submit http://[redacted]/latest/meta-data/ straight into the URL field. A positive result is metadata content appearing in the imported file.
  2. Redirect chain. Host a redirector like the one above and point it at an internal address. A positive result is the server following the redirect and returning internal content, which shows redirects are not revalidated.
  3. Alternate encodings of the metadata IP. Try decimal, octal or other representations of [redacted]. A positive result is the same metadata response, showing the blocklist only matches the dotted form.
  4. DNS rebinding. Use a hostname you control that first resolves to a public address and later to an internal one. A positive result is the fetch reaching the internal address after the initial check passed.
  5. Other internal services. Point the redirector at internal admin panels, databases or cloud APIs. A positive result is any response body from a service that should not be reachable from the internet.

Tips from the report

  1. When you see some server-side fetch functionality, try SSRF.
  2. Use Beeceptor.

Glossary

  • API: a way for one program to ask another program for data or an action over the network, usually getting a structured answer back.
  • AWS (Amazon Web Services): Amazon's cloud platform, where companies rent servers and other computing resources.
  • Beeceptor: a service for creating web endpoints that record incoming requests and can be configured to answer or redirect them.
  • Bug bounty: a programme where companies pay researchers for finding and reporting security problems in their systems.
  • Credentials: secret material, such as a key or password, that proves an identity and grants access.
  • DNS rebinding: a trick where a hostname you control resolves to a harmless address at first and to an internal address later, so a check and the actual request see different destinations.
  • EC2: Amazon's service for renting virtual servers, called instances.
  • Endpoint: a specific address on a server that accepts requests, for example a particular URL path.
  • HTTP: the protocol browsers and servers use to exchange web requests and responses.
  • Instance: a single virtual server running in a cloud environment.
  • Instance metadata service: a small internal service on a cloud server, reachable at a fixed local address, that answers questions about the machine, including handing out its credentials.
  • Link-local address: an address that is only meaningful on the local network segment and is never routed on the public internet; [redacted] is one.
  • Redirect: a server's answer telling the client to go and request a different address instead.
  • Server-side: happening on the website's server rather than in the visitor's browser.
  • SSRF (Server-Side Request Forgery): a vulnerability that lets an attacker force an application to issue requests on the attacker's behalf to unintended resources, such as the company's internal network.
  • Triaged: reviewed and confirmed as a real issue by the receiving security team.
  • URL: a web address, such as https://example.com/page.
  • Vulnerability: a weakness in software that someone can use to make it behave in a way its owners did not intend.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.