Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Array Injection: Bypass JSON XSS Filter [Learn How]

Hey HF members, I am back with another short tutorial for you guys, an offensive hat subject, Bypass Json XSS Filter using Array Injection. ✌

Edit: Unable to post any of the codes in the forum thread, which really sucks, the new firewall rule is making things real complicated, doesn't even allow to post normal codes like bash (saw on my other thread when a user posted a bash script), I really wish any of the forum devs would fix this issue. It's over protective! 🙃😒 I have written the examples (codes) over pastebin and added in the pictures of them, hope it doesn't annoys you to understand the 'how to' and helps you to learn, so, let us start.

Bypass JSON XSS Filter with Array Injection ✌

First let us take a Target Scenario : A web-service receives JSON input from the user:

Code
HF doesn't allow me to post simple POST examples, so here is the example :

https://pastebin.com/raw/z6aSi4vx

[Image: 31c6c32b17e3ea15b8f0290733c8045f.png]

And now let's take that the developer only filters if `msg` contains `<` or `>`.
Exploit: Use an array to bypass the usual filter that only checks `typeof msg === "string"`.

PoC Payload :

Code
https://pastebin.com/raw/jinL6qRG

[Image: cb19bf952c68654776b668a9d6223dde.png]

The filter fails because the value of the key 'msg' is an open string so < & > is not found as an array.

Code
["text1", "text2"] is not equal to "<"

It is because if the server does not check the content type of each element in the array, then JS will parse and render the HTML as XSS.

As a Result; the web displays `msg` without sanitizing each element of the array.

For example :

Code
https://pastebin.com/raw/Q36PinnF

[Image: 9867678c196bec9a536a1e4b6d273a34.png]

Fix Recommendation :

Code
Javascript: https://pastebin.com/raw/6npUSyYe

[Image: 1059956d75b8c8814cdc16bc4b61ebc7.png]

Reminder : Try in your localhost machine.

Have a good day and don't forget to QL this post.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by StanleyNov 16, 2025 01:55 PM 0 63 Nov 16, 2025 01:55 PM
Last Post: Stanley
by MrBrJun 27, 2018 09:17 AM 2 210 Jun 27, 2018 09:17 AM
Last Post: MrBr
by 888risingJun 14, 2018 01:45 PM 4 175 Jun 14, 2018 01:45 PM
Last Post: 888rising