Skip to content
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

Merged
merged 68 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
4703db1
Restructure security landing page
chrisdavidmills May 28, 2024
c04092c
Retitle and redirect Security your site page to Practical implementat…
chrisdavidmills May 28, 2024
5254100
Update files/en-us/web/security/index.md
chrisdavidmills May 28, 2024
c39da2b
Update files/en-us/web/security/index.md
chrisdavidmills May 28, 2024
c7a383a
initial draft of all Observatory pages
chrisdavidmills May 30, 2024
3164d32
Merge branch 'add-observatory-docs-to-mdn' of github.com:chrisdavidmi…
chrisdavidmills May 30, 2024
06d0b98
Update files/en-us/web/security/practical_implementation/clickjacking…
chrisdavidmills May 30, 2024
cc8a1bb
Update files/en-us/web/security/practical_implementation/clickjacking…
chrisdavidmills May 30, 2024
d7d47c7
Update files/en-us/web/security/practical_implementation/cookies/inde…
chrisdavidmills May 30, 2024
64dd386
Update files/en-us/web/security/practical_implementation/clickjacking…
chrisdavidmills May 30, 2024
0dc7334
Update files/en-us/web/security/practical_implementation/cookies/inde…
chrisdavidmills May 30, 2024
883d4a5
Update files/en-us/web/security/practical_implementation/referrer_pol…
chrisdavidmills May 30, 2024
68659ec
Update files/en-us/web/security/practical_implementation/referrer_pol…
chrisdavidmills May 30, 2024
8c03637
Update files/en-us/web/security/practical_implementation/sri/index.md
chrisdavidmills May 30, 2024
189313e
Update files/en-us/web/security/practical_implementation/sri/index.md
chrisdavidmills May 30, 2024
460025c
Update files/en-us/web/security/practical_implementation/tls/index.md
chrisdavidmills May 30, 2024
ec81406
Update files/en-us/web/security/practical_implementation/cookies/inde…
chrisdavidmills May 30, 2024
74ab66d
Update files/en-us/web/security/practical_implementation/cookies/inde…
chrisdavidmills May 30, 2024
dbeb415
Update files/en-us/web/security/practical_implementation/cors/index.md
chrisdavidmills May 30, 2024
0d277b9
Update files/en-us/web/security/practical_implementation/cors/index.md
chrisdavidmills May 30, 2024
d01abc7
Update files/en-us/web/security/practical_implementation/csp/index.md
chrisdavidmills May 30, 2024
63410ca
Update files/en-us/web/security/practical_implementation/csp/index.md
chrisdavidmills May 30, 2024
612279a
Update files/en-us/web/security/practical_implementation/csp/index.md
chrisdavidmills May 30, 2024
1d6810d
Update files/en-us/web/security/practical_implementation/csp/index.md
chrisdavidmills May 30, 2024
e24c1a2
Update files/en-us/web/security/practical_implementation/csp/index.md
chrisdavidmills May 30, 2024
65a6c43
Update files/en-us/web/security/practical_implementation/csrf_prevent…
chrisdavidmills May 30, 2024
a307fc4
Update files/en-us/web/security/practical_implementation/csrf_prevent…
chrisdavidmills May 30, 2024
309e549
Update files/en-us/web/security/practical_implementation/csrf_prevent…
chrisdavidmills May 30, 2024
7755192
Update files/en-us/web/security/practical_implementation/csrf_prevent…
chrisdavidmills May 30, 2024
a9d6f30
Update files/en-us/web/security/practical_implementation/index.md
chrisdavidmills May 30, 2024
7b437a9
Update files/en-us/web/security/practical_implementation/referrer_pol…
chrisdavidmills May 30, 2024
d7a2d24
Merge branch 'main' into add-observatory-docs-to-mdn
chrisdavidmills May 30, 2024
5b4e224
Fix broken links
chrisdavidmills May 30, 2024
69de9a9
tidy up links on the main practical page
chrisdavidmills May 31, 2024
85916b3
Make sure desired documents are linked to
chrisdavidmills Jun 2, 2024
536fc91
Merge branch 'main' into add-observatory-docs-to-mdn
chrisdavidmills Jun 2, 2024
46e7951
Add a few details to make sure the page align with the test results
chrisdavidmills Jun 3, 2024
c43f8ea
Merge branch 'main' into add-observatory-docs-to-mdn
chrisdavidmills Jun 3, 2024
8d68d09
fixes for dipikabh review comments
chrisdavidmills Jun 7, 2024
cfa0529
Update files/en-us/web/security/practical_implementation/index.md
chrisdavidmills Jun 7, 2024
b19f5e2
Update files/en-us/web/security/practical_implementation_guides/index.md
chrisdavidmills Jun 7, 2024
8ded9c2
Update files/en-us/web/security/practical_implementation_guides/index.md
chrisdavidmills Jun 7, 2024
d828218
remove old version of guide landing page
chrisdavidmills Jun 10, 2024
93eca1a
tweak redirects
chrisdavidmills Jun 10, 2024
35c1c3b
More fixes for dipikabh review comments
chrisdavidmills Jun 10, 2024
6da1616
Update files/en-us/web/security/practical_implementation_guides/index.md
chrisdavidmills Jun 10, 2024
66f47fe
Fix latest round of dipika review comments, and fix some links
chrisdavidmills Jun 12, 2024
74eae48
Making fixes for review comments from dipika and tibap
chrisdavidmills Jun 14, 2024
d7375f5
Update files/en-us/web/security/practical_implementation_guides/csrf_…
chrisdavidmills Jun 14, 2024
006f2f7
Update files/en-us/web/security/practical_implementation_guides/index.md
chrisdavidmills Jun 14, 2024
e18b08f
Update files/en-us/web/security/practical_implementation_guides/index.md
chrisdavidmills Jun 14, 2024
26e178a
Update files/en-us/web/security/practical_implementation_guides/tls/i…
chrisdavidmills Jun 14, 2024
796d616
last few tweaks
chrisdavidmills Jun 18, 2024
75dd4d9
Merge branch 'main' into add-observatory-docs-to-mdn
caugner Jun 18, 2024
72d7c97
fix broken links
chrisdavidmills Jun 19, 2024
0529929
Fixes for gene1wood review comments
chrisdavidmills Jun 19, 2024
2875f75
Fixes for review comments from freddyb
chrisdavidmills Jun 19, 2024
02051b8
add corp page
chrisdavidmills Jun 19, 2024
2e5a8ee
Merge branch 'main' into add-observatory-docs-to-mdn
chrisdavidmills Jun 19, 2024
bfda732
Update CSRF XSS link
chrisdavidmills Jun 20, 2024
f7c14a7
few more fixes for freddy and dipika comments
chrisdavidmills Jun 20, 2024
a692710
Correct HTTP observatory naming issues
chrisdavidmills Jun 20, 2024
0a76c93
Improve CORP page
chrisdavidmills Jun 20, 2024
762d53f
Add xs-leaks info and link
chrisdavidmills Jun 20, 2024
3aa78fd
Couple more fixes for gene wood comments
chrisdavidmills Jun 20, 2024
abc565f
fixes for freddyb comments
chrisdavidmills Jun 21, 2024
83a03ca
Fixes to SameSite directive descriptions
chrisdavidmills Jun 23, 2024
7f7ac0e
Merge branch 'main' into add-observatory-docs-to-mdn
chrisdavidmills Jun 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ To prevent referrer leakage entirely, specify the `no-referrer` value instead. N

Use services like the ones below to check your `Referrer-Policy`:

- [MDN Observatory](/en-US/observatory/)
- [HTTP Observatory](/en-US/observatory/)
- [securityheaders.com](https://securityheaders.com/)

```apacheconf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ X-Content-Type-Options: nosniff

- {{HTTPHeader("Content-Type")}}
- The [original definition](https://docs.microsoft.com/archive/blogs/ie/ie8-security-part-vi-beta-2-update) of X-Content-Type-Options by Microsoft.
- Use [MDN Observatory](/en-US/observatory/) to test the security configuration of websites (including this header).
- Use [HTTP Observatory](/en-US/observatory/) to test the security configuration of websites (including this header).
- [Mitigating MIME Confusion Attacks in Firefox](https://blog.mozilla.org/security/2016/08/26/mitigating-mime-confusion-attacks-in-firefox/)
- [Cross-Origin Read Blocking (CORB)](https://fetch.spec.whatwg.org/#corb)
- [Google Docs CORB explainer](https://chromium.googlesource.com/chromium/src/+/master/services/network/cross_origin_read_blocking_explainer.md)
2 changes: 1 addition & 1 deletion files/en-us/web/http/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Helpful tools and resources for understanding and debugging HTTP.

- [Firefox Developer Tools](https://firefox-source-docs.mozilla.org/devtools-user/index.html)
- : [Network monitor](https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/index.html)
- [Mozilla Observatory](https://observatory.mozilla.org/)
- [HTTP Observatory](/en-US/observatory/)
- : A project designed to help developers, system administrators, and security professionals configure their sites safely and securely.
- [RedBot](https://redbot.org/)
- : Tools to check your cache-related headers.
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/security/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ The following features can help guard against clickjacking:

To get comprehensive instructions for implementing security features effectively on websites and to ensure you're following best practices, see our set of [Practical security implementation guides](/en-US/docs/Web/Security/Practical_implementation_guides).

Some of these guides are directly related to the [MDN Observatory](/en-US/observatory/) tool. Observatory performs security audits on a website and provides a grade and score along with recommendations for fixing the security issues it finds. These guides explain how to resolve issues surfaced by the MDN Observatory tests: the tool links to the relevant guide for each issue, helping guide you towards an effective resolution. Interestingly, Mozilla's internal developer teams use this guidance when implementing websites to ensure that security best practices are applied.
Some of these guides are directly related to the [HTTP Observatory](/en-US/observatory/) tool. Observatory performs security audits on a website and provides a grade and score along with recommendations for fixing the security issues it finds. These guides explain how to resolve issues surfaced by the MDN Observatory tests: the tool links to the relevant guide for each issue, helping guide you towards an effective resolution. Interestingly, Mozilla's internal developer teams use this guidance when implementing websites to ensure that security best practices are applied.

## See also

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

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.

Copy link
Contributor Author

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

SameSite=Strict: Only send the cookie on same-site navigations. Cookies are omitted on same-origin navigations (e.g. a.example.com to b.example.com). This is a very strict setting, but it does provide strong CSRF protection, so use this value if possible.

Copy link

@mozfreddyb mozfreddyb Jun 21, 2024

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, updated to

  • SameSite=Strict: Only send the cookie in same-site contexts (navigations and other requests). Cookies are omitted in same-origin contexts (e.g. navigating a.example.com to b.example.com), cross-site requests (e.g. hotlinking), and cross-site navigation (e.g. when following a link from a different web page). This is a very strict setting, but it does provide strong CSRF protection, 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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"additionally" seems odd when you have to pick one of the settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I've updated it to

SameSite=Lax: Send the cookie on same-site and same-origin navigations, and 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 be used if Strict is too restrictive.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Remember that navigations are not the most interesting thing for CSRF / same-site cookies, but inclusion of cross-origin resources from attackers is.

  • same-site is a superset of same-origin-

How about "Only send the cookie in same-site requests but also when navigating to your website."

  • Omit the "default behavior in modern browsers". Only Chrome ships this and Firefox currently has no intention of shipping it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to:

- `SameSite=Lax`: Send the cookie in same-site requests and when navigating _to_ your website. This should be used if `Strict` is too restrictive.


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Choose a reason for hiding this comment

The 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"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)
Loading