| Auto-Submit | +1 |
Danil SomsikovAndrey, wdyt? Is it worth it?
Resolved
Forcefully inject sessionId into child DevTools session messagesDanil SomsikovThe sessionId should already be put there by a child, so rather than injecting it, perhaps we can validate that a correct id is there and kill the child for bad IPC if it's not? Perhaps this would be both cheaper to implement and prevent a compromised renderer from trying other paths?
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
crdtp::cbor::CBORTokenizer tokenizer(crdtp::SpanFrom(message));That's a bit scary logic to have in such a place! In general, something using tokenizer so extensively belongs to crdtp (see `AppendString8EntryToCBORMap()` for example), but I think here we can do without dedicated low-level code and go with existent form of lazy patching. One option would be using a (Dispatchable)[https://source.chromium.org/chromium/chromium/src/+/main:third_party/inspector_protocol/crdtp/dispatch.h;bpv=1;bpt=1], another would be utilizing protocol core support for deferred messages, please see an [example here](https://source.chromium.org/chromium/chromium/src/+/main:v8/third_party/inspector_protocol/crdtp/protocol_core_test.cc;l=421).
message->data = mojo_base::BigBuffer(cbor);Is there a reason we're not doing this on the test side? The less test-specific code we have in the prod files the better. Let's just make it a trivial wrapper around DispatchProtocolNotification, i.e. `DispatchProtocolNotificationForTesting(blink::mojom::DevToolsMessagePtr message)`, and handle json-to-cbor business on the test side.
for (DevToolsSession* root_session : host->sessions_) {Can we just extract `DevToolsAgentHostImpl::GetSessionForTesting()` and move the rest of the logic to the test side? This would also let us get rid of on_before_dispatch, as you would be able to straigthen the logic on the test side:
if (!session) {Is there a meaningful scneario where we would hit that? Perhaps CHECK() instead?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
| Commit-Queue | +1 |
crdtp::cbor::CBORTokenizer tokenizer(crdtp::SpanFrom(message));That's a bit scary logic to have in such a place! In general, something using tokenizer so extensively belongs to crdtp (see `AppendString8EntryToCBORMap()` for example), but I think here we can do without dedicated low-level code and go with existent form of lazy patching. One option would be using a (Dispatchable)[https://source.chromium.org/chromium/chromium/src/+/main:third_party/inspector_protocol/crdtp/dispatch.h;bpv=1;bpt=1], another would be utilizing protocol core support for deferred messages, please see an [example here](https://source.chromium.org/chromium/chromium/src/+/main:v8/third_party/inspector_protocol/crdtp/protocol_core_test.cc;l=421).
Done
Is there a reason we're not doing this on the test side? The less test-specific code we have in the prod files the better. Let's just make it a trivial wrapper around DispatchProtocolNotification, i.e. `DispatchProtocolNotificationForTesting(blink::mojom::DevToolsMessagePtr message)`, and handle json-to-cbor business on the test side.
Done
for (DevToolsSession* root_session : host->sessions_) {Can we just extract `DevToolsAgentHostImpl::GetSessionForTesting()` and move the rest of the logic to the test side? This would also let us get rid of on_before_dispatch, as you would be able to straigthen the logic on the test side:
- find session
- get agent host and process host
- dispatch the message.
Done
Is there a meaningful scneario where we would hit that? Perhaps CHECK() instead?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
DevToolsSession* DevToolsSession::GetSessionById(const std::string& session_id) {So all the class methods are just trivial wrappers now? Can we get rid of the class and expose ....ForTesting() methods directly as we do elsewhere please?
crdtp::json::ConvertJSONToCBOR(crdtp::SpanFrom(json), &cbor);This one can certainly be done directly in the test.
Please note this is a rolled dependency, this needs to be landed upstream in crdtp and rolled here.
span<uint8_t> GetString8ValueFromMap(span<uint8_t> message,Please also provide a unit test for this.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
| Commit-Queue | +1 |
DevToolsSession* DevToolsSession::GetSessionById(const std::string& session_id) {So all the class methods are just trivial wrappers now? Can we get rid of the class and expose ....ForTesting() methods directly as we do elsewhere please?
Done
crdtp::json::ConvertJSONToCBOR(crdtp::SpanFrom(json), &cbor);This one can certainly be done directly in the test.
Done
Please note this is a rolled dependency, this needs to be landed upstream in crdtp and rolled here.
span<uint8_t> GetString8ValueFromMap(span<uint8_t> message,Please also provide a unit test for this.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
Hmm.. What happened to the tests though?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Auto-Submit | +1 |
Hmm.. What happened to the tests though?
Not sure, restored.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
46 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: content/browser/devtools/protocol/devtools_protocol_browsertest.cc
Insertions: 182, Deletions: 0.
The diff is too large to show. Please review the diff.
```
```
The name of the file: content/browser/devtools/devtools_session.h
Insertions: 1, Deletions: 2.
The diff is too large to show. Please review the diff.
```
```
The name of the file: content/browser/devtools/devtools_session.cc
Insertions: 52, Deletions: 39.
The diff is too large to show. Please review the diff.
```
Verify sessionId in incoming protocol messages from renderer
In DevTools "flattened" protocol mode, the renderer process is responsible
for including the correct sessionId in every protocol response and
notification. Previously, the browser process forwarded these messages to
the client without verification. A compromised renderer could deliberately
omit or spoof the sessionId, potentially allowing it to inject events into
the root session or other child sessions.
This CL fixes the vulnerability by having the browser process verify the
sessionId of every protocol message originating from a renderer-side
session. If the sessionId is missing, incorrect, or unexpectedly present
(in the case of the root session), the browser now considers the renderer
compromised and terminates it using bad_message::ReceivedBadMessage.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |