Skip to content
XSS Write-up Advanced

Failed XSS? CRLF to the Rescue

A search endpoint reflected the query parameter raw into a custom response header, and a Unicode character containing a newline byte allowed the attacker to inject a second HTTP response with a script. The attacker could execute JavaScript in the victim's browser.

medium.com

Published on medium.com

Hey Guys! This is a small write-up about one of my recent findings.

Anon Tuttu Venus, 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.

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 server reflected user input into a response header without encoding newline characters, and its HTTP parser accepted a Unicode character that decodes to a newline as a header separator.

Impact

An attacker could execute arbitrary JavaScript in a victim's browser, though the report notes a strict parser would have rejected the request and a WAF blocked the standard CRLF sequence.

What the attacker needed

Victim clicks a crafted link; server reflects query into a header; server accepts GBK newline character

The fix

The server should properly encode or reject control characters in reflected headers and use a strict HTTP parser.

How it was found

  1. Send a search query containing a Unicode character that encodes a newline byte.
  2. The server reflects it raw into the X-Search-Query header, splitting the response.
  3. Inject a second HTTP response with Content-Type text/html and a script body.
  4. Load the crafted URL in a browser and observe the script executing.

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.

The website put the search term into a response header without cleaning it. A special character that contains a newline let the attacker start a new fake response with a script, which the browser ran.

What is XSS?

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

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.