Google has released new tools and documentation designed to help developers mitigate cross-site scripting (XSS) attacks using the Content Security Policy (CSP) standard.
XSS vulnerabilities continue to affect numerous web applications, even ones developed by major companies. In the past two years, Google awarded researchers more than $1.2 million for these types of flaws.
One potentially efficient solution for mitigating XSS attacks is CSP, a mechanism that allows developers to restrict which scripts can be executed. If policies are configured properly, attackers are not able to load malicious scripts and other resources, even if they manage to inject HTML code into a webpage.
However, CSP policies fail to provide proper XSS protection if they are not configured properly. A study conducted recently by Google researchers on more than 1 billion domains showed that CSP policies can be bypassed in a vast majority of cases.
Google wants to help developers and security experts determine if a CSP is efficient against XSS attacks by releasing a tool called CSP Evaluator. The online tool, also available as a Chrome extension, helps identify subtle CSP misconfigurations that could be exploited by attackers.
While such a tool can be very helpful, Google pointed out that the large number of popular domains with resources that allow CSP to be bypassed makes it difficult to create a whitelist of safe scripts for complex applications. A better approach involves using a nonce-based CSP policy, where a nonce (i.e. an unpredictable token that can only be used once) is assigned to each trusted script.
Google has used this approach for several of its applications, including Cloud Console, History, Photos, Maps Timeline, Careers Search and Cultural Institute. In order to help developers determine if an application is compatible with a nonce-based CSP, Google released a Chrome extension called CSP Mitigator. The search giant has also published documentation describing best strategies for implementing CSP.
Google has invited security experts to submit proposals on how to make popular open-source frameworks compatible with a nonce-based CSP. The initiative has been added to the company’s bug bounty program and submissions can qualify for a reward.