Skip to content
XSS Write-up Beginner

XSS through base64 encoded JSON

A publicly reachable PHP endpoint accepted a base64-encoded JSON value in a URL parameter and rendered one of its fields into the page without sanitisation, so HTML and script content in that field executed in the browser. An attacker could craft a link that runs script in a victim's session on the affected host.

Aman Pareek Follow

Published on apth3hack3r.medium.com

This is one of my very interesting and unexpected finding while testing an Application Tracking System.

Aman Pareek, on apth3hack3r.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 endpoint decoded the settings parameter and inserted a JSON field into the HTML response without encoding or validating it.

Impact

Script supplied through the settings parameter executed in the page, so a crafted link could run attacker-controlled JavaScript in a victim's browser on that host.

What the attacker needed

Victim opens a crafted link; endpoint reachable without login

How it was found

  1. Browse the in-scope subdomain and note the members area paths after login
  2. Fuzz the host root with a common PHP filename wordlist to find an unusual endpoint
  3. Notice the settings GET parameter appears to hold base64-encoded JSON and decode it to confirm
  4. Put HTML/script content into a JSON value, re-encode the JSON as base64
  5. Request the endpoint with that base64 value in the settings parameter 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.

Some web pages take a chunk of data from the URL, decode it, and print parts of it straight into the page. If that data can contain HTML or script, the browser treats it as part of the site and runs it, which is cross-site scripting (XSS). Here the data was base64-encoded JSON, which looks scrambled but is not a security control, so the script still ran.

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 Aman Pareek

View all

2 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.