Content security policy
Boost your developer team’s knowledge about content security policy related vulnerabilities! Avatao’s library of 650+ exercises covers the most popular programming languages and security topics, using both guided tutorials and more difficult challenges. We make it easy for you to find, assign, and track your developers’ progress on our interactive CSP training modules.

Introduction to CSP
Content Security Policy (or CSP) is a standard which helps detect and mitigate certain types of attacks which result in the execution of malicious content in the trusted web page context. Cross-Site Scripting (XSS), clickjacking, and injection attacks are a few examples, but there are many more.
Even though a strong CSP which is set correctly can’t guarantee overall security for web applications, it adds a second layer of protection and can make it significantly more difficult for an attacker to exploit vulnerabilities.
Why do we need CSP header?
- An important line of defense for web applications is the same-origin policy (or SOP). This security rule is used to restrict how a document or script can interact with resources from another origin, and should theoretically be enough to ensure basic security. However, external resources such as assets, fonts, social media buttons, and javascripts from content delivery networks pose a problem, since a browser will execute all codes from a “trusted” origin by default. As such, any malicious code that is, say, injected into an external script, will also be executed.
- This is where CSP comes in. A properly configured CSP header defines rules from a standardized set of directives which tells the browser which resources can be trusted, and which should be blocked, thus protecting the user from dynamic calls that load content into the current page. With CSP, we’re not only mitigating the risk of many types of attacks, but we’re also defining a precise policy framework.
Security considerations
Without a CSP management solution, not only is creating a successful CSP a tedious and manual process, but you also run the risk of implementing a set of directives which is easily bypassed. Luckily, there are some tools out there which can help you properly analyze your CSP policy, a couple of which you can find here and here.
CSP directives can be extremely helpful, but only if they are configured properly; otherwise, your applications will remain vulnerable. Check out some of our secure coding exercises about CSP vulnerabilities to make sure your developers understand the various attack vectors, as well as how to fix them, in multiple top programming languages!

Get started with secure coding training today
