What is CSP?

What is CSP?
R
Regin AsylviaProfessorAsked on January 7, 2020 in Programming.•35.8k views
|

1 Answer

Content Security PolicyĀ (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement to distribution of malware. CSP is designed to be fully backward compatible (except CSP version 2 where there are some explicitly-mentioned inconsistencies in backward compatibility; more detailsĀ hereĀ section 1.1). Browsers that don't support it still work with servers that implement it, and vice-versa: browsers that don't support CSP simply ignore it, functioning as usual, defaulting to the standard same-origin policy for web content. If the site doesn't offer the CSP header, browsers likewise use the standardĀ same-origin policy. To enable CSP, you need to configure your web server to return theĀ Content-Security-PolicyĀ HTTP header (sometimes you will see mentions of theĀ X-Content-Security-PolicyĀ header, but that's an older version and you don't need to specify it anymore). Alternatively, theĀ <meta>Ā element can be used to configure a policy, for example:Ā <meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src https://*; child-src 'none';">
T
travelingbdSupporterAnswered on June 21, 2020,
|

Your Answer

Write your response