Skip to content
XSS Write-up Beginner

Html Injection Via User Agent Leads To Website Distortion Revealing Backend Code

The User-Agent header value was reflected into the page without proper encoding, allowing HTML injection. An attacker could distort the website and reveal backend code.

Anurag__Verma Follow

Published on infosecwriteups.com

This is my 3rd writeup about an HTML INJECTION occurring at the User-Agent header which leads to website page distortion and revealing backend code.

Anurag__Verma, on infosecwriteups.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.

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 inserted the User-Agent header into the HTML response without encoding it.

Impact

An attacker could distort the website and reveal backend code; XSS was blocked, so the impact was limited to HTML injection.

What the attacker needed

Ability to set a custom User-Agent header

How it was found

  1. Capture a request to the main target page.
  2. Notice that the User-Agent value is reflected in the response.
  3. Craft a payload with HTML tags in the User-Agent header.
  4. Send the request and observe the page distortion and backend code exposure.

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 back what you send it, like your browser's User-Agent string, it must treat that text as plain text, not as code. Here it didn't, so special HTML tags in the User-Agent were treated as part of the page, changing how the page looked and exposing some server-side code.

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 Anurag__Verma

View all

9 more disclosed reports, best first.

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.