-
Notifications
You must be signed in to change notification settings - Fork 22.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Observatory docs to MDN #33793
Add Observatory docs to MDN #33793
Changes from 5 commits
4703db1
c04092c
5254100
c39da2b
c7a383a
3164d32
06d0b98
cc8a1bb
d7d47c7
64dd386
0dc7334
883d4a5
68659ec
8c03637
189313e
460025c
ec81406
74ab66d
dbeb415
0d277b9
d01abc7
63410ca
612279a
1d6810d
e24c1a2
65a6c43
a307fc4
309e549
7755192
a9d6f30
7b437a9
d7a2d24
5b4e224
69de9a9
85916b3
536fc91
46e7951
c43f8ea
8d68d09
cfa0529
b19f5e2
8ded9c2
d828218
93eca1a
35c1c3b
6da1616
66f47fe
74eae48
d7375f5
006f2f7
e18b08f
26e178a
796d616
75dd4d9
72d7c97
0529929
2875f75
02051b8
2e5a8ee
bfda732
f7c14a7
a692710
0a76c93
762d53f
3aa78fd
abc565f
83a03ca
7f7ac0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,9 +34,13 @@ To minimize the scope for cookie vulnerabilities on your site, limit access to c | |
- `Path` | ||
- : Cookies should be set to the most restrictive `Path` possible. | ||
- `SameSite` | ||
- : Forbid sending cookies via cross-origin requests (for example from {{htmlelement("img")}} elements) using `SameSite`. This is a strong [anti-CSRF](/en-US/docs/Web/Security/Practical_implementation_guides/CSRF_prevention) measure. `SameSite` is also useful in protecting against [Clickjacking](/en-US/docs/Glossary/Clickjacking) attacks in cases that rely on the user being authenticated. You should use one of the following two values: | ||
- `SameSite=Strict`: Only send the cookie when your site is directly navigated to. | ||
- `SameSite=Lax`: Additionally send the cookie when navigating to your site from another site. Note that this is the default behavior used in modern browsers if no `SameSite` directive is set. | ||
|
||
- : Forbid sending cookies via cross-origin requests (for example from {{htmlelement("img")}} elements) using `SameSite`. You should use one of the following two values: | ||
|
||
- `SameSite=Strict`: Only send the cookie when your site is directly navigated to. This is a strong [anti-CSRF](/en-US/docs/Web/Security/Practical_implementation_guides/CSRF_prevention) measure, so use this value if possible. | ||
- `SameSite=Lax`: Additionally send the cookie when navigating to your site from another site. This is the default behavior used in modern browsers if no `SameSite` directive is set, and should only be used if `Strict` is too restrictive. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "additionally" seems odd when you have to pick one of the settings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I've updated it to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How about "Only send the cookie in same-site requests but also when navigating to your website."
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to:
|
||
|
||
Both of the above values are useful in protecting against [Clickjacking](/en-US/docs/Glossary/Clickjacking) attacks in cases that rely on the user being authenticated. | ||
|
||
## Examples | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,28 +6,51 @@ page-type: guide | |
|
||
{{QuickLinksWithSubpages("/en-US/docs/Web/Security")}} | ||
|
||
Cross-Origin Resource Policy is set by the {{httpheader("Cross-Origin-Resource-Policy")}} header, which lets websites and applications opt in to protection against certain requests from other origins (such as those issued with elements like {{htmlelement("script")}} and {{htmlelement("img")}}). | ||
Cross-Origin Resource Policy (CORP) is set by the {{httpheader("Cross-Origin-Resource-Policy")}} header, which lets websites and applications opt in to protection against certain cross-origin requests (such as those made by the {{htmlelement("script")}} and {{htmlelement("img")}} elements). | ||
chrisdavidmills marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Problem | ||
|
||
Side-channel hardware vulnerabilities such as [Meltdown](<https://en.wikipedia.org/wiki/Meltdown_(security_vulnerability)>) and [Spectre](<https://en.wikipedia.org/wiki/Spectre_(security_vulnerability)>) allow sensitive data disclosure due to a race condition arising as part of speculative execution functionality designed to improve performance. | ||
Some side-channel hardware vulnerabilities (also known as Cross-site leaks, or XS-Leaks), such as [Meltdown](<https://en.wikipedia.org/wiki/Meltdown_(security_vulnerability)>) and [Spectre](<https://en.wikipedia.org/wiki/Spectre_(security_vulnerability)>), exploit a race condition arising as part of speculative execution functionality of modern processors. This functionality is designed to improve performance but can be manipulated to disclose sensitive data. | ||
|
||
## Solution | ||
|
||
Use `Cross-Origin-Resource-Policy` to block [`no-cors`](/en-US/docs/Web/API/fetch#mode) cross-origin and/or cross-site requests to the given resource. Use the most restrictive value possible for your site: `same-site` or `same-origin` are recommended. | ||
Use `Cross-Origin-Resource-Policy` to block [`no-cors`](/en-US/docs/Web/API/fetch#mode) cross-origin requests to given resources. As this policy is expressed via a response header, the actual request is not prevented. Instead, the browser prevents the result from being leaked by stripping the response body. | ||
|
||
As this policy is expressed via a response header, the actual request is not prevented — rather, the browser prevents the result from being leaked by stripping the response body. | ||
The possible values are: | ||
|
||
- `same-origin` | ||
- : Limits resource access to requests coming from the same origin. This is recommended for requests for sensitive user information, or requests to private APIs. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about "....recommended for URLs that reply with sensitive user information or private APIs"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. like it; updated |
||
- `same-site` | ||
- : Limits resource access to requests coming from the same site. This is recommended for requests to origins whose functionality is shared across several other same-site origins. Examples include a company CDN that serves static resources, and a single sign-on (SSO) app that handles authentication. | ||
- `cross-origin` | ||
- : Allows resources to be accessed by cross-origin requests. This is recommended only for requests to widely-used origins, such as public CDNs or widgets. This is the default value if `Cross-Origin-Resource-Policy` is not set. | ||
|
||
Set the most restrictive value possible for your site. | ||
|
||
If your use case requires `cross-origin` access, opt into a better default by sending a {{httpheader("Cross-Origin-Embedder-Policy")}} header. This will prevent loading of cross-origin resources that don't also explicitly send a `Cross-Origin-Resource-Policy: cross-origin` header. | ||
chrisdavidmills marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Examples | ||
|
||
Instruct browsers to disallow cross-origin no-cors requests: | ||
Instruct browsers to disallow cross-origin requests made in `no-cors` mode: | ||
|
||
```http | ||
Cross-Origin-Resource-Policy: same-origin | ||
``` | ||
|
||
Instruct browsers to allow cross-origin resource access, including access to features with unthrottled timers (such as {{jsxref("SharedArrayBuffer")}} objects or {{domxref("Performance.now()")}}): | ||
|
||
```http | ||
Cross-Origin-Resource-Policy: same-origin | ||
Cross-Origin-Embedder-Policy: require-corp | ||
``` | ||
|
||
This also permits such resources to be embedded. | ||
|
||
## See also | ||
|
||
- [Consider deploying Cross-Origin Resource Policy](resourcepolicy.fyi) | ||
- [XS-Leaks Wiki](https://xsleaks.dev/) | ||
- [`Access-Control-Allow-Origin`](/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin) | ||
- [Cross-Origin Resource Sharing (CORS)](/en-US/docs/Web/HTTP/CORS) | ||
- [`Cross-Origin-Embedder-Policy`](/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy) | ||
- [`Cross-Origin-Opener-Policy`](/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy) | ||
- [Cross-Origin Resource Sharing (CORS)](/en-US/docs/Web/HTTP/CORS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't fully true. If you are navigating from a.example to b.example, the cookies will be omitted. They are only sent when the navigation is same-site.
Thus, SameSite=strict is breaking pages left and right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've updated this wording to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cookies are omitted in cross-site requests (hotlinking) and also on cross-site navigation (e.g., when following a link from a different web page). Cookies will be only sent in same-site contexts (context here meaning navigation & other requests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, updated to