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

Limit untrusted allocations when decoding Vectors to 1MB #9699

Conversation

achristensen07
Copy link
Contributor

@achristensen07 achristensen07 commented Feb 6, 2023

23f2542

Limit untrusted allocations when decoding Vectors to 1MB
https://bugs.webkit.org/show_bug.cgi?id=251804

Reviewed by Kimmo Kinnunen.

257725@main introduced a performance improvement where we only allocate exactly as much
memory as we need once when decoding a Vector.  This is wonderful, but it introduced
allocation based on size from an untrusted source, making it so any message that sends
a Vector can be used to send a very large size_t and crash the other process.  In this
PR I get the best of both worlds: if the total allocation size is less that 1MB then we
do the fast and efficient thing, but if it is more than 1MB we do the safe thing.

* Source/WebKit/Platform/IPC/ArgumentCoders.h:

Canonical link: https://commits.webkit.org/259917@main

55a3be2

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style   πŸ›  ios   πŸ›  mac βœ… πŸ›  wpe   πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim   πŸ›  mac-AS-debug   πŸ›  gtk   πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac   πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios   πŸ§ͺ mac-wk1   πŸ§ͺ api-gtk
  πŸ›  tv   πŸ§ͺ mac-wk2
βœ… πŸ›  tv-sim   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch   πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge   πŸ›  watch-sim

@achristensen07 achristensen07 self-assigned this Feb 6, 2023
@achristensen07 achristensen07 added the WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore). label Feb 6, 2023
Copy link
Contributor

@kkinnunen-apple kkinnunen-apple left a comment

Choose a reason for hiding this comment

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

Good catch.

This should be testable, probably in some test similar to ArgumentCoderSpanTest but probably it needs a new fixture.. The test would be one where the encode encodes size_t big value and decoder decodes Vector and the test would test that decoder decodes nullopt instead of a crash.

@achristensen07 achristensen07 force-pushed the eng/Limit-untrusted-allocations-when-decoding-Vectors-to-1MB branch from 3c59e4d to 55a3be2 Compare February 6, 2023 21:31
@achristensen07 achristensen07 added the merge-queue Applied to send a pull request to merge-queue label Feb 6, 2023
https://bugs.webkit.org/show_bug.cgi?id=251804

Reviewed by Kimmo Kinnunen.

257725@main introduced a performance improvement where we only allocate exactly as much
memory as we need once when decoding a Vector.  This is wonderful, but it introduced
allocation based on size from an untrusted source, making it so any message that sends
a Vector can be used to send a very large size_t and crash the other process.  In this
PR I get the best of both worlds: if the total allocation size is less that 1MB then we
do the fast and efficient thing, but if it is more than 1MB we do the safe thing.

* Source/WebKit/Platform/IPC/ArgumentCoders.h:

Canonical link: https://commits.webkit.org/259917@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/Limit-untrusted-allocations-when-decoding-Vectors-to-1MB branch from 55a3be2 to 23f2542 Compare February 6, 2023 22:52
@webkit-commit-queue
Copy link
Collaborator

Committed 259917@main (23f2542): https://commits.webkit.org/259917@main

Reviewed commits have been landed. Closing PR #9699 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 23f2542 into WebKit:main Feb 6, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit Misc. For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore).
Projects
None yet
4 participants