Skip to content
XSS Write-up Intermediate

Exploiting insecure exception logging

The application logged HTTP requests that caused exceptions without proper HTML encoding, so an attacker could inject a blind XSS payload into headers like User-Agent, which would execute when an administrator viewed the exception log. The same technique could also be used to exploit Log4j vulnerabilities for remote code execution.

Bogdan Calin Follow

Published on invicti.com

When your web application receives a request that causes an exception, you usually want to log that request for further analysis. But what if the request contains an attack payload?

Bogdan Calin, on invicti.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 logged user-controlled request data (such as headers) without HTML encoding before displaying it in an admin dashboard.

Impact

An attacker could execute arbitrary JavaScript in an administrator's browser, potentially stealing session tokens or performing actions on their behalf; the same technique could also lead to remote code execution if a Log4j vulnerability is present.

What the attacker needed

Ability to send requests that cause exceptions; admin views the exception log

The fix

All request data logged with exceptions should be sanitised and encoded to the same standard as other user inputs.

How it was found

  1. Send requests designed to cause exceptions, injecting payloads into headers such as User-Agent and Referer.
  2. Wait for the exception to be logged and for an administrator to view the log.
  3. The payload executes in the administrator's browser, allowing extraction of DOM content or other actions.

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 has an error, it often saves details about the request that caused it. If those details are shown to an administrator without being made safe, an attacker can hide malicious code in the request. When the admin views the log, the code runs in their browser, potentially letting the attacker take over their session.

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.