+dcheng@ as another third_party/blink/tools/blinkpy/presubmit/audit_non_blink_usage.py OWNER.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Kyouhei HorizumiSome tests are failing on bots because the failing tests creates 100 workers
third_party/blink/web_tests/external/wpt/hr-time/resources/clamped-time-origin.js
and this CL throttles them.It's nice it means the throttling is working -- maybe tweaking the throttling limit to e.g. 128 (or adjust the test to create e.g. 50 workers, while I haven't checked for the context for "100" workers -- just random number, or should be sufficient large to deflake?) might fix the failure.
Kyouhei HorizumiI'll first try increasing the limit to 128 and check whether it still effectively blocks the attack using my tech support scam PoC.
Hiroshige HayashizakiI confirmed locally that the affected WPT tests TIMEOUT with a limit of 64, but PASS with 128.
I also tested my tech support scam PoC in a Debug build with the limit set to 128.
When triggered from `beforeunload`, navigating back or closing the tab still works, with only about 0.5s of additional delay compared to 64.
However, in other scenarios such as reloading, the hung renderer dialog appears, but terminating the page takes significantly longer. Some example measurements:
- 64 / 5s: ~8s
- 128 / 5s: ~20s
- 128 / 10s: ~7s
(These are only example measurements from a Debug build, so I'm not sure how much this affects Release builds. The termination time can also increase significantly if the dialog is left open, as noted below.)
@hiro...@chromium.org I think increasing the limit to 128 makes sense for WPT compatibility, but perhaps we should also extend the time window from 5s to 10s to reduce the load. What do you think?
---
**Separately, one additional observation:**
Even while the hung renderer dialog is displayed, the page can continue creating Workers until the user clicks a button.
I observed that leaving the dialog open for about 5 minutes eventually makes the entire browser severely unresponsive.
This might be related to the lack of an overall limit on the number of active Workers, though I haven't confirmed the cause.
I can't think of a practical way to exploit this at the moment, and it's outside the scope of this CL, but it may be worth filing a separate issue to document the behavior.
Kyouhei HorizumiOK, let's keep the current limit of this CL and instead adjust the WPT (e.g. 100 -> 50, in a separate CL).
Kyouhei HorizumiSounds good! For now, I've confirmed that the WPT passes locally after reducing the number of Workers from 100 to 50.
Kyouhei HorizumiI've created a separate CL for the WPT tests:
https://chromium-review.googlesource.com/c/chromium/src/+/8714620
Done
Kyouhei Horizumi@jap...@chromium.org Hi Nate, would you mind taking another look at the latest patchset? I've updated the CL to address Hiroshige's review comments (changes since patchset 5).
@jap...@chromium.org Hi Nate, Hiroshige is back and has assigned another reviewer, so no need to take another look. Thanks anyway!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
How much do we really need to protect against this? There many other ways to DoS the browser process. This is a fair amount of complexity for something that only offers fairly limited protection in the end.
int count = 0;Making this the second field will reduce the amount of padding in the struct overall.
using WorkerCreationBursts = base::flat_map<url::Origin, WorkerCreationBurst>;Blink maps should be using blink::HashMap.
DEFINE_THREAD_SAFE_STATIC_LOCAL(WorkerCreationBursts, bursts, ());This should use GUARDED_BY() if we keep it.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
How much do we really need to protect against this? There many other ways to DoS the browser process. This is a fair amount of complexity for something that only offers fairly limited protection in the end.
@dch...@chromium.org Thanks for pointing this out!
I'd like to clarify what you mean by "fairly limited protection."
A. Do you mean that, because there are many other ways to DoS the browser process, mitigating only this Worker-based path provides limited protection against the broader problem (including support-scam scenarios), so this may not be worth mitigating individually?
B. Or do you agree that this particular issue is worth mitigating, but think the current approach is too complex relative to the protection it provides?
I think the next direction would be quite different depending on which you mean.
Making this the second field will reduce the amount of padding in the struct overall.
Done
using WorkerCreationBursts = base::flat_map<url::Origin, WorkerCreationBurst>;Blink maps should be using blink::HashMap.
Done. Thanks for the suggestion.
DEFINE_THREAD_SAFE_STATIC_LOCAL(WorkerCreationBursts, bursts, ());This should use GUARDED_BY() if we keep it.
Done.
I used `AtomicStringTable` as a reference for the locking pattern.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Kyouhei HorizumiHow much do we really need to protect against this? There many other ways to DoS the browser process. This is a fair amount of complexity for something that only offers fairly limited protection in the end.
@dch...@chromium.org Thanks for pointing this out!
I'd like to clarify what you mean by "fairly limited protection."
A. Do you mean that, because there are many other ways to DoS the browser process, mitigating only this Worker-based path provides limited protection against the broader problem (including support-scam scenarios), so this may not be worth mitigating individually?
B. Or do you agree that this particular issue is worth mitigating, but think the current approach is too complex relative to the protection it provides?
I think the next direction would be quite different depending on which you mean.
I found the 2018 discussion around the IPC-flooding mitigation that became `NavigationRateLimiter`:
https://chromium-review.googlesource.com/c/1230067
In particular, your concern there about accumulating technical debt through API-specific IPC-flooding mitigations helped me understand your concern here better.
When I have some time, I'll compare the current Worker mitigation with `NavigationRateLimiter` and explain why the Worker case needs additional complexity.
A generic IPC-level solution would of course be preferable, but that does not seem to be the current direction:
https://issues.chromium.org/issues/40086182#comment21
Kyouhei HorizumiHow much do we really need to protect against this? There many other ways to DoS the browser process. This is a fair amount of complexity for something that only offers fairly limited protection in the end.
Kyouhei Horizumi@dch...@chromium.org Thanks for pointing this out!
I'd like to clarify what you mean by "fairly limited protection."
A. Do you mean that, because there are many other ways to DoS the browser process, mitigating only this Worker-based path provides limited protection against the broader problem (including support-scam scenarios), so this may not be worth mitigating individually?
B. Or do you agree that this particular issue is worth mitigating, but think the current approach is too complex relative to the protection it provides?
I think the next direction would be quite different depending on which you mean.
I found the 2018 discussion around the IPC-flooding mitigation that became `NavigationRateLimiter`:
https://chromium-review.googlesource.com/c/1230067In particular, your concern there about accumulating technical debt through API-specific IPC-flooding mitigations helped me understand your concern here better.
When I have some time, I'll compare the current Worker mitigation with `NavigationRateLimiter` and explain why the Worker case needs additional complexity.
A generic IPC-level solution would of course be preferable, but that does not seem to be the current direction:
https://issues.chromium.org/issues/40086182#comment21
@dch...@chromium.org Would the following explanation address your concerns about the complexity of this CL?
### Why this CL is necessary
I don't think a browser hang alone necessarily justifies a Chromium fix.
However, tech support scams have caused substantial financial losses, and this particular attack technique has been used in such scams for over a year. The attack is also extremely easy to execute (see [Issue 519762183](https://issues.chromium.org/issues/519762183) for details).
It can also prevent existing timeouts and hang detection mechanisms from working properly.
### Why a map is necessary
`NavigationRateLimiter` is relatively simple because it stores a counter in each Frame.
In contrast, this Worker creation limit needs to be enforced in the Renderer before sending IPCs to the Browser Process.
Since a single Renderer Process may contain multiple Origins, a process-wide limit could also restrict Worker creation from unrelated Origins.
Therefore, we use a map to maintain separate counters for each Origin.
### Why a Lock is necessary
Nested Workers run on separate threads, so synchronization is required to safely share the counters.
### Why Factory Client creation is deferred
Originally, the Factory Client was created in the DedicatedWorker constructor, which initiated communication with the Browser Process.
To avoid this IPC for rejected Workers, Factory Client creation has been deferred until first use.
Given a few other recent issues in this area, I think it's worth pursuing something here.
However, I'm wondering if we can do something simpler than maintaining per-origin tables. For pages, we prevent pages from having more than 1000 frames ever but we don't have something similar for workers.
Would it make sense to just have a process global counter for the number of live (dedicated?) workers? Firefox actually has this and sets it to `dom.workers.maxPerDomain`; I am wondering if setting it to something like 1024 would be "good enough" or if that's still too easy to hit a DoS condition.
Rationale for 1024: Firefox's default limit is 512; Chrome uses site isolation so having a per-process map is mostly a waste. Platforms which have weaker site isolation will have an easier time hitting this... but platforms with weaker site isolation have more resource limits too, so having the limit be process global kind of makes sense to me there too.
Another difference is Firefox queues dedicated workers when it hits the limit instead of throwing an exception; that's something we could consider here too.
@dch...@chromium.org Thank you for your feedback!
Would it make sense to just have a process global counter for the number of live (dedicated?) workers?
Regarding the process-wide limit, Hiroshige previously raised a concern about the potential side-channel attack surface in his Sep 17 comment:
https://chromium-review.googlesource.com/c/chromium/src/+/8313708/comment/cb9aa21f_73a66732/
Would this still be a concern with the proposed approach?
Sorry for the long delay here; I was asking around for opinions. While I would personally prefer a per-renderer approach, it's undeniably true that there is some cross-site info leaks, especially on Android.
I have two questions:
1. If we really want to keep this per-origin, I think we actually need to key on the precursor tuple. Otherwise, if you create a worker from data: URLs, those would never be throttled because the nonce would be unique (and the nonce is considered for the hash). Do you know of any other edge cases here? (Any origins that don't have a tuple at all would all be batched together, but I think that's unavoidable)
2. Is it hard to queue the request to run the worker if we hit the limit instead of trying to do this rate limit? What would be more preferable to the worker team?
Daniel, thank you for your reply. I think that's a very good point.
I think your proposed approach would also cover cases such as `data:` URLs, sandboxed iframes and popups, and CSP sandbox. One potential concern, though, is whether this could introduce a side channel, given that sandboxing may be used to intentionally isolate otherwise same-origin documents.
Not exactly an edge case, but a similar way to bypass the limit would be to create workers from iframes with different ports or (sub)domains. A similar issue was discussed by Mozilla in the past (see comments #6–#9):
https://bugzilla.mozilla.org/show_bug.cgi?id=1286895#c6
However, Mozilla appears to have chosen not to address this issue.
@hiro...@chromium.org What are your thoughts on question 2?