Implement security enforcements for sandboxed frame processes.

With OOPSIFs, it becomes possible to tighten security checks for
processes that host sandboxed frames. Namely, sandboxed frames have an
opaque origin and cannot access storage, passwords, cookies and
various other forms of data. This CL implements this restriction with
an additional check in CanAccessMaybeOpaqueOrigin() that's specific to
sandboxed frame processes, blocking all access to an existing origin's
data coming from a sandboxed process. Two other types of access are
still permitted:

- new URLs are still allowed to commit in sandboxed frames. Ideally,
  we would also enforce that this requires the URL to commit with an
  opaque origin, but currently this knowledge is not plumbed from
  all the callers (namely, CanCommitURL and CanCommitOriginAndUrl).
  This will be fixed in subsequent CLs.

- using a particular origin as an initiator origin (for example, in
  postMessage) is still allowed, as long as that origin is
  opaque. This is because sandboxed frames are still allowed to
  communicate with other frames and send/receive messages. Note that
  there are still some workarounds [1] in place that exclude opaque
  origins from performing ChildProcessSecurityPolicy security checks
  in the first place, which also will be removed in future CLs.

Here is a summary of current uses of CanAccessDataForOrigin(), as well
as why these are all safe to block in sandboxed frames, which is what
this CL does:

- DOM storage, such as localStorage, sessionStorage, or web
  databases. These are not allowed in opaque origins.

- Passwords. Blink already enforces that opaque origins already cannot
  access passwords [2], so this is just adding a browser-side
  enforcement.

- cookies (the common path does not use CanAccessOrigin() and protects
  cookie access by construction, but one Android-specific media path
  currently still uses CanAccessOrigin() to protect cookie
  access). Cookies can't be accessed by opaque origins.

- blob URL access. Blob URLs *can* be created in sandboxed frames (and
  will have an opaque origin as a result), but after a recent blob URL
  refactor (see net::features::kSupportPartitionedBlobUrl), that
  doesn't go through CanAccessOrigin() checks. Only the old mode
  (already disabled by default) still uses CanAccessOrigin(), and
  specifically skips it for opaque origins [3]. Hence, it should be
  safe to just treat blob URLs the same as any other type of storage
  from CPSP's perspective.

- Push messaging access. These require ServiceWorkers to run in the
  corresponding origin, but ServiceWorkers are blocked for sandboxed
  frames: see code [4] and spec [5].

- Plugins. Plugins can't be loaded in sandboxed frames, and there's no
  directive to bypass that restriction [6].

[1] https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_frame_proxy_host.cc;l=549;drc=79fd5d71c46d0e6ecd842867bc1c787fae68e218

[2] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/weborigin/security_origin.h;l=240;drc=79fd5d71c46d0e6ecd842867bc1c787fae68e218

[3] https://source.chromium.org/chromium/chromium/src/+/main:storage/browser/blob/blob_registry_impl.cc;l=639;drc=b5b5329172a1607685db895653aa928560848ed3

[4] https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/service_worker/navigator_service_worker.cc;l=36;drc=a5a3f3a8599e454645674a6de1a54660c34f8faf

[5] https://www.w3.org/TR/service-workers/#control-and-use-window-client

[6] https://web.dev/articles/sandboxed-iframes.

Change-Id: I4ae23c9eef75540ac96d0cfac699272a49152cf9
Bug: 325410297
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5282423
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Ayu Ishii <ayui@chromium.org>
Commit-Queue: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1280332}
4 files changed
tree: 99ace56f0ab897abb93ef8172641de43d7315bd2
  1. android_webview/
  2. apps/
  3. ash/
  4. base/
  5. build/
  6. build_overrides/
  7. buildtools/
  8. cc/
  9. chrome/
  10. chromecast/
  11. chromeos/
  12. codelabs/
  13. components/
  14. content/
  15. courgette/
  16. crypto/
  17. dbus/
  18. device/
  19. docs/
  20. extensions/
  21. fuchsia_web/
  22. gin/
  23. google_apis/
  24. google_update/
  25. gpu/
  26. headless/
  27. infra/
  28. ios/
  29. ipc/
  30. media/
  31. mojo/
  32. native_client_sdk/
  33. net/
  34. pdf/
  35. ppapi/
  36. printing/
  37. remoting/
  38. rlz/
  39. sandbox/
  40. services/
  41. skia/
  42. sql/
  43. storage/
  44. styleguide/
  45. testing/
  46. third_party/
  47. tools/
  48. ui/
  49. url/
  50. webkit/
  51. .clang-format
  52. .clang-tidy
  53. .clangd
  54. .eslintrc.js
  55. .git-blame-ignore-revs
  56. .gitallowed
  57. .gitattributes
  58. .gitignore
  59. .gitmodules
  60. .gn
  61. .mailmap
  62. .rustfmt.toml
  63. .vpython3
  64. .yapfignore
  65. ATL_OWNERS
  66. AUTHORS
  67. BUILD.gn
  68. CODE_OF_CONDUCT.md
  69. codereview.settings
  70. DEPS
  71. DIR_METADATA
  72. LICENSE
  73. LICENSE.chromium_os
  74. OWNERS
  75. PRESUBMIT.py
  76. PRESUBMIT_test.py
  77. PRESUBMIT_test_mocks.py
  78. README.md
  79. WATCHLISTS
README.md

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure.

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.

If you found a bug, please file it at https://crbug.com/new.