Camille | 0f2a39f | 2022-11-04 10:45:04 | [diff] [blame] | 1 | # Web Platform Security guidelines |
| 2 | |
| 3 | [TOC] |
| 4 | |
| 5 | ## Introduction |
| 6 | The Open Web Platform (OWP) is a fast evolving platform, with new features |
| 7 | continuously expanding the scope of what the platform can do. It is also a |
| 8 | particularly rich target for would-be attackers. In this context, all new |
| 9 | features should be reviewed with particular care when it comes to their |
| 10 | security implications. The goal of this document is to help feature teams go |
| 11 | through the Security part of the S&P review process which ensures that their |
| 12 | features meet the security requirements expected of a new Web Platform feature. |
| 13 | |
| 14 | The guidelines in this document provide insight on how the Security teams think |
| 15 | about the security implications of new Web Platform features. They are here to |
| 16 | help feature teams think about security early on when designing their APIs. As |
| 17 | new threats and new mitigations arise, we will update this document to reflect |
| 18 | our updated recommendations. |
| 19 | |
| 20 | Currently, this document is divided into three sets of guidelines: security |
| 21 | boundaries, integration with security APIs and security UX. We have written |
| 22 | those based on the Web Platform Security team experience of conducting security |
| 23 | reviews, in partnership with other security teams at Google. This is based on |
| 24 | concerns that have come up in security reviews, and a few items that we |
| 25 | envision could be problematic. |
| 26 | |
| 27 | The goal of this document is not to provide a checklist, where if every item in |
| 28 | the list is checked a feature can be considered secure. If you find that your |
| 29 | feature cannot meet some of the security guidelines on this list, please reach |
| 30 | out to the Web Platform Security team earlier rather than later, and we can |
| 31 | work together on how to support your feature’s needs in a secure manner. |
| 32 | |
| 33 | ## Guidelines |
| 34 | |
| 35 | ### General guidelines |
| 36 | |
| 37 | <a name="TOC-safe-api-guidelines"></a> |
| 38 | #### Safe API design |
| 39 | |
| 40 | > Prefer simple APIs. |
| 41 | |
| 42 | * It is easier for developers to use higher-level and well laid out APIs. Try |
| 43 | to make the easy thing the safe thing in new APIs. |
| 44 | * If an API really needs potentially risky knobs, they should be well |
| 45 | documented and ideally named to explicitly call out their risk (e.g., the |
| 46 | subtle property in WebCrypto -- although this naming could be even more |
| 47 | explicit). |
| 48 | |
| 49 | <a name="TOC-design-with-the-web-ecosystem-in-mind"></a> |
| 50 | #### Design with the web ecosystem in mind |
| 51 | |
| 52 | > Consider how your feature will interact with the whole web ecosystem. In |
| 53 | particular, consider the interactions with workers (ServiceWorkers, |
| 54 | SharedWorkers, DedicatedWorkers), Fenced Frames and with the back/forward |
| 55 | cache. |
| 56 | |
| 57 | * Some features might need to be restricted in workers. For example, we have |
| 58 | restricted access to features like camera/microphone/geolocation because we |
| 59 | have no UI surface with which to explain the implication of an API to users. |
| 60 | * Fenced Frames have particular privacy requirements that might require |
| 61 | disabling a feature inside them. For example, CSP EE required particular |
| 62 | integration as enforcing a CSP on a Fenced Frame would provide a |
| 63 | communication channel with the Fenced Frame embedder. |
| 64 | * The interaction of the feature with the back/forward cache might be a |
| 65 | security concern. For example, audio and video capture should only be allowed |
| 66 | in pages currently shown to the users, and not in pages located in the |
| 67 | back/forward cache. See also the [non-fully |
| 68 | active](https://www.w3.org/TR/security-privacy-questionnaire/#non-fully-active) |
| 69 | part of the W3C security and privacy questionnaire. |
| 70 | |
| 71 | <a name="TOC-enterprise-policies"></a> |
| 72 | #### Enterprise policies |
| 73 | |
| 74 | > New enterprise policies are not allowed to bypass existing web security |
| 75 | policies/protections. Enterprise policies can only be added to bypass newly |
| 76 | introduced security restrictions, to maintain compatibility of existing |
| 77 | enterprise web apps. Enterprise policies should only ever bypass policy |
| 78 | decisions made by the browser, and not policies requested by websites. |
| 79 | |
| 80 | * When the browser introduces a new security restriction, such as gating Shared |
| 81 | Array Buffers behind crossOriginIsolation, it is ok to introduce an |
| 82 | enterprise policy to bypass that restriction in order to maintain |
| 83 | compatibility of existing enterprise web apps. |
| 84 | * It is not ok to create an enterprise policy to bypass longstanding security |
| 85 | restrictions that should be supported by existing apps. For example, it would |
| 86 | not be ok to introduce an enterprise policy to bypass the same-origin policy. |
| 87 | * Enterprise policies should only apply to new security restrictions introduced |
| 88 | to the browser. Enterprise policies should not be used to relax security |
| 89 | policies requested by the website themselves. For example, it would not be ok |
| 90 | to introduce an enterprise policy that bypasses CSP. |
| 91 | * See the [Chrome Security |
| 92 | FAQ](https://chromium.googlesource.com/chromium/src/+/master/docs/security/faq.md#Are-enterprise-admins-considered-privileged) |
| 93 | for more information on enterprise policies. |
| 94 | |
| 95 | ### Security boundaries |
| 96 | |
| 97 | <a name="TOC-security-boundaries"></a> |
| 98 | #### Security boundaries |
| 99 | |
| 100 | > The security team maintains several security boundaries in the WebPlatform: |
| 101 | origin, site, secure contexts, cross-origin isolated contexts. Before |
| 102 | introducing a new security boundary to support your design, discuss it with |
| 103 | the Web Platform Security team to ensure it's equally enforceable. |
| 104 | |
| 105 | * Maintaining a security boundary is complex, and might not even be possible |
| 106 | (e.g. origins and Spectre). An API relying on a new form of security boundary |
| 107 | should be thoroughly discussed with the Security team to check if the |
| 108 | boundary is enforceable and the security guarantees can be met. For example, |
| 109 | it is impossible to create an iframe that is fully isolated from its parent, |
| 110 | due to the risk of Spectre attacks on platforms that do not support Site |
| 111 | Isolation (low-end Android). |
| 112 | |
| 113 | <a name="TOC-the-origin-boundary"></a> |
| 114 | #### The origin boundary |
| 115 | |
| 116 | > The origin is the security boundary we aim to defend. We may make diverge |
| 117 | > from that (in both directions) in some cases, but those ought to be done in |
| 118 | > consultation with security folks. |
| 119 | |
| 120 | * The origin is the primary security boundary of the web, as per the |
| 121 | [Same-origin |
| 122 | policy](https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy). |
| 123 | * Note that unlike privacy, security is |
| 124 | concerned with same-site but cross-origin interactions. |
| 125 | |
| 126 | * Maintaining a security boundary is complex, and might not even be possible |
| 127 | (e.g. origins and Spectre). An API relying on a new form of security boundary |
| 128 | should be thoroughly discussed with the Security team to check if the |
| 129 | boundary is enforceable and the security guarantees can be met. For example, |
| 130 | it is impossible to create an iframe that is fully isolated from its parent, |
| 131 | due to the risk of Spectre attacks on platforms that do not support Site |
| 132 | Isolation (low-end Android). |
| 133 | |
| 134 | <a name="TOC-encryption"></a> |
| 135 | #### Encryption |
| 136 | |
| 137 | > Prefer secure contexts for new features. |
| 138 | |
| 139 | * Any data sent over HTTP can be observed by others on the network and opens |
| 140 | users to on-path attackers. |
| 141 | * The same-origin policy the web security model is built upon is easily abused |
| 142 | without cryptographical authentication of the servers we are talking to. |
| 143 | * See the [Chrome Security |
| 144 | FAQ](https://chromium.googlesource.com/chromium/src/+/main/docs/security/faq.md#why-are-some-web-platform-features-only-available-in-https-page_loads) |
| 145 | for more information. |
| 146 | |
| 147 | <a name="TOC-timer-resolution"></a> |
| 148 | #### Timer resolution |
| 149 | |
| 150 | > Explicit timers' granularity must be limited based on a context's |
| 151 | cross-origin isolation status. Currently, isolated contexts can support |
| 152 | timers coarsened to at least 5 microseconds, while unisolated contexts must |
| 153 | coarsen timers to 100 microseconds or more. If an API allows the creation of |
| 154 | timers with a precision higher than allowed in unisolated contexts, it should |
| 155 | be restricted to crossOriginIsolated contexts. |
| 156 | |
| 157 | * High resolution timers open users to timing attacks such as Spectre. This is |
| 158 | why their precision should be limited. |
| 159 | * In crossOriginIsolated contexts, cross-origin resources are either loaded |
| 160 | without credentials, or they opt into being embedded cross-origin into a |
| 161 | context where they could potentially be read by their embedder. This means |
| 162 | that cross-origin resources in a crossOriginIsolated context are either ok |
| 163 | with a Spectre attack (opt-in model), or of no interest to an attacker |
| 164 | (credentialless model). Because of this, we allow higher precision timers in |
| 165 | crossOriginIsolated contexts. |
| 166 | * APIs that can be used to create timers (e.g. SharedArrayBuffers) that are |
| 167 | more precise than timers available in cross-origin isolated contexts should |
| 168 | be gated behind crossOriginIsolation, in order to avoid introducing high |
| 169 | resolution timers to the platform. |
| 170 | |
| 171 | <a name="TOC-accessing-data-of-cross-origin-subresources"></a> |
| 172 | #### Accessing data of cross-origin subresources |
| 173 | |
| 174 | > New APIs that can access data from cross-origin subresources should be gated |
| 175 | > behind an appropriate mechanism depending on their surface: |
| 176 | > * CORS/TAO for access to a single resource. |
| 177 | > * crossOriginIsolation for access to the agent cluster. |
| 178 | > * crossOriginIsolation + frame opt-in mechanism for access to the whole page. |
| 179 | |
| 180 | * This kind of API bypasses the same-origin policy, which is the base of the |
| 181 | Web security model. This is only acceptable if the cross-origin resources opt |
| 182 | into sharing this data. |
| 183 | * CORS or TAO are appropriate when divulging information about a single |
| 184 | resource, e.g. load timings for a single resource. |
| 185 | * crossOriginIsolation should be used when the API can divulge information |
| 186 | about cross-origin resources located in the same agent cluster (roughly, the |
| 187 | API is scoped to same-origin documents). For example, an API that measures |
| 188 | the memory taken by all same-origin documents and their subresources. |
| 189 | * If the API can divulge information from the resources located in the whole |
| 190 | page, we will need an opt-in from documents outside the agent cluster, on top |
| 191 | of crossOriginIsolation. For example, an API that streams a video of the page |
| 192 | or takes a screenshot of the page. Alternatively, it might be acceptable to |
| 193 | gate the API behind user interaction with a sufficiently informative UI |
| 194 | element. |
| 195 | |
| 196 | <a name="TOC-side-channels"></a> |
| 197 | #### Side channels |
| 198 | |
| 199 | > Any new form of cross-origin communication or API should be carefully |
| 200 | > considered when it comes to side-channel attack risks. |
| 201 | |
| 202 | * Cross-origin communication channels and APIs can be abused to leak data from |
| 203 | cross-origin resources. Any new addition should be carefully reviewed to |
| 204 | assess the amount of data exposed. Note that unlike privacy, security is |
| 205 | concerned with same-site but cross-origin communication and APIs. |
| 206 | |
| 207 | <a name="TOC-implementation-concerns"></a> |
| 208 | #### Implementation concerns |
| 209 | |
| 210 | > Any new API whose implementation is particularly risky (e.g. requires new |
| 211 | > parsers, involves new codecs, requires particular isolation) should see the |
| 212 | > implementation reviewed in detail, in conjunction with the wider Chrome |
| 213 | > Security team. |
| 214 | |
| 215 | * New parsers and codecs are particularly risky pieces of code that are exposed |
| 216 | to attacker-controlled inputs. Their implementations are subjected to |
| 217 | particular rules (see the [rule of |
| 218 | two](https://chromium.googlesource.com/chromium/src/+/HEAD/docs/security/rule-of-2.md)), |
| 219 | and they must be fuzzed. |
| 220 | * Proper isolation is hard to deploy, is heavily dependent on implementation |
| 221 | and might face constraints on some platforms (e.g. low-end Android devices). |
| 222 | |
| 223 | <a name="TOC-user-activation"></a> |
| 224 | #### User activation |
| 225 | |
| 226 | > Consider requiring a feature be gated behind user activation if its UX could |
| 227 | > be abused by a document the user did not interact with. |
| 228 | |
| 229 | * Several features should only be available if the user chooses to interact |
| 230 | with the document. If they could be abused otherwise, consider gating them |
| 231 | behind user activation. For example, fullscreen is gated behind user |
| 232 | activation, as it could be used to trick the user into believing they are on |
| 233 | another page by mimicking the Chrome UI. |
| 234 | * This helps match the platform with the user’s mental model. |
| 235 | * Features which are security sensitive will likely need aditional protection |
| 236 | beyond user activation. User activation is not a security boundary, it is a |
| 237 | way to protect users from abusive UX behavior from sites. |
| 238 | |
| 239 | <a name="TOC-navigation-and-document-lifetime"></a> |
| 240 | #### Navigation and Document lifetime |
| 241 | |
| 242 | > Any feature that impacts the lifetime of documents or that modifies |
| 243 | > navigation is likely to have far-reaching security implications. Please |
| 244 | > discuss the implications with the Web Platform Security team as soon as |
| 245 | > possible. |
| 246 | |
| 247 | * Modifying the navigation stack could cause URL spoofing attacks. |
| 248 | * Modifying the navigation stack or the document lifetime could result in wrong |
| 249 | origin or security policies being applied to the document. |
| 250 | |
| 251 | ### Integration with security policies |
| 252 | |
| 253 | <a name="TOC-document-load"></a> |
| 254 | #### Document load |
| 255 | |
| 256 | > All changes to how a document is loaded should ensure they uphold the following |
| 257 | > security policies: |
| 258 | > [XFO](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options), |
| 259 | > [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP), |
| 260 | > [COOP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Opener-Policy), |
| 261 | > [COEP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy), |
| 262 | > and [Private Network access](https://wicg.github.io/private-network-access/). |
| 263 | |
| 264 | * XFO, CSP, COEP and Private Network access can block document load. This |
| 265 | should be respected. |
| 266 | * COOP can trigger a browsing context group switch which should be respected as |
| 267 | well. |
| 268 | * CSP, COEP and Private Network access are computed when loading a document and |
| 269 | may apply to all of the document resources. Failure to integrate properly |
| 270 | with them could result in the policies being bypassed. |
| 271 | |
| 272 | <a name="TOC-subresource-load"></a> |
| 273 | #### Subresource load |
| 274 | |
| 275 | > All changes to how a resource is loaded should uphold the following |
| 276 | > security policies: |
| 277 | > [CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP), |
| 278 | > [COEP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cross-Origin-Embedder-Policy), |
| 279 | > [CORP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cross-Origin_Resource_Policy_(CORP)), |
| 280 | > [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), |
| 281 | > [CORB](https://fetch.spec.whatwg.org/#corb), |
| 282 | > [SRI](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) |
| 283 | > and [Private Network access](https://wicg.github.io/private-network-access/). |
| 284 | |
| 285 | * All of the policies above may block unsafe resource loads and must be |
| 286 | properly applied to any subresource load. |
| 287 | |
| 288 | <a name="TOC-code-execution"></a> |
| 289 | #### Code execution |
| 290 | |
| 291 | > New ways of executing JavaScript code should integrate with CSP script-src. |
| 292 | |
| 293 | * New ways of executing JavaScript should defend themselves against XSS attacks |
| 294 | by supporting CSP. |
| 295 | |
| 296 | > New ways of executing code should consider the cross-site scripting (XSS) |
| 297 | > risks. If any new risk is identified, the new API should integrate with CSP |
| 298 | > script-src and/or Trusted Types and/or Sanitizer. |
| 299 | |
| 300 | * New ways of executing code should consider whether they are open to XSS |
| 301 | vulnerabilities. If they are, they should defend themselves against attacks |
| 302 | by supporting CSP and/or Trusted Types and/or Sanitizer. |
| 303 | * For example, the [import map |
| 304 | proposal](https://github.com/WICG/import-maps/issues/105) had to be spelled |
| 305 | as an extension to the |
| 306 | `<script>` tag to avoid inadvertently creating CSP bypasses. |
| 307 | |
| 308 | <a name="TOC-CORS"></a> |
| 309 | #### CORS |
| 310 | |
| 311 | > New types of elements should require CORS when loading resources. |
| 312 | |
| 313 | * CORS allows an origin to control how its authenticated data is embedded in |
| 314 | other origins. In an ideal world, all cross-origin authenticated requests |
| 315 | would require CORS, but this is impossible for compatibility reasons. |
| 316 | However, new elements should not add a new source of non CORS requests to the |
| 317 | platform. |
| 318 | * Elements that are allowed to make cross-origin authenticated requests without |
| 319 | CORS introduce a hole in the platform that may be exploited in a MIME |
| 320 | mismatch attack to bypass CORS protections for resources that are normally |
| 321 | loaded through Fetch or into elements that require CORS. |
| 322 | |
| 323 | <a name="TOC-mime-types"></a> |
| 324 | #### MIME types |
| 325 | |
| 326 | > New resource types should require strict MIME type matching, and avoid |
| 327 | > relying upon [sniffing](https://mimesniff.spec.whatwg.org/). |
| 328 | |
| 329 | * Mismatches between a resource's asserted MIME type and the way it's used by |
| 330 | the browser can cause security issues. For example, browsers currently |
| 331 | attempt to execute practically anything via `<script>` tags because of |
| 332 | widespread mislabeling of script resources as `text/html` or text/plain`, |
| 333 | which can expose those resources to side-channel attacks like Spectre, and |
| 334 | more direct XSSI attacks. |
| 335 | [CORB](https://chromium.googlesource.com/chromium/src/+/HEAD/services/network/cross_origin_read_blocking_explainer.md) |
| 336 | mitigates some, but not all, of these risks. |
| 337 | * New resource types should avoid these risks entirely by specifying clear MIME |
| 338 | types, and accepting only those resources that assert themselves to be of the |
| 339 | proper type. |
| 340 | |
| 341 | ### Security UX |
| 342 | |
| 343 | <a name="TOC-iframes"></a> |
| 344 | #### Iframes |
| 345 | |
| 346 | > A document element should not be allowed to draw outside its frame. |
| 347 | |
| 348 | * A document drawing over its embedding frame allows it to perform clickjacking |
| 349 | attacks and should never be allowed. |
| 350 | * Drawing over the browser-controlled UX surface allows to perform all sorts of |
| 351 | attacks. See the browser-controlled surface guideline below for more |
| 352 | information. |
| 353 | |
| 354 | <a name="TOC-browser-controlled-surface"></a> |
| 355 | #### Browser-controlled surface |
| 356 | |
| 357 | > Browser-controlled surfaces should not be drawn over. Converting a |
| 358 | > browser-controlled UX surface into a content-controlled surface can only be |
| 359 | > considered in specific cases and must be gated behind appropriate mechanisms. |
| 360 | |
| 361 | * Drawing over the omnibox allows to perform URL spoof attacks and should never |
| 362 | be allowed. It can also lead to displaying incorrect SSL state information to |
| 363 | the user. |
| 364 | * It is possible to consider converting some of the browser-controlled surfaces |
| 365 | into content-controlled surfaces in cases such as installed PWAs. This should |
| 366 | still be gated behind explicit signals from the user, such as a permission |
| 367 | grant or other in-context UI affordances that allow the user to toggle |
| 368 | between modes. |
| 369 | * Browser-controlled surfaces include the top browser chrome, but also the |
| 370 | fullscreen disclosure bubble, Payment Handler dialogs, permission dialogs, |
| 371 | etc. |
| 372 | |
| 373 | <a name="TOC-site-identity-and-security-indicators"></a> |
| 374 | #### Site identity and security indicators |
| 375 | |
| 376 | > Communicating site identity and security indicators should only be done |
| 377 | > through browser-controlled UI. |
| 378 | |
| 379 | * Security state and site identity are state tracked by the browser and it is |
| 380 | difficult (at best) to show this information inside the content area in a |
| 381 | trustworthy way. See the [Chrome Security |
| 382 | FAQ](https://chromium.googlesource.com/chromium/src/+/master/docs/security/faq.md#Certificates-Connection-Indicators) |
| 383 | for more details. |
| 384 | * Interstitials (e.g., SSL error pages) are shown in the content area but are |
| 385 | browser controlled committed navigations. |
| 386 | * Other security displays overlaid on the content area (e.g., autofill |
| 387 | warnings) should be handled with care and should be controlled by the |
| 388 | browser. |
| 389 | |
| 390 | <a name="TOC-browser-controlled-ui"></a> |
| 391 | #### Browser-controlled UI |
| 392 | |
| 393 | > Changes to browser-controlled UI or new features that will require new |
| 394 | > browser-controlled UI should go through Chrome Browser security review. |
| 395 | |
| 396 | * Browser-controlled UI has many considerations around spoofing, abuse, etc. |
| 397 | * New UI needs to be reviewed by various cross-functional groups (not just |
| 398 | security). |
| 399 | * This is especially true when the UI involves the user making a decision or |
| 400 | the UI communicates site identity to the user in any way. |
| 401 | |
| 402 | <a name="TOC-permissions"></a> |
| 403 | #### Permissions |
| 404 | |
| 405 | > Powerful new capabilities should in most cases integrate with |
| 406 | > Permissions-Policy and only be accessible to top-level frames by default. |
| 407 | > The Permissions Team should be brought in early to consult on new |
| 408 | > permissions. |
| 409 | |
| 410 | * Permissions often require users to make a trust decision about a site. In |
| 411 | Chrome, the only visible site identity is the top-level frame (whose origin |
| 412 | is shown in the Omnibox). |
| 413 | * User confusion about subframe origins was a motivation for permission |
| 414 | delegation, where top-level contexts must explicitly delegate their |
| 415 | permissions to subframes, allowing the user to only have to reason about |
| 416 | top-level frames. |
| 417 | |
| 418 | <a name="TOC-mixed-content"></a> |
| 419 | #### Mixed content |
| 420 | |
| 421 | > New features should not be able to relax or work around mixed content |
| 422 | > restrictions. |
| 423 | |
| 424 | * Chrome now upgrades or blocks all mixed content (insecure resources or |
| 425 | connections embedded in secure contexts). This greatly simplifies Chrome’s |
| 426 | security state model. |
| 427 | * Allowing new features to bypass these security restrictions can undermine |
| 428 | other security features in Chrome which assume no mixed content (such as |
| 429 | HTTPS-First Mode). |
| 430 | |
| 431 | <a name="TOC-foreground-background-execution"></a> |
| 432 | #### Foreground/background execution |
| 433 | |
| 434 | > Consider whether a new feature might be abusable or confusing to a user if a |
| 435 | > site can use it while in the background. Ensure that the user has sufficient |
| 436 | > context for something triggering and won’t be caught by surprise. |
| 437 | |
| 438 | * This will often co-occur with “Browser-controlled UI” (see above), but it is |
| 439 | good to think about whether an API should be restricted to foreground tabs |
| 440 | only if they have a risk of being surprising to the user when used by a page. |
| 441 | * For example, we restrict HTML fullscreen to foreground contexts (and display |
| 442 | a disclosure UI). APIs that trigger permission prompts should only show the |
| 443 | prompts when the tab is in the foreground. |
| 444 | |