Discovery of Xss / Html Injection by analyzing target source code
The application reflected the client IP address, taken from the X-Forwarded-For header, into a meta tag in the page source without sanitisation. An attacker could inject HTML or JavaScript through that header, leading to HTML injection and cross-site scripting.
medium.com
Published on medium.com
Have you ever found a vulnerability just by looking at the target source code? If not, let me tell you about my experience.
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application trusted the X-Forwarded-For header and inserted its value into the page without sanitisation, while only validating the User-Agent.
Impact
An attacker could execute arbitrary JavaScript in a victim's browser, potentially leading to actions such as data theft or session hijacking, though the report does not demonstrate these further.
What the attacker needed
Ability to set X-Forwarded-For header; victim visits a crafted request
How it was found
- Inspect the page source and notice the IP address is reflected in a meta tag.
- Intercept a request and add an X-Forwarded-For header to change the reflected IP value.
- Replace the header value with an HTML payload and observe it is rendered in the page.
- Replace the header value with an XSS payload and observe script execution.
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 write-up has not been written yet. The Original tab links to the source.
When a website shows information that comes from the user, such as an IP address, it must clean it first. Here the site put the IP address straight into the page without cleaning, so an attacker could make the page show their own code. That code could run in a victim's browser and do things like steal data.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.