www.hackerone.com website CSP "script-src" includes "unsafe-inline"
The website's Content-Security-Policy included 'unsafe-inline' in the script-src directive, which weakens protection against script injection. An attacker could potentially exploit this to carry out cross-site scripting attacks if an injection point exists.
- Fixed in 12 hours
- Disclosed after 20 days
Summary by the researcher
The www.hackerone.com website was missing a strict "script-src" value. Albeit just a low profile risk, a sound "script-src" value should be considered best practice.
The report
Summary:
The HTTP header of the hackerone.com website includes an unsafe CSP parameter for "script-src".
Description: The hackerone.com website (https://www.hackerone.com) has a Content-Security-Policy configured, as pointed out on the Bug Bounty page of their program:
We utilize a strict Content Security Policy and a safe-by-default templating language to effectively neutralize Cross-Site Scripting (XSS).
However, the "script-src" parameter is set to "unsafe-inline", which allows injection of user passed values, which in result can be misused for Cross-Site Scripting attacks. As a best practice, this value should not be included as a "script-src" parameter, if possible.
Steps To Reproduce
The header can be read using a simple curl query:
$ curl -I https://www.hackerone.com
HTTP/1.1 200 OK
Date: Wed, 03 May 2017 13:43:29 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: __cfduid=d80b77473f21b44450916a32b6f4e56d11493819008; expires=Thu, 03-May-18 13:43:28 GMT; path=/; Domain=www.hackerone.com; HttpOnly
Cache-Control: max-age=300, public
X-Drupal-Dynamic-Cache: HIT
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Mon, 01 May 2017 21:41:56 GMT
ETag: W/"1493674916"
Vary: Cookie,Accept-Encoding
X-Generator: Drupal 8 (https://www.drupal.org)
Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; child-src www.youtube-nocookie.com app-sj17.marketo.com; connect-src 'self' hackerone.com *.mktoresp.com checkout.stripe.com; font-src 'self'; form-action 'self' syndication.twitter.com platform.twitter.com; frame-ancestors 'self'; frame-src www.youtube.com www.youtube-nocookie.com app-sj17.marketo.com boards.greenhouse.io platform.twitter.com syndication.twitter.com checkout.stripe.com; img-src 'self' data: www.google-analytics.com syndication.twitter.com platform.twitter.com *.twimg.com q.stripe.com; media-src 'self'; script-src 'self' 'unsafe-inline' www.google-analytics.com app-sj17.marketo.com munchkin.marketo.net boards.greenhouse.io platform.twitter.com cdn.syndication.twimg.com checkout.stripe.com; style-src 'self' 'unsafe-inline' app-sj17.marketo.com boards.greenhouse.io boards-use1-cdn.greenhouse.io platform.twitter.com checkout.stripe.com; report-uri https://errors.hackerone.net/api/30/csp-report/?sentry_key=61c1e2f50d21487c97a071737701f598
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Xss-Protection: 1; mode=block
X-Drupal-Cache: HIT
X-Request-ID: v-50f3aef2-3006-11e7-9597-02c51b741cbd
X-AH-Environment: prod
X-Varnish: 549998133 549985183
Age: 75
Via: 1.1 varnish
X-Cache: HIT
X-Cache-Hits: 43
Server: cloudflare-nginx
CF-RAY: 3593a644588915ad-FRA
As can be seen, "unsafe-inline" is included in in the list of "script-src" parameters. This does not result in an immediate threat, but should be excluded, if possible, as a best practice. For further information, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
Context
HackerOne runs a public bug bounty programme, and its programme page states the security posture of the main marketing site, https://www.hackerone.com. Among other claims, the programme page says:
We utilise a strict Content Security Policy and a safe-by-default templating language to effectively neutralize Cross-Site Scripting (XSS).
A Content Security Policy (CSP) is delivered as an HTTP response header and tells the browser which sources of script, style, image, frame and other content are permitted on the page. The script-src directive is the one that governs JavaScript: which origins may be loaded, and whether inline <script> blocks and inline event handlers are allowed. The 'unsafe-inline' keyword in script-src re-enables inline script, which is exactly what a strict CSP is meant to prevent. The response headers name Drupal 8, cloudflare-nginx and Varnish.
The researcher, rootkid, looked at the CSP header on the marketing site and compared it with the strict-CSP claim on the programme page.
Setup
No account, role or special tooling was needed. The check is a single unauthenticated HTTP request to the public site, made with curl. The only precondition is that the site returns its CSP header on a normal page load, which it does.
Finding it
The researcher noticed that the Content-Security-Policy header on https://www.hackerone.com includes 'unsafe-inline' in the script-src directive, while the programme page states a strict CSP is used. The researcher describes the issue as low profile: it does not create an immediate threat on its own, but a sound script-src value should not contain 'unsafe-inline' where it can be avoided, as a matter of best practice.
Exploitation
Step 1: Read the response headers
The header can be read with a simple curl query:
$ curl -I https://www.hackerone.com
HTTP/1.1 200 OK
Date: Wed, 03 May 2017 13:43:29 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: __cfduid=[redacted]; expires=Thu, 03-May-18 13:43:28 GMT; path=/; Domain=www.hackerone.com; HttpOnly
Cache-Control: max-age=300, public
X-Drupal-Dynamic-Cache: HIT
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Mon, 01 May 2017 21:41:56 GMT
ETag: W/"1493674916"
Vary: Cookie,Accept-Encoding
X-Generator: Drupal 8 (https://www.drupal.org)
Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; child-src www.youtube-nocookie.com app-sj17.marketo.com; connect-src 'self' hackerone.com *.mktoresp.com checkout.stripe.com; font-src 'self'; form-action 'self' syndication.twitter.com platform.twitter.com; frame-ancestors 'self'; frame-src www.youtube.com www.youtube-nocookie.com app-sj17.marketo.com boards.greenhouse.io platform.twitter.com syndication.twitter.com checkout.stripe.com; img-src 'self' data: www.google-analytics.com syndication.twitter.com platform.twitter.com *.twimg.com q.stripe.com; media-src 'self'; script-src 'self' 'unsafe-inline' www.google-analytics.com app-sj17.marketo.com munchkin.marketo.net boards.greenhouse.io platform.twitter.com cdn.syndication.twimg.com checkout.stripe.com; style-src 'self' 'unsafe-inline' app-sj17.marketo.com boards.greenhouse.io boards-use1-cdn.greenhouse.io platform.twitter.com checkout.stripe.com; report-uri https://errors.hackerone.net/api/30/csp-report/?sentry_key=[redacted]
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Xss-Protection: 1; mode=block
X-Drupal-Cache: HIT
X-Request-ID: v-50f3aef2-3006-11e7-9597-02c51b741cbd
X-AH-Environment: prod
X-Varnish: 549998133 549985183
Age: 75
Via: 1.1 varnish
X-Cache: HIT
X-Cache-Hits: 43
Server: cloudflare-nginx
CF-RAY: 3593a644588915ad-FRA
The -I flag asks curl for the response headers only. The important line is the Content-Security-Policy header. Its script-src directive reads:
script-src 'self' 'unsafe-inline' www.google-analytics.com app-sj17.marketo.com munchkin.marketo.net boards.greenhouse.io platform.twitter.com cdn.syndication.twimg.com checkout.stripe.com
So the site allows scripts from its own origin and from a list of third-party hosts, and, in addition, allows inline script through 'unsafe-inline'. The rest of the policy is comparatively tight: default-src 'none', base-uri 'self', block-all-mixed-content, frame-ancestors 'self', and a report-uri pointing at a Sentry CSP report endpoint. The style-src directive also carries 'unsafe-inline', but the report focuses on script-src.
Step 2: Confirm the contradiction
With the header in hand, the researcher compared it with the programme page's claim of a strict CSP. The presence of 'unsafe-inline' in script-src allows injection of user-passed values, which can be misused for Cross-Site Scripting attacks. The researcher notes that this does not result in an immediate threat, but that the value should be excluded where possible, as a best practice, and links to the MDN documentation for the script-src directive for further reading.
Root cause
The policy is configured with 'unsafe-inline' in script-src. In CSP, 'unsafe-inline' is the keyword that permits inline <script> elements and inline event handlers, which the rest of a strict policy would otherwise block. The report does not explain why the keyword is present.
Impact
The report is explicit that there is no immediate threat from the header alone. The report says the keyword allows injection of user-passed values, which can be misused for Cross-Site Scripting attacks. The researcher frames the finding as a best-practice issue, not a demonstrated XSS. No proof of concept showing script execution is included.
Fix
The report recommends excluding 'unsafe-inline' from script-src where possible. It does not describe a change that was made, and no fix is recorded in the text. In practice, removing the keyword requires moving inline scripts to external files or authorising them with a nonce or hash, but that is general CSP guidance rather than something the report states.
Variants to test
- Check
script-srcon other hosts in the same organisation, including subdomains and staging environments. A positive result is'unsafe-inline'present inscript-srcon a host that is in scope. - Check
style-srcfor'unsafe-inline'. A positive result is the keyword present there too, as it is on this site, which widens the surface for CSS-based attacks. - Compare the published security claims on a programme page with the actual headers. A positive result is any mismatch between a stated strict CSP and a policy that permits inline script.
- Look for reflected or stored input on pages covered by the policy. A positive result is a parameter whose value appears unescaped in the HTML, which would turn the
'unsafe-inline'weakness into executable script. - Check whether
object-srcis restricted, sincedefault-src 'none'covers it here. A positive result elsewhere is a policy that leaves plugin content unrestricted.
What happened, in plain words
HackerOne runs a public bug bounty programme, which means it invites outside researchers to look for security problems on its systems and report them. The programme page for that effort makes a promise about the main marketing website, https://www.hackerone.com. Among other statements, the page says:
We utilise a strict Content Security Policy and a safe-by-default templating language to effectively neutralize Cross-Site Scripting (XSS).
To understand the finding, you need three ideas.
A Content Security Policy (CSP) is a set of instructions that a website sends to your browser along with the page. Think of it like a guest list at a private party: the browser is the bouncer, and the CSP tells the bouncer which outside sources are allowed to bring things in, such as scripts, images, styles and embedded frames. The policy travels as an HTTP response header, which is a small block of text the server sends before the page content.
One line inside that policy is the script-src directive. This is the part that governs JavaScript, the programming language that makes web pages interactive. It says which web addresses scripts may be loaded from, and whether scripts written directly inside the page's HTML are allowed. A directive here just means one named instruction within the larger policy.
The keyword 'unsafe-inline' inside script-src is the permission slip for inline script: code written straight into the page rather than loaded from a separate file. A strict CSP is specifically designed to block that kind of code, because if an attacker can trick the page into printing something a user typed, that text could become executable script. This is the heart of Cross-Site Scripting (XSS): an attacker gets their own code to run inside someone else's trusted website, usually by slipping it in through a form field, a URL parameter or stored content.
The researcher, rootkid, read the CSP header on the marketing site and compared it with the strict-CSP promise on the programme page. The header contained 'unsafe-inline' in script-src, which contradicts the claim. The response headers name Drupal 8, a content management system, plus Cloudflare and Varnish.
Setting up
No account, login or special tool was needed. The check is a single request to the public website, made with a command-line tool called curl. curl is a program that fetches a web address and prints what the server sends back, a bit like a browser doing one request and showing you the raw reply instead of drawing a page.
The only precondition is that the site returns its CSP header on a normal page load, which it does. If the header were missing entirely, there would be nothing to inspect.
Finding it
The researcher noticed that the Content-Security-Policy header on https://www.hackerone.com includes 'unsafe-inline' in the script-src directive, while the programme page states a strict CSP is used. The researcher describes the issue as low profile: it does not create an immediate threat on its own, but a sound script-src value should not contain 'unsafe-inline' where it can be avoided, as a matter of best practice.
Exploitation
Step 1: Read the response headers
The header can be read with a simple curl query:
$ curl -I https://www.hackerone.com
HTTP/1.1 200 OK
Date: Wed, 03 May 2017 13:43:29 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Set-Cookie: __cfduid=[redacted]; expires=Thu, 03-May-18 13:43:28 GMT; path=/; Domain=www.hackerone.com; HttpOnly
Cache-Control: max-age=300, public
X-Drupal-Dynamic-Cache: HIT
X-UA-Compatible: IE=edge
Content-language: en
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Last-Modified: Mon, 01 May 2017 21:41:56 GMT
ETag: W/"1493674916"
Vary: Cookie,Accept-Encoding
X-Generator: Drupal 8 (https://www.drupal.org)
Content-Security-Policy: default-src 'none'; base-uri 'self'; block-all-mixed-content; child-src www.youtube-nocookie.com app-sj17.marketo.com; connect-src 'self' hackerone.com *.mktoresp.com checkout.stripe.com; font-src 'self'; form-action 'self' syndication.twitter.com platform.twitter.com; frame-ancestors 'self'; frame-src www.youtube.com www.youtube-nocookie.com app-sj17.marketo.com boards.greenhouse.io platform.twitter.com syndication.twitter.com checkout.stripe.com; img-src 'self' data: www.google-analytics.com syndication.twitter.com platform.twitter.com *.twimg.com q.stripe.com; media-src 'self'; script-src 'self' 'unsafe-inline' www.google-analytics.com app-sj17.marketo.com munchkin.marketo.net boards.greenhouse.io platform.twitter.com cdn.syndication.twimg.com checkout.stripe.com; style-src 'self' 'unsafe-inline' app-sj17.marketo.com boards.greenhouse.io boards-use1-cdn.greenhouse.io platform.twitter.com checkout.stripe.com; report-uri https://errors.hackerone.net/api/30/csp-report/?sentry_key=[redacted]
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Xss-Protection: 1; mode=block
X-Drupal-Cache: HIT
X-Request-ID: v-50f3aef2-3006-11e7-9597-02c51b741cbd
X-AH-Environment: prod
X-Varnish: 549998133 549985183
Age: 75
Via: 1.1 varnish
X-Cache: HIT
X-Cache-Hits: 43
Server: cloudflare-nginx
CF-RAY: 3593a644588915ad-FRA
Line by line, in plain words:
$ curl -I https://www.hackerone.comis the command you type. The-Iflag askscurlfor the response headers only, not the page body. The$is just the shell prompt, not part of the command.HTTP/1.1 200 OKis the status line.200means the request succeeded.Date: Wed, 03 May 2017 13:43:29 GMTis when the server answered.Content-Type: text/html; charset=UTF-8says the reply is an HTML page encoded in UTF-8, a common text encoding.Connection: keep-alivemeans the network connection can stay open for further requests.Set-Cookie: __cfduid=[redacted]; ...is a cookie the server asks the browser to store. A cookie is a small piece of data a site leaves in your browser so it can recognise you on later requests. The value here has been redacted because it is a session-like identifier.Cache-Control: max-age=300, publictells browsers and caches they may keep a copy for 300 seconds.X-Drupal-Dynamic-Cache: HITis a Drupal-specific note saying a cached version was served.X-UA-Compatible: IE=edgeis an old instruction for Internet Explorer to use its newest rendering mode.Content-language: ensays the page is in English.X-Content-Type-Options: nosniffstops browsers from guessing a file's type and treating it as something else.X-Frame-Options: DENYstops other sites from embedding this page in a frame.Expires: Sun, 19 Nov 1978 05:00:00 GMTis a very old date, a common trick to tell caches the content is already expired.Last-Modified: Mon, 01 May 2017 21:41:56 GMTis when the page content last changed.ETag: W/"1493674916"is a fingerprint of the content, used by caches to tell versions apart.Vary: Cookie,Accept-Encodingtells caches that the response can differ depending on cookies and on the browser's supported compression.X-Generator: Drupal 8 (https://www.drupal.org)reveals the software that built the page: Drupal 8.Content-Security-Policy: ...is the important line. It is the full guest list for the page. We will break it down below.Strict-Transport-Security: max-age=31536000; includeSubDomains; preloadtells browsers to always use HTTPS for this site and its subdomains for a year.X-Xss-Protection: 1; mode=blockis an old browser instruction to block pages when a reflected XSS pattern is detected.X-Drupal-Cache: HITsays Drupal served a cached page.X-Request-ID: v-50f3aef2-3006-11e7-9597-02c51b741cbdis an identifier for this request, useful for debugging.X-AH-Environment: prodsays the request hit the production environment.X-Varnish: 549998133 549985183shows Varnish, a caching layer, handled the request.Age: 75means the cached copy is 75 seconds old.Via: 1.1 varnishconfirms the request passed through Varnish.X-Cache: HITandX-Cache-Hits: 43say the cache served the page and how many times it has done so.Server: cloudflare-nginxnames the web server software, Cloudflare's nginx.CF-RAY: 3593a644588915ad-FRAis a Cloudflare request identifier.
The important line is the Content-Security-Policy header. Its script-src directive reads:
script-src 'self' 'unsafe-inline' www.google-analytics.com app-sj17.marketo.com munchkin.marketo.net boards.greenhouse.io platform.twitter.com cdn.syndication.twimg.com checkout.stripe.com
So the site allows scripts from its own origin and from a list of third-party hosts, and, in addition, allows inline script through 'unsafe-inline'. 'self' means the same website that served the page. The other names are outside services: Google Analytics for statistics, Marketo for marketing, Greenhouse for job listings, Twitter for embedded tweets and Stripe for payments. The rest of the policy is comparatively tight: default-src 'none' blocks everything not explicitly allowed, base-uri 'self' restricts the base address used to resolve links, block-all-mixed-content stops insecure HTTP content on an HTTPS page, frame-ancestors 'self' limits who may frame the page, and a report-uri points at a Sentry CSP report endpoint, which is a service that collects reports when the browser blocks something. The style-src directive also carries 'unsafe-inline', but the report focuses on script-src.
Step 2: Confirm the contradiction
With the header in hand, the researcher compared it with the programme page's claim of a strict CSP. The presence of 'unsafe-inline' in script-src allows injection of user-passed values, which can be misused for Cross-Site Scripting attacks. Escaping means converting special characters so they are treated as plain text rather than as code. The researcher notes that this does not result in an immediate threat, but that the value should be excluded where possible, as a best practice, and links to the MDN documentation for the script-src directive for further reading.
Root cause
The policy is configured with 'unsafe-inline' in script-src. In CSP, 'unsafe-inline' is the keyword that permits inline <script> elements and inline event handlers, which the rest of a strict policy would otherwise block. An event handler is a small piece of code attached to an HTML element that runs when something happens, such as a click. The report does not explain why the keyword is present.
Impact
The report is explicit that there is no immediate threat from the header alone. The report says the keyword allows injection of user-passed values, which can be misused for Cross-Site Scripting attacks. Reflected means the value bounces straight back in the same response, for example from a URL parameter. Stored means the value is saved on the server and shown to other visitors later. The researcher frames the finding as a best-practice issue, not a demonstrated XSS. No proof of concept showing script execution is included.
Fix
The report recommends excluding 'unsafe-inline' from script-src where possible. It does not describe a change that was made, and no fix is recorded in the text. In practice, removing the keyword requires moving inline scripts to external files or authorising them with a nonce or hash, but that is general CSP guidance rather than something the report states. A nonce is a one-time random value added to a script tag and to the policy so only that script is trusted; a hash is a fingerprint of the script's exact contents.
Variants to test
- Check
script-srcon other hosts in the same organisation, including subdomains and staging environments. A positive result is'unsafe-inline'present inscript-srcon a host that is in scope. - Check
style-srcfor'unsafe-inline'. A positive result is the keyword present there too, as it is on this site, which widens the surface for CSS-based attacks. - Compare the published security claims on a programme page with the actual headers. A positive result is any mismatch between a stated strict CSP and a policy that permits inline script.
- Look for reflected or stored input on pages covered by the policy. A positive result is a parameter whose value appears unescaped in the HTML, which would turn the
'unsafe-inline'weakness into executable script. - Check whether
object-srcis restricted, sincedefault-src 'none'covers it here. A positive result elsewhere is a policy that leaves plugin content unrestricted.
Glossary
- Bug bounty programme: A scheme where an organisation invites outside researchers to find and report security problems, often with a reward.
- Content Security Policy (CSP): A set of instructions sent by a website to the browser listing which sources of scripts, styles, images and other content are allowed.
- HTTP response header: A small block of text a web server sends before the page content, carrying metadata and instructions.
- Directive: One named instruction inside a CSP, such as
script-srcorstyle-src. script-src: The CSP directive that controls which JavaScript sources and inline scripts are allowed.style-src: The CSP directive that controls which stylesheets and inline styles are allowed.'unsafe-inline': A CSP keyword that permits code written directly inside the page, which a strict policy would otherwise block.'self': A CSP keyword meaning the same website that served the page.default-src 'none': A CSP directive that blocks every resource type not explicitly allowed elsewhere in the policy.base-uri 'self': A CSP directive restricting the base address used to resolve relative links.block-all-mixed-content: A CSP directive that stops insecure HTTP content from loading on an HTTPS page.frame-ancestors 'self': A CSP directive limiting which pages may embed this page in a frame.report-uri: A CSP directive giving the address where the browser sends reports when it blocks something.object-src: The CSP directive controlling plugin content such as Flash or Java applets.- Cross-Site Scripting (XSS): A class of attack where an attacker gets their own code to run inside someone else's trusted website.
- Reflected input: A value that bounces straight back in the same response, for example from a URL parameter.
- Stored input: A value saved on the server and shown to other visitors later.
- Escaping: Converting special characters so they are treated as plain text rather than as code.
- Inline script: JavaScript written directly inside the HTML page rather than loaded from a separate file.
- Event handler: A small piece of code attached to an HTML element that runs when something happens, such as a click.
- Nonce: A one-time random value added to a script tag and to the policy so only that script is trusted.
- Hash: A fingerprint of a script's exact contents, used in CSP to trust that specific script.
- Cookie: A small piece of data a site leaves in your browser so it can recognise you on later requests.
- curl: A command-line program that fetches a web address and prints the server's reply.
- Drupal 8: A content management system used to build and serve websites.
- Cloudflare: A service that sits in front of a website to cache and protect it.
- Varnish: A caching layer that stores copies of pages to serve them faster.
- Sentry: A service that collects error and CSP reports.
- MDN: Mozilla's web documentation site, used as a reference for web standards.
- CSS: The language that controls how web pages look.
- HTTPS: The secure, encrypted version of HTTP used by websites.
- Staging environment: A copy of a website used for testing before changes go live.
- Subdomain: A prefix on a domain name, such as
blog.example.comunderexample.com. - Parameter: A named value passed in a URL or form, such as
?name=value. - Proof of concept: A demonstration showing that a vulnerability can actually be exploited.
- Production environment: The live system that real users see.