Skip to content
SSRF Disclosed report Intermediate

Server Side Request Forgery (SSRF) via Analytics Reports

megaman_ Follow

Originally disclosed on HackerOne

Bounty$25,000 Critical 10.0 View original
  • Triaged in 25 hours
  • Fixed in 5 days
  • Paid in 5 days
  • Disclosed after 15 days

Summary by the program

We recently received a critical server-side request forgery (SSRF) vulnerability report through our bug bounty program. The issue allowed attackers to make internal requests from our application servers by exploiting a lack of output sanitization in an error message. By crafting malicious requests, an attacker could have accessed internal AWS services and obtained temporary credentials.

Upon receiving the report, we were able to reproduce and verify the issue. We have implemented a fix that is now deployed in production. Below you can see that element[:template] wasn’t properly sanitized in the error message. The value being returned html_without_layout is being fed into a library that converts this into a PDF.

Diff:

Ruby
             
html_without_layout = elements.map do |element|
  case element[:type]
  when 'template'
    path = template_path(element)
    if path
      ApplicationController.new.render_to_string(
        partial: path,
        layout: false,
        assigns: {
          include_css: true,
        },
        locals: {
          query_results:,
          constants: PSR_CONSTANTS,
          retesting_reports: retesting_reports,
          reporters: reporters,
          total_submission_count: total_submission_count,
          in_scope_asset_count: in_scope_asset_count,
          report_asset_count: report_asset_count,
        },
      )  
    else
-    "Missing template for element: #{element[:template]}"
+    "Missing template for element"

We have also added regression tests to prevent future occurrences of this vulnerability.

Our forensic investigation concluded that there is no evidence this issue was exploited prior to the report.

We have rated this vulnerability CVSSv3 10 (Critical) based on the potential impact of exposed credentials:

CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N/CR:H/IR:H/AR:H.

We want to thank @mega7 for sending in their report; reports like this one are invaluable for us to continue enhancing our security posture. We also appreciate them for stopping at the right point in testing, demonstrating a responsible and ethical approach.

Summary by the researcher

Report Conclusion:

  • The Main Issue:

I was able to access AWS Credentials using an SSRF vulnerability by injecting an <iframe> tag into template element when generating a PDF of analytics reports.

  • The potential impacts of this vulnerability:

  1. Ability to read internal files.
  2. Unauthorized Access to AWS Credentials.
  3. Manipulating AWS resources.
  4. Possibility of Data Loss.
  5. Accounts Takeover.
  6. Executing Arbitrary Commands.
  • What did I do when I found this vulnerability:

I quickly reported this issue as soon as I found it, then I was trying to find the quickest way to alert Hackerone team as quickly as possible, especially because I know it could take some days for a response. then I thought about sending a message to some of the Hackerone triage team, I was expecting a response within a few hours but it doesn't happened. So I decided to send a message to @jobert, and I was really surprised by his quick and kind response.

  • How the Hackerone team was responsible for fixing this issue and how they responded:

I was really surprised by Hackerone quick response, they have fixed the issue and let me retest it in less than 24 hours. They are a very collaborative team.

  • Supporting Material/References:

Best Regards, @Mega7

The report

Hello Gents, I would like to report an issue where attackers are able to read internal files via an SSRF vulnerability.

Proof of concept

  • ███

Impact

SSRF.

Thanks and have a nice day!

The original report as published on HackerOne, by megaman_. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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. 5 min read.

Context

HackerOne runs a bug bounty platform, and part of that platform is analytics reporting: users can generate reports that are rendered as PDFs. Those reports are built from a list of elements, and one of the element types is a template, which is rendered server-side through ApplicationController.new.render_to_string with a partial path, a set of locals (query results, constants, retesting reports, reporters, submission counts, asset counts) and no layout. The rendered HTML is then passed to a library that converts it into a PDF.

The vulnerability disclosed here is a server-side request forgery in that PDF generation path. The researcher, @Mega7, found that an <iframe> tag injected into the template element of an analytics report was rendered into the PDF pipeline, and that this allowed internal requests to be made from the application servers, reaching internal AWS services and obtaining temporary credentials.

Setup

The report does not describe the account, role or tooling used to reach the analytics report feature. What it does establish is the precondition: the attacker needs to be able to control the template value of an element in an analytics report that is then rendered to PDF. No special privileges beyond that are described.

Finding it

The researcher's summary states the core observation directly: by injecting an <iframe> tag into the template element when generating a PDF of analytics reports, it was possible to trigger an SSRF and reach AWS credentials. The program's own summary explains where the injected value surfaced: when a template path could not be resolved, the error message included the raw element[:template] value, and that message was not sanitised before being fed into the PDF conversion library.

So the flaw was not in the template rendering itself but in the error path. A missing template produced a string containing attacker-controlled markup, and that string became part of the HTML handed to the PDF renderer.

Exploitation

Step 1: inject markup into the template element

The researcher placed an <iframe> tag into the template element of an analytics report. The report does not reproduce the exact payload or the request that carried it, so the precise syntax is not available here. What matters is that the value ends up in element[:template] and that the template lookup fails, which routes execution into the error branch.

Step 2: the error message carries the payload into the PDF renderer

The program published the relevant diff, which shows the vulnerable branch and the fix:

Ruby

html_without_layout = elements.map do |element|
  case element[:type]
  when 'template'
    path = template_path(element)
    if path
      ApplicationController.new.render_to_string(
        partial: path,
        layout: false,
        assigns: {
          include_css: true,
        },
        locals: {
          query_results:,
          constants: PSR_CONSTANTS,
          retesting_reports: retesting_reports,
          reporters: reporters,
          total_submission_count: total_submission_count,
          in_scope_asset_count: in_scope_asset_count,
          report_asset_count: report_asset_count,
        },
      )
    else
-    "Missing template for element: #{element[:template]}"
+    "Missing template for element"

The else branch is the interesting one. Before the fix, the string "Missing template for element: #{element[:template]}" interpolated the attacker-controlled template value straight into the HTML that html_without_layout accumulates. That HTML is what the PDF conversion library receives. After the fix, the value is dropped from the message entirely.

Step 3: the iframe is fetched server-side

Because the PDF renderer processes the HTML, the injected <iframe> causes the rendering component to make a request to the URL it specifies. That request originates from the application server rather than from the researcher's browser, which is the SSRF. The researcher used this to reach internal AWS services and obtain temporary credentials.

The report does not include the internal URL, the response body, or the credential format, so those details cannot be reproduced here.

Root cause

The mistake is a missing output sanitisation on an error message. The template path lookup can fail, and the failure message was built by interpolating the user-supplied element[:template] value into HTML. That HTML was then passed to a library whose job is to render HTML into a PDF, and such libraries fetch subresources such as iframes. The result is that user input crossed from a data context into an active rendering context with network access.

The existing defences did not stop it because the value was not escaped at the point where it entered the HTML, and because the PDF renderer was trusted to process whatever HTML it was given. The program's summary frames it exactly this way: element[:template] was not properly sanitised in the error message, and the returned html_without_layout was fed into the PDF conversion library.

Impact

The program rated the issue CVSSv3 10 (Critical) with the vector:

Text
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N/CR:H/IR:H/AR:H

The justification given is the potential impact of exposed credentials. The researcher listed the potential impacts as:

  1. Ability to read internal files.
  2. Unauthorized access to AWS credentials.
  3. Manipulating AWS resources.
  4. Possibility of data loss.
  5. Account takeover.
  6. Executing arbitrary commands.

These are the researcher's stated possibilities; the program's forensic investigation concluded that there is no evidence the issue was exploited prior to the report. The bounty was 25,000 USD.

Fix

The program changed the error message so that it no longer includes the template value, as shown in the diff above: "Missing template for element: #{element[:template]}" became "Missing template for element". Regression tests were added to prevent future occurrences. The fix is deployed in production, and the researcher says the issue was fixed and available for retest in less than 24 hours.

Variants to test

  1. Error paths that echo input. Submit values that fail a lookup (missing template, unknown report type, invalid filter) and watch whether the raw value appears in any generated document, email or PDF. A positive result is your markup appearing unescaped in the rendered output.
  2. PDF and document generators with subresource loading. Wherever user input reaches an HTML-to-PDF or HTML-to-image pipeline, try an <iframe>, <img> or <link> pointing at an internal address. A positive result is a request arriving at a host you control from the application's egress address, or an internal response reflected into the document.
  3. Cloud metadata endpoints. Point the injected subresource at the metadata service of the hosting provider. A positive result is credential material or instance data appearing in the generated document or in a callback.
  4. Template path parameters. Try path traversal or absolute paths in the template identifier itself, not just markup, and observe whether the error or the rendered output discloses file contents.
  5. Sanitisation applied only on the success path. Compare how a valid template value and an invalid one are handled; the invalid branch is often the one that skips escaping.

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. 13 min read.

What happened, in plain words

HackerOne is a website where companies pay independent security researchers to find mistakes in their software. The company that runs the site also uses the site itself, and one of its features is analytics reporting: a user can ask the platform to produce a report, and the platform turns that report into a PDF file, the same kind of document you would open in a PDF reader.

A researcher called @Mega7 found a way to make HackerOne's own servers fetch a web address of the researcher's choosing while building such a PDF. That kind of trick is called server-side request forgery, or SSRF: instead of your browser making a request, the victim's server makes it for you, from inside the company's network where it can reach things the public internet cannot.

In this case the server was tricked into contacting internal Amazon Web Services (AWS) systems, and the researcher obtained temporary credentials. Credentials are the username-and-password equivalent for machines: strings that prove to a cloud provider who you are and what you are allowed to do. With temporary AWS credentials, someone could potentially read internal files, change cloud resources, cause data loss, take over accounts or run commands. HackerOne rated the issue 10 out of 10 on the CVSS scale, the maximum, and paid a 25,000 USD bounty. The company says its investigation found no evidence the flaw was used before the report, and the fix is live.

This article walks through what the researcher did, what the company changed in its code, and why each step matters, assuming you have never looked at a security report before.

Background you need first

A few ideas come up again and again, so here they are from zero.

A server and a browser. Your browser is the program on your computer that shows web pages. A server is a computer somewhere else that stores the website and answers requests. When you open a page, your browser asks the server for it and the server sends it back. Normally the server only fetches things when a user asks it to, and only things that belong to the site.

An API. Think of a restaurant. The menu is the list of things you can order, the waiter takes your order to the kitchen, and the kitchen sends back a dish. An API (application programming interface) is the waiter: a defined way for one piece of software to ask another piece of software to do something and get an answer back. Websites use APIs constantly, for example when a page asks the server for a list of reports.

A PDF. A PDF is a file format for documents that look the same on every device. Many websites generate PDFs on the fly, for invoices, tickets or reports. To do that, the server takes some HTML (the language web pages are written in), hands it to a library (a bundle of ready-made code), and the library turns it into a PDF.

HTML tags. HTML is written with tags such as <p> for a paragraph or <img> for an image. An <iframe> tag embeds another web page inside the current one. When a browser, or a PDF generator that behaves like a browser, sees an <iframe>, it goes and fetches the address inside it. That fetching is the key to everything below.

A cookie or token. When you log in, the server gives your browser a small piece of text, a cookie or token, that it checks on every later request so it knows who you are. Cloud providers use similar tokens, called credentials, to let programs act on your behalf. If someone else gets your token, they can act as you.

SSRF. Server-side request forgery means tricking a server into making a request you control. Imagine you cannot enter a building, but the receptionist can. If you can convince the receptionist to walk into a back room and read a document aloud to you, you have done SSRF. The receptionist is the server, the back room is the internal network, and the trick is the input you gave it.

Sanitisation. Sanitising input means cleaning it before using it, for example turning < into a harmless code so it is shown as text instead of being treated as the start of a tag. If a program forgets to sanitise, user input can be interpreted as instructions rather than as plain data.

CVSS. The Common Vulnerability Scoring System is a standard way to score how serious a security flaw is, from 0 to 10. A 10 is the maximum.

The feature that was attacked

HackerOne's analytics reporting lets a user build a report out of a list of elements. Each element has a type, and one of the types is template. A template is a reusable piece of page layout, like a form letter with blanks to fill in. When the platform builds the report, it renders the template on the server: it takes a template file, fills in data such as query results, constants, retesting reports, reporters, submission counts and asset counts, and produces HTML. That HTML is then passed to a library that converts it into a PDF.

The report does not describe which account, role or tools the researcher used to reach this feature. What it does establish is the precondition: the attacker needs to be able to control the template value of an element in an analytics report that is then rendered to a PDF. No special privileges beyond that are described.

Finding it

The researcher's summary states the core observation directly: by injecting an <iframe> tag into the template element when generating a PDF of analytics reports, it was possible to trigger an SSRF and reach AWS credentials.

The company's summary explains where the injected value surfaced. When a template path could not be resolved, the error message included the raw element[:template] value, and that message was not sanitised before being fed into the PDF conversion library. So the flaw was not in the template rendering itself but in the error path. A missing template produced a string containing attacker-controlled markup, and that string became part of the HTML handed to the PDF renderer.

Why does the error path matter? Because developers often focus on the happy path, the case where everything works, and treat error messages as harmless text. But an error message is still text that gets shown or processed somewhere, and if it contains user input, that input can become active.

Exploitation

Step 1: inject markup into the template element

The researcher placed an <iframe> tag into the template element of an analytics report. The report does not reproduce the exact payload or the request that carried it, so the precise syntax is not available here. What matters is that the value ends up in element[:template] and that the template lookup fails, which routes execution into the error branch.

Why make the lookup fail? Because the error branch is the one that echoes the value back. A valid template would be rendered normally; an invalid one falls into the else branch shown below, and that branch builds a message containing the raw value.

Step 2: the error message carries the payload into the PDF renderer

The company published the relevant diff, which shows the vulnerable branch and the fix:

Ruby

html_without_layout = elements.map do |element|
  case element[:type]
  when 'template'
    path = template_path(element)
    if path
      ApplicationController.new.render_to_string(
        partial: path,
        layout: false,
        assigns: {
          include_css: true,
        },
        locals: {
          query_results:,
          constants: PSR_CONSTANTS,
          retesting_reports: retesting_reports,
          reporters: reporters,
          total_submission_count: total_submission_count,
          in_scope_asset_count: in_scope_asset_count,
          report_asset_count: report_asset_count,
        },
      )
    else
-    "Missing template for element: #{element[:template]}"
+    "Missing template for element"

Line by line, in plain words:

  • html_without_layout = elements.map do |element| starts building a list of HTML pieces, one per element in the report. map means "go through every item and produce a new item for each".
  • case element[:type] looks at what kind of element this is.
  • when 'template' handles the template type.
  • path = template_path(element) works out which template file to use for this element.
  • if path checks whether a template was found.
  • ApplicationController.new.render_to_string(...) renders the template into a string of HTML. The options say: use this partial (template file), no surrounding layout, include the CSS, and fill in the listed data (query results, constants, retesting reports, reporters, submission counts, asset counts).
  • else is the branch taken when no template was found.
  • The line starting with - is the old code: "Missing template for element: #{element[:template]}". The #{...} part inserts the value of element[:template] into the message. That value is whatever the user supplied, so if the user supplied an <iframe> tag, the tag ends up in the message.
  • The line starting with + is the new code: "Missing template for element". The user's value is gone from the message.

The else branch is the interesting one. Before the fix, the string "Missing template for element: #{element[:template]}" interpolated the attacker-controlled template value straight into the HTML that html_without_layout accumulates. That HTML is what the PDF conversion library receives. After the fix, the value is dropped from the message entirely.

Step 3: the iframe is fetched server-side

Because the PDF renderer processes the HTML, the injected <iframe> causes the rendering component to make a request to the URL it specifies. That request originates from the application server rather than from the researcher's browser, which is the SSRF. The researcher used this to reach internal AWS services and obtain temporary credentials.

The report does not include the internal URL, the response body, or the credential format, so those details cannot be reproduced here.

Why is this dangerous? Because the request comes from inside the company's network. From your home computer, an internal AWS address is unreachable; from HackerOne's server, it is a neighbour. The server is trusted by those internal systems, so it can ask them questions that an outsider cannot.

Root cause

The mistake is a missing output sanitisation on an error message. The template path lookup can fail, and the failure message was built by interpolating the user-supplied element[:template] value into HTML. That HTML was then passed to a library whose job is to render HTML into a PDF, and such libraries fetch subresources such as iframes. The result is that user input crossed from a data context into an active rendering context with network access.

The existing defences did not stop it because the value was not escaped at the point where it entered the HTML, and because the PDF renderer was trusted to process whatever HTML it was given. The company's summary frames it exactly this way: element[:template] was not properly sanitised in the error message, and the returned html_without_layout was fed into the PDF conversion library.

A useful comparison: a comment field on a blog is data, and the site should display it as text. But if the site pastes that comment into the page as if it were part of the page's own code, a commenter can add a tag that makes every visitor's browser do something. Here the "page" was a PDF being generated, and the "visitor" was the server itself.

Impact

The company rated the issue CVSSv3 10 (Critical) with the vector:

Text
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N/CR:H/IR:H/AR:H

That vector is a compact code describing the conditions. In plain terms: the attack can be done over the network, needs no special conditions, no privileges and no user interaction, and the scope changes (the vulnerable component affects other components). Confidentiality and integrity are highly affected; availability is not. The company's justification is the potential impact of exposed credentials.

The researcher listed the potential impacts as:

  1. Ability to read internal files.
  2. Unauthorized access to AWS credentials.
  3. Manipulating AWS resources.
  4. Possibility of data loss.
  5. Account takeover.
  6. Executing arbitrary commands.

These are the researcher's stated possibilities; the company's forensic investigation concluded that there is no evidence the issue was exploited prior to the report. The bounty was 25,000 USD.

Fix

The company changed the error message so that it no longer includes the template value, as shown in the diff above: "Missing template for element: #{element[:template]}" became "Missing template for element". Regression tests were added to prevent future occurrences. The fix is deployed in production, and the researcher says the issue was fixed and available for retest in less than 24 hours.

Why does removing the value fix it? Because the attacker's markup never reaches the HTML that the PDF library processes. The error message still tells developers that a template is missing, but it no longer carries the user's text into a place where it can act.

Variants to test

If you want to look for similar bugs, here are directions the technical write-up suggests. Each one is a way of asking the same question: does user input end up somewhere it is treated as instructions rather than as text?

  1. Error paths that echo input. Submit values that fail a lookup (missing template, unknown report type, invalid filter) and watch whether the raw value appears in any generated document, email or PDF. A positive result is your markup appearing unescaped in the rendered output.
  2. PDF and document generators with subresource loading. Wherever user input reaches an HTML-to-PDF or HTML-to-image pipeline, try an <iframe>, <img> or <link> pointing at an internal address. A positive result is a request arriving at a host you control from the application's egress address, or an internal response reflected into the document.
  3. Cloud metadata endpoints. Point the injected subresource at the metadata service of the hosting provider. A positive result is credential material or instance data appearing in the generated document or in a callback.
  4. Template path parameters. Try path traversal or absolute paths in the template identifier itself, not just markup, and observe whether the error or the rendered output discloses file contents.
  5. Sanitisation applied only on the success path. Compare how a valid template value and an invalid one are handled; the invalid branch is often the one that skips escaping.

Glossary

  • API: a defined way for one piece of software to ask another to do something and get an answer back, like a waiter taking an order to a kitchen.
  • AWS: Amazon Web Services, a cloud provider that rents out computers, storage and other services over the internet.
  • AWS credentials: temporary strings that prove to AWS who a program is and what it may do, similar to a username and password for machines.
  • Bounty: money a company pays a researcher for reporting a security flaw.
  • Cookie: a small piece of text a website stores in your browser so it can recognise you on later requests.
  • Credentials: secrets that prove identity, such as passwords, tokens or keys.
  • CVSS: Common Vulnerability Scoring System, a standard 0 to 10 score for how serious a security flaw is.
  • Diff: a side-by-side view of code changes, where lines starting with - are removed and lines starting with + are added.
  • Egress: network traffic leaving a system, for example requests a server makes to the outside world.
  • Error path: the branch of code that runs when something goes wrong, such as a lookup failing.
  • Escaping: converting characters that have special meaning in HTML into harmless text, so they are displayed rather than interpreted.
  • HTML: the language web pages are written in, made of tags such as <p> and <iframe>.
  • HTML-to-PDF library: a bundle of code that takes HTML and produces a PDF document.
  • <iframe>: an HTML tag that embeds another web page inside the current one, causing the browser or renderer to fetch that address.
  • Interpolation: inserting a value into a string, as in #{element[:template]}.
  • Locals: values passed into a template so it can fill in its blanks.
  • Metadata service: an internal address offered by cloud providers that returns information about the running server, sometimes including credentials.
  • Partial: a reusable piece of a template, like a form letter with blanks.
  • PDF: a document format that looks the same on every device.
  • Regression test: an automated test that checks a fixed bug stays fixed.
  • Sanitisation: cleaning input so it is treated as data rather than as instructions.
  • Server: a computer that stores a website and answers requests from browsers and other programs.
  • SSRF (server-side request forgery): tricking a server into making a request of your choosing, often to internal systems you cannot reach yourself.
  • Template: a reusable page layout with blanks to fill in.
  • Token: a piece of text that proves identity or permission, used by programs and websites.
  • Vector (CVSS): a compact code describing the conditions and impact of a vulnerability.

More by megaman_

View all

8 more disclosed reports, best first.

More from HackerOne

View all

The newest disclosed reports for this program.

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.