XSS (Static Nonce in CSP)
Last updated
Last updated
Scenario: The application is using a Content-Security-Policy (CSP) that blocks inline scripts from executing. There is a possibility of a Stored XSS as the application is not performing input validation or output encoding.
The following is the portion of CSP header:
From the above policy, we can note the following:
1. 'self': Can only load JavaScript from the same origin of app and scripts from external URL's will be blocked.
2. No 'unsafe-inline': we cannot execute inline scripts such as:
OR
Note: alert('XSS'); is also an example of a function call such as doSomething(); Both would be blocked.
3. 'nonce ...': Scripts with the specified nonce value can be executed.
Observation: After browsing the application for a while and observing the value of CSP header, we can conclude that the application does not rotate the nonce value with each HTTP request. This would increase the execution rate of our payload.
XSS Payload: The following payload successfully executed:
References: