Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: chrome/common/extensions/docs/templates/articles/contentSecurityPolicy.html

Issue 12223068: Fix some typos, broken links and other issues in extension docs (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <h1>Content Security Policy (CSP)</h1> 1 <h1>Content Security Policy (CSP)</h1>
2 2
3 3
4 <p> 4 <p>
5 In order to mitigate a large class of potental cross-site scripting issues, 5 In order to mitigate a large class of potential cross-site scripting issues,
6 Chrome's extension system has incorporated the general concept of 6 Chrome's extension system has incorporated the general concept of
7 <a href="http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specif ication.dev.html"> 7 <a href="http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specif ication.dev.html">
8 <strong>Content Security Policy (CSP)</strong> 8 <strong>Content Security Policy (CSP)</strong>
9 </a>. This introduces some fairly strict policies that will make extensions 9 </a>. This introduces some fairly strict policies that will make extensions
10 more secure by default, and provides you with the ability to create and 10 more secure by default, and provides you with the ability to create and
11 enforce rules governing the types of content that can be loaded and executed 11 enforce rules governing the types of content that can be loaded and executed
12 by your extensions and applications. 12 by your extensions and applications.
13 </p> 13 </p>
14 14
15 <p> 15 <p>
16 In general, CSP works as a black/whitelisting mechanism for resources loaded 16 In general, CSP works as a black/whitelisting mechanism for resources loaded
17 or executed by your extensions. Defining a reasonable policy for your 17 or executed by your extensions. Defining a reasonable policy for your
18 extension enables you to carefully consider the resources that your extension 18 extension enables you to carefully consider the resources that your extension
19 requires, and to ask the browser to ensure that those are the only resources 19 requires, and to ask the browser to ensure that those are the only resources
20 your extension has access to. These policies provide security over and above 20 your extension has access to. These policies provide security over and above
21 the <a href="manifest.html#permissions">host permissions</a> your extension 21 the <a href="declare_permissions.html">host permissions</a> your extension
22 requests; they're an additional layer of protection, not a replacement. 22 requests; they're an additional layer of protection, not a replacement.
23 </p> 23 </p>
24 24
25 <p> 25 <p>
26 On the web, such a policy is defined via an HTTP header or <code>meta</code> 26 On the web, such a policy is defined via an HTTP header or <code>meta</code>
27 element. Inside Chrome's extension system, neither is an appropriate 27 element. Inside Chrome's extension system, neither is an appropriate
28 mechanism. Instead, an extension's policy is defined via the extension's 28 mechanism. Instead, an extension's policy is defined via the extension's
29 <a href="manifest.html"><code>manifest.json</code></a> file as follows: 29 <a href="manifest.html"><code>manifest.json</code></a> file as follows:
30 </p> 30 </p>
31 31
(...skipping 11 matching lines...) Expand all
43 "An Introduction to Content Security Policy" 43 "An Introduction to Content Security Policy"
44 </a> article on HTML5Rocks. 44 </a> article on HTML5Rocks.
45 </p> 45 </p>
46 46
47 <h2 id="restrictions">Default Policy Restrictions</h2> 47 <h2 id="restrictions">Default Policy Restrictions</h2>
48 48
49 <p> 49 <p>
50 Packages that do not define a <a href="manifestVersion.html"> 50 Packages that do not define a <a href="manifestVersion.html">
51 <code>manifest_version</code> 51 <code>manifest_version</code>
52 </a> have no default content security policy. Those that select 52 </a> have no default content security policy. Those that select
53 <code>manifest_version</code></a> 2, have a default content security policy 53 <code>manifest_version</code> 2, have a default content security policy
54 of: 54 of:
55 </p> 55 </p>
56 56
57 <pre>script-src 'self'; object-src 'self'</pre> 57 <pre>script-src 'self'; object-src 'self'</pre>
58 58
59 <p> 59 <p>
60 This policy adds security by limiting extensions and applications in three 60 This policy adds security by limiting extensions and applications in three
61 ways: 61 ways:
62 </p> 62 </p>
63 63
64 <h3 id="JSEval">Eval and related functions are disabled</h3> 64 <h3 id="JSEval">Eval and related functions are disabled</h3>
65 65
66 <p>Code like the following does not work:</p> 66 <p>Code like the following does not work:</p>
67 67
68 <pre> 68 <pre>
69 alert(eval("foo.bar.baz")); 69 alert(eval("foo.bar.baz"));
70 window.setTimeout("alert('hi')", 10); 70 window.setTimeout("alert('hi')", 10);
71 window.setInteral("alert('hi')", 10); 71 window.setInterval("alert('hi')", 10);
72 new Function("return foo.bar.baz"); 72 new Function("return foo.bar.baz");
73 </pre> 73 </pre>
74 74
75 <p>Evaluating strings of JavaScript like this is a common XSS attack vector. 75 <p>Evaluating strings of JavaScript like this is a common XSS attack vector.
76 Instead, you should write code like: 76 Instead, you should write code like:
77 77
78 <pre> 78 <pre>
79 alert(foo && foo.bar && foo.bar.baz); 79 alert(foo && foo.bar && foo.bar.baz);
80 window.setTimeout(function() { alert('hi'); }, 10); 80 window.setTimeout(function() { alert('hi'); }, 10);
81 window.setInterval(function() { alert('hi'); }, 10); 81 window.setInterval(function() { alert('hi'); }, 10);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 <p> 332 <p>
333 You may, of course, tighten this policy to whatever extent your extension 333 You may, of course, tighten this policy to whatever extent your extension
334 allows in order to increase security at the expense of convenience. To specify 334 allows in order to increase security at the expense of convenience. To specify
335 that your extension can only load resources of <em>any</em> type (images, etc) 335 that your extension can only load resources of <em>any</em> type (images, etc)
336 from its own package, for example, a policy of <code>default-src 'self'</code> 336 from its own package, for example, a policy of <code>default-src 'self'</code>
337 would be appropriate. The <a href="samples.html#mappy">Mappy</a> sample 337 would be appropriate. The <a href="samples.html#mappy">Mappy</a> sample
338 extension is a good example of an extension that's been locked down above and 338 extension is a good example of an extension that's been locked down above and
339 beyond the defaults. 339 beyond the defaults.
340 </p> 340 </p>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698