This type of ctfs is just creating a xss url and send to bot and get their cookies(flag) , so we focus on Xss.
But ….:::danger
They sanitize it with DomPurify at newest version !
:::
Pay attention in this code :
It doesnt specify an charset which lead to vulnerabilities.
Which leads to the wrong encoding heres of sushi emoji.
I cannot explain better the blog so read it :vvv .This is a valid DOM and dompurify wont sanitize this and then chrome parse it as ISO_2022_JP
BOOOOOOOOOOOOOOOOOOOOOOM
We get xss :)
It will scan 16KB of document and if it doesn’t find any encodings, it will fast scan (256kb) which we dont talk about .
Slow can will check only the interesting byte < 0x80 and 0x1b is in that case.
Here is the scan_table it use to detect if that byte it interesting or not.
(!=0 -> interesting)
So if it meets a interesting byte. First it will check if that bytes is inside a or or comment. If inside a title tag , it will be decreased the score it can boost, then skip to the end of tag just in case there is 12 bytes in title already.
Pay attention that in our case my input actually push into the title tag too.
However, there is something funny here when reading more the logic check tag
It loops back 192 bytes to find the “<” and “>” . Yeah like i say “192” bytes. So if you pad a bunch of “a” before your “%1b” , it won’t be considered inside a title tag and they wont be skipped to tag end + keep full score weightshift !!!
It seems the reason why exploit 2 works . Now let’s dive deeper
In short, one scan just check 8 pairs of interesting bytes then pruning. If something get pruned , it is done and no get checked any more!!! And we dont want this
If the number of pairs is not divided by 8 , no boostPrune will happend
That emoji in bytes is 0xF0 0xF8 0x8a 0xa3 (take 4 bytes)
And if we look at the logic to boost Logic to whackBOOST a little and WHACK SO MUCH ! :vv
First i think it not matter because 0xF0 is bigger than 0x1F right ?
But when i try to debug, it happens, the 0xF0 is < 0x1F and it whack our score so much!!
*I still dont make sense maybe because of signed number :v
SO the emoji whacking us too much !!!
===»> If we put data after sushi , there is no way to continue checking ISO due to pruned