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 1 commit
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
Prev Previous commit
Next Next commit
Fixes for gene1wood review comments
  • Loading branch information
chrisdavidmills committed Jun 19, 2024
commit 05299298b43860a7e8ce0cb0221a1a1894abffda
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Limit access to cookies as much as possible.

## Problem

Cookies often contain session identifiers or other sensitive information. Unwanted access to cookies, therefore, can cause a host of problems, including [privacy](/en-US/docs/Web/Privacy) issues, ({{Glossary("Cross-site_scripting", "Cross-site scripting (XSS)")}}) attacks, Cross-site request forgery ([CSRF](/en-US/docs/Glossary/CSRF)) attacks, and more.
Cookies often contain session identifiers or other sensitive information. Unauthorized access to cookies, therefore, can cause a host of problems, including [privacy](/en-US/docs/Web/Privacy) issues, ({{Glossary("Cross-site_scripting", "Cross-site scripting (XSS)")}}) attacks, Cross-site request forgery ([CSRF](/en-US/docs/Glossary/CSRF)) attacks, and more.

## Solution

Expand All @@ -32,9 +32,9 @@ To minimize the scope for cookie vulnerabilities on your site, limit access to c
- `Domain`
- : Cookies should only have a `Domain` set if they need to be accessible on other domains; this should be set to the most restrictive domain possible.
- `Path`
- : Cookies should be set to the most restrictive `Path` possible; for most applications, this will be set to the root directory.
- : Cookies should be set to the most restrictive `Path` possible.
- `SameSite`
- : Forbid sending the cookie via cross-origin requests (for example from {{htmlelement("img")}} element), as 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:
- : 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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ page-type: guide

{{QuickLinksWithSubpages("/en-US/docs/Web/Security")}}

Users frequently input sensitive data on websites, such as names, addresses, and banking details. As a web developer, it's crucial to protect this information from bad actors who use a wide range of exploits to steal such information and use it for personal gain. The focus of [web security](/en-US/docs/Web/Security) is to help you protect your website against these exploits and secure your users' sensitive data.
Users frequently input sensitive data on websites, such as names, addresses, passwords, and banking details. As a web developer, it's crucial to protect this information from bad actors who use a wide range of exploits to steal such information and use it for personal gain. The focus of [web security](/en-US/docs/Web/Security) is to help you protect your website against these exploits and secure your users' sensitive data.

This page lists guides that detail the best practices for implementing security features on websites. While these guides do not cover all possible security scenarios and cannot guarantee complete security of your website, following the information and best practices in these guides will make your sites significantly more secure.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Many factors can increase the load on your website; this includes web crawlers.

Use `robots.txt` to reduce website load and stop unsuitable content appearing in search results.

Using `robots.txt` is optional and sites should use it only for these purposes. It should not be used as a way to prevent the disclosure of private information or to hide portions of a website. While using this file can prevent these sites from appearing in search engine results, it does not secure websites against attackers who can still determine such details because `robots.txt` is publicly accessible.
Using `robots.txt` is optional and sites should use it only for these purposes. It should not be used as a way to prevent the disclosure of private information or to hide portions of a website. While using this file can prevent pages from appearing in search engine results, it does not secure websites against attackers. In fact, it can help them: `robots.txt` is publicly accessible, and by adding your sensitive page paths to it, you are showing attackers exactly where they are.
dipikabh marked this conversation as resolved.
Show resolved Hide resolved

Also be aware that some robots will ignore your `robots.txt` file, for example, malware robots and email address harvesters.
dipikabh marked this conversation as resolved.
Show resolved Hide resolved

## Examples

Expand All @@ -36,4 +38,4 @@ Disallow: /secret/admin-interface

## See also

- [About /robots.txt](https://www.robotstxt.org/robotstxt.html) on `robotstxt.org`.
- [About /robots.txt](https://www.robotstxt.org/robotstxt.html) on `robotstxt.org`
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ page-type: guide

## Problem

Attackers can modify the contents of JavaScript libraries hosted on content delivery networks (CDNs), creating vulnerabilities in all websites that use these libraries.
If an attacker exploited a content delivery network (CDN) and modified the contents of JavaScript libraries hosted on that CDN, it would create vulnerabilities in all websites that use those libraries.

For example, JavaScript code hosted on `library.org` that is loaded from `example.org` can access the entire contents of `example.org`. If an attacker modifies this resource to include malicious code, it could alter download links, deface the site, steal credentials, cause denial-of-service (DoS) attacks, and so on.
For example, JavaScript hosted on `library.org` that is loaded from `example.org` can access the entire contents of `example.org`. If an attacker modifies that hosted JavaScript to include malicious code, it could alter download links, deface the site, steal credentials, cause denial-of-service (DoS) attacks, and so on.

## Solution

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ page-type: guide

{{QuickLinksWithSubpages("/en-US/docs/Web/Security")}}

[Transport Layer Security (TLS)](/en-US/docs/Glossary/TLS) provides assurances about the confidentiality, authentication, and integrity of all communications, and as such, should be used for all inbound and outbound website communications.
[Transport Layer Security (TLS)](/en-US/docs/Glossary/TLS) provides assurances about the confidentiality, authenticity, and integrity of all communications, and as such, should be used for all inbound and outbound website communications.

## TLS configuration

### Problem

If data is sent over the web unencrypted, it can be intercepted and read by third parties, who can modify and/or steal the data — this is often known as a [manipulator-in-the-middle](/en-US/docs/Glossary/MitM) (MiTM) attack. MiTM attacks have severe consequences for the security of your system.
If data is sent over the web unencrypted, it can be intercepted by third parties, who can access and modify the data — this is often known as a [manipulator-in-the-middle](/en-US/docs/Glossary/MitM) (MiTM) attack. MiTM attacks have severe consequences for the security of your system.

All requests and responses should, therefore, be sent over HTTPS. The modern web practically enforces this — all browsers are moving towards requiring [HTTPS](/en-US/docs/Glossary/HTTPS) by default, and many web features can only be used in a [secure context](/en-US/docs/Web/Security/Secure_Contexts).
All requests and responses should therefore be sent over HTTPS, which uses TLS to encrypt the data. The modern web practically enforces this — all browsers are moving towards requiring [HTTPS](/en-US/docs/Glossary/HTTPS) by default, and many web features can only be used in a [secure context](/en-US/docs/Web/Security/Secure_Contexts).

### Solution

You should set up your server software to use a robust TLS configuration that enforces HTTPS. There are several TLS configuration generators available that can help with this, for example, the Mozilla [SSL Configuration Generator](https://ssl-config.mozilla.org/). This tool provides several options based on Mozilla's [TLS guidelines](https://wiki.mozilla.org/Security/Server_Side_TLS).
You should set up your server software to use a secure configuration that enforces the use of HTTPS with safe TLS settings. There are several TLS configuration generators available that can help with this, for example, the Mozilla [SSL Configuration Generator](https://ssl-config.mozilla.org/). This tool provides several options based on Mozilla's [TLS guidelines](https://wiki.mozilla.org/Security/Server_Side_TLS).

## Resource loading

Expand All @@ -38,7 +38,7 @@ Similarly, attempts to load passive content such as images insecurely, although
<img src="http://very.badssl.com/image.jpg" />
```

Although modern browsers make it evident when websites are loading resources insecurely, these errors still occur with significant frequency.
Although modern browsers make it evident when websites are loading resources insecurely, these errors still occur across the web with significant frequency.

### Solution

Expand All @@ -56,9 +56,9 @@ In this example, HTTPS is being used correctly to load a JavaScript library:

### Problem

Websites may continue to listen on port 80 (HTTP) to prevent connection errors when users type a URL into their address bar, as initial browser connections are made via HTTP. This poses an initial security risk during the first connection to sites.
Websites may continue to listen on port 80 (HTTP) to prevent connection errors when users type a URL into their address bar, as initial browser connections are often made via HTTP. This poses an initial security risk during the first connection to sites as that connection is not protected by TLS.

In addition, sites should avoid redirections from HTTP to HTTPS on a different host, as this prevents `Strict-Transport-Security` from being set (see [HTTP Strict Transport Security](#http_strict_transport_security)).
In addition, sites should avoid redirections from HTTP on one host to HTTPS on a different host, as this prevents `Strict-Transport-Security` from being set for the first host (see [HTTP Strict Transport Security](#http_strict_transport_security)).

### Solution

Expand Down Expand Up @@ -96,26 +96,26 @@ Redirect `site.example.org` from HTTP to HTTPS, using Apache:

### Problem

To prevent [manipulator-in-the-middle](/en-US/docs/Glossary/MitM) (MiTM) attacks, browsers should only connect to sites via HTTPS, regardless of the chosen protocol.
To prevent [manipulator-in-the-middle](/en-US/docs/Glossary/MitM) (MiTM) attacks, browsers should only connect to sites via HTTPS.

### Solution

HTTP [`Strict-Transport-Security`](/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security) (HSTS) is an HTTP header that notifies browsers to connect to a given site only over HTTPS, even if the originally specified scheme was HTTP. Browsers with HSTS set for a given site will automatically upgrade all requests to HTTPS. HSTS also tells browsers to treat TLS and certificate-related errors more strictly by disabling the ability to bypass the error page.
HTTP [`Strict-Transport-Security`](/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security) (HSTS) is an HTTP header that notifies browsers to connect to a given site only over HTTPS, even if the originally specified scheme was HTTP. Browsers with HSTS set for a given site will automatically upgrade all requests to HTTPS for that site. HSTS also tells browsers to treat TLS and certificate-related errors more strictly by disabling the ability to bypass the certificate error page.

`Strict-Transport-Security` supports the following directives:

- `max-age`
- : Sets the duration, in seconds, for which browsers will redirect to HTTPS.
- `includeSubDomains` {{optional_inline}}
- : Specifies whether browsers should upgrade requests on all subdomains to HTTPS. For example, setting `includeSubDomains` on `domain.example.com` will ensure that requests to `host1.domain.example.com` and `host2.domain.example.com` are upgraded.
- : Specifies whether browsers should upgrade requests on all subdomains to HTTPS. For example, setting `includeSubDomains` on `domain.example.com` will ensure that requests to `host1.domain.example.com` and `host2.domain.example.com` are upgraded in addition to `domain.example.com`.
- `preload` {{optional_inline}}
- : Specifies whether the site should be preloaded. Including this directive means your site will be included in the [HSTS preload list](https://hstspreload.org/).
- : Specifies whether the site should be preloaded. Including this directive means your site can be included in the [HSTS preload list](https://hstspreload.org/).

Follow these steps to correctly implement HSTS on your website:

1. Set a `max-age` value of at least six months (`15768000`). Longer periods, such as two years (`63072000`), are recommended. Once this value is set, the site must continue to support HTTPS until the expiry time is reached.
2. If possible, set `includeSubDomains` to improve security on all subdomains. Careful testing is needed when setting this directive because it could disable sites on subdomains that don't yet have HTTPS enabled.
3. If possible, set `preload` to include your website in the [HSTS preload list](https://hstspreload.org/). Web browsers will perform HTTPS upgrades to preloaded sites before receiving the initial `Strict-Transport-Security` header. This prevents [downgrade attacks](https://en.wikipedia.org/wiki/Downgrade_attack) upon first use and is recommended for all high-risk websites. Note that being included in the HSTS preload list also requires `includeSubDomains` to be set and `max-age` to be set to a minimum of 1 year (`31536000`).
3. If possible, set `preload` to make it possible to include your website in the HSTS preload list. To add it to the list, visit https://hstspreload.org/ and enter your site URL into the form at the top of the page, fixing any issues that it mentions. Web browsers will perform HTTPS upgrades to preloaded sites before receiving the initial `Strict-Transport-Security` header. This prevents [downgrade attacks](https://en.wikipedia.org/wiki/Downgrade_attack) upon first use and is recommended for all high-risk websites. Note that being included in the HSTS preload list also requires `includeSubDomains` to be set and `max-age` to be set to a minimum of 1 year (`31536000`).

### Examples

Expand Down