|
|
Chromium Code Reviews
Description[Extensions Bindings] Avoid passing the event filter to JS
Currently, in JS bindings, we pass the event filter to JS, and then pass
it back to C++ to find matching event listeners. This can cause problems
because the object could be tweaked by monkey-patching, and we aren't
correctly checking.
Instead of updating the checks to safely interact with the object, just
avoid passing it to JS altogether. Instead, pass the ids of the relevant
listeners directly to JS. This avoids the security issue and is also
more performant.
Add a regression test.
BUG=702946
Review-Url: https://codereview.chromium.org/2924683002
Cr-Commit-Position: refs/heads/master@{#478742}
Committed: https://chromium.googlesource.com/chromium/src/+/229f3b010af25c9bc38c01cfc7c403d8b5fdecf0
Patch Set 1 : rebase #Patch Set 2 : remove extra '.' #
Total comments: 10
Patch Set 3 : lazyboy's + jbroman's #Patch Set 4 : rebase #
Messages
Total messages: 42 (35 generated)
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
Description was changed from ========== bindings fix BUG= ========== to ========== [Extensions Bindings] Avoid passing the event filter to JS Currently, in JS bindings, we pass the event filter to JS, and then pass it back to C++ to find matching event listeners. This can cause problems because the object could be tweaked by monkey-patching, and we aren't correctly checking. Instead of updating the checks to safely interact with the object, just avoid passing it to JS altogether. Instead, pass the ids of the relevant listeners directly to JS. This avoids the security issue and is also more performant. Add a regression test. BUG=702946 ==========
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Patchset #1 (id:1) has been deleted
Patchset #1 (id:20001) has been deleted
Patchset #2 (id:60001) has been deleted
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #1 (id:40001) has been deleted
rdevlin.cronin@chromium.org changed reviewers: + jbroman@chromium.org, lazyboy@chromium.org
Mind taking a look? Not strictly related to native bindings (and in fact automatically fixed when we convert), but probably best to not wait for that.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
lgtm once jbroman@'s happy. https://codereview.chromium.org/2924683002/diff/100001/chrome/test/data/exten... File chrome/test/data/extensions/api_test/bindings/event_filter/background.js (right): https://codereview.chromium.org/2924683002/diff/100001/chrome/test/data/exten... chrome/test/data/extensions/api_test/bindings/event_filter/background.js:5: Object.defineProperty(Object.prototype, 'windowExposedByDefault', nit: put a comment about the intent of this custom getter. https://codereview.chromium.org/2924683002/diff/100001/chrome/test/data/exten... chrome/test/data/extensions/api_test/bindings/event_filter/background.js:6: {enumerable: true, get() { return 'hahaha'; }}); nit: remove one of the two spaces before "return" https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... File extensions/renderer/event_bindings.cc (right): https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... extensions/renderer/event_bindings.cc:144: CHECK(array->CreateDataProperty(context, i++, v8::Integer::New(isolate, id)) I'll defer to Jeremy for this one.
lgtm https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... File extensions/renderer/event_bindings.cc (right): https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... extensions/renderer/event_bindings.cc:130: EventFilter& event_filter = g_event_filter.Get(); nit: const&? (use of a singleton across threads like this is kinda scary, but non-const ref makes me thing this is going to mutate) https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... extensions/renderer/event_bindings.cc:144: CHECK(array->CreateDataProperty(context, i++, v8::Integer::New(isolate, id)) On 2017/06/10 at 00:22:08, lazyboy wrote: > I'll defer to Jeremy for this one. This looks good to me. https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... extensions/renderer/event_bindings.cc:182: std::vector<v8::Local<v8::Value>> arguments; super-nit: could at least reserve the buffer here, since it's of constant size. Or this could just be an array on the stack: v8::Local<v8::Value> args[] = { gin::StringToSymbol(context->isolate(), event_name), content::V8ValueConverter::create()->ToV8Value(event_args, context->v8_context()), listener_ids }; context->module_system()->CallModuleMethodSafe( kEventBindings, "dispatchEvent", arraysize(args), args); (don't feel obligated as it's arguably premature optimization, but to my eyes it's also slightly simpler)
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device-xcode-...) mac_chromium_compile_dbg_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_comp...) mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
https://codereview.chromium.org/2924683002/diff/100001/chrome/test/data/exten... File chrome/test/data/extensions/api_test/bindings/event_filter/background.js (right): https://codereview.chromium.org/2924683002/diff/100001/chrome/test/data/exten... chrome/test/data/extensions/api_test/bindings/event_filter/background.js:5: Object.defineProperty(Object.prototype, 'windowExposedByDefault', On 2017/06/10 00:22:08, lazyboy wrote: > nit: put a comment about the intent of this custom getter. Done. https://codereview.chromium.org/2924683002/diff/100001/chrome/test/data/exten... chrome/test/data/extensions/api_test/bindings/event_filter/background.js:6: {enumerable: true, get() { return 'hahaha'; }}); On 2017/06/10 00:22:08, lazyboy wrote: > nit: remove one of the two spaces before "return" Good catch! Done. https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... File extensions/renderer/event_bindings.cc (right): https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... extensions/renderer/event_bindings.cc:130: EventFilter& event_filter = g_event_filter.Get(); On 2017/06/12 15:48:51, jbroman wrote: > nit: const&? (use of a singleton across threads like this is kinda scary, but > non-const ref makes me thing this is going to mutate) Done. https://codereview.chromium.org/2924683002/diff/100001/extensions/renderer/ev... extensions/renderer/event_bindings.cc:182: std::vector<v8::Local<v8::Value>> arguments; On 2017/06/12 15:48:51, jbroman wrote: > super-nit: could at least reserve the buffer here, since it's of constant size. > Or this could just be an array on the stack: > > v8::Local<v8::Value> args[] = { > gin::StringToSymbol(context->isolate(), event_name), > content::V8ValueConverter::create()->ToV8Value(event_args, > context->v8_context()), > listener_ids > }; > context->module_system()->CallModuleMethodSafe( > kEventBindings, "dispatchEvent", arraysize(args), args); > > (don't feel obligated as it's arguably premature optimization, but to my eyes > it's also slightly simpler) sgtm. Little more complicated since we have to pull out V8ValueConverter::create() (that returns a raw ptr, not a unique ptr - that's annoyed me enough that I'll investigate converting), but overall I'd agree it's a little simpler. Thanks for the suggestion!
The CQ bit was checked by rdevlin.cronin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by rdevlin.cronin@chromium.org
The CQ bit was checked by rdevlin.cronin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from lazyboy@chromium.org, jbroman@chromium.org Link to the patchset: https://codereview.chromium.org/2924683002/#ps140001 (title: "rebase")
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch.
Bot data: {"patchset_id": 140001, "attempt_start_ts": 1497298979822100,
"parent_rev": "39fbf000fd660ce059a62d68b02f51cc0384ca0c", "commit_rev":
"229f3b010af25c9bc38c01cfc7c403d8b5fdecf0"}
Message was sent while issue was closed.
Description was changed from ========== [Extensions Bindings] Avoid passing the event filter to JS Currently, in JS bindings, we pass the event filter to JS, and then pass it back to C++ to find matching event listeners. This can cause problems because the object could be tweaked by monkey-patching, and we aren't correctly checking. Instead of updating the checks to safely interact with the object, just avoid passing it to JS altogether. Instead, pass the ids of the relevant listeners directly to JS. This avoids the security issue and is also more performant. Add a regression test. BUG=702946 ========== to ========== [Extensions Bindings] Avoid passing the event filter to JS Currently, in JS bindings, we pass the event filter to JS, and then pass it back to C++ to find matching event listeners. This can cause problems because the object could be tweaked by monkey-patching, and we aren't correctly checking. Instead of updating the checks to safely interact with the object, just avoid passing it to JS altogether. Instead, pass the ids of the relevant listeners directly to JS. This avoids the security issue and is also more performant. Add a regression test. BUG=702946 Review-Url: https://codereview.chromium.org/2924683002 Cr-Commit-Position: refs/heads/master@{#478742} Committed: https://chromium.googlesource.com/chromium/src/+/229f3b010af25c9bc38c01cfc7c4... ==========
Message was sent while issue was closed.
Committed patchset #4 (id:140001) as https://chromium.googlesource.com/chromium/src/+/229f3b010af25c9bc38c01cfc7c4...
Message was sent while issue was closed.
A revert of this CL (patchset #4 id:140001) has been created in https://codereview.chromium.org/2936673004/ by rdevlin.cronin@chromium.org. The reason for reverting is: New test seems to be flaky on Mac... https://luci-logdog.appspot.com/v/?s=chromium%2Fbb%2Fchromium.mac%2FMac10.9_T.... |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
