Skip to content
XSS Write-up Intermediate

From 400 Bad Request to XSS Pop Up

A role-creation feature rejected angle brackets in the role name, but sending the same parameter twice let the attacker slip a script-bearing image tag past the check. The stored value later ran as script when an administrator edited a user assigned that role.

medium.com

Published on medium.com

Overview : I was testing an application where most of the functionalities were vulnerable to stored XSS, but most of the previous reports had been patched. I came across a functionality to create admin roles, where I injected special characters like <> into the “rolename” parameter of a POST request to analyze the…

Muhammad Shehroz, 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 input validation and the storage layer disagreed about which duplicate parameter to use, so the checked value and the saved value differed.

Impact

An attacker with access to role creation could store script that runs in an administrator's session when they edit an affected user, potentially exposing session data.

What the attacker needed

Ability to create roles; ability to create users; admin views the user edit page

The fix

The validation should reject or normalise duplicate parameters and check the exact value that will be stored and rendered, with output encoding on display.

How it was found

  1. Send a role-creation request with a role name containing angle brackets and observe the 400 rejection.
  2. Intercept the request and add a second role_name parameter before the original, putting the payload in the new one and keeping the original as test.
  3. Submit the request and confirm the role is created with the injected name.
  4. Create a user assigned to that role.
  5. Click the edit button for that user 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 site tried to block dangerous characters in a role name, but it only checked one copy of the field. When the same field is sent twice, the checker looked at one copy and the database saved the other. The bad text was stored and later ran as code in an admin's browser, which is called stored cross-site scripting.

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.