Level6
Link: https://xss-game.appspot.com/level6Solution
Host a simple Javascript file which can be fetch through a URL (https). The Javascript file need only to contain an alert() method.alert("XSS")
Place the URL to the https file right after the # tag of the URL. Use HTTPS instead of https in the URL to the scropt to bypass the check.Result
Analysis
The vulnerability lies withing how the code handles the value after the # tag.In the line 45, the value right after the # tag is taken as the gadget name. And then in line 48, this value is directly passed into the includeGadget() method.
And in the includeGadget() method a <script> tag is created [line 18] and the url (gadgetName) parameter value is directly used as the src attribute of the <script> tag [line 28].
This means, we can completly control the src attribute of the <script> tag being created. That is, with this vulnerability we can inject our own Javascript file into the code.
The only hurdle is the security check done in the line 21. But this can be easily by passed due to it's case sensitivity. It blocks any value with https or http. But this filter can be bypassed by using Http, HTtpS and so on since URLs are actualy case insensitive.
I found another solution. You don't have to host your js file anywhere. Instead just use the base64 encoded data of the alert script. For instance alert('hi'); will be turned into "data:undefined;base64,YWxlcnQoJ2hpJyk7".
ReplyDeleteFull working URL: https://xss-game.appspot.com/level6/frame#data:undefined;base64,YWxlcnQoJ2hpJyk7
Love this series, thanks for the previous solutions 👏
great
Delete