Skip to content

Commit 0dee0e6

Browse files
mhorowitzfacebook-github-bot
authored andcommitted
Look up HostObject computed properties on the right object in the prototype chain.
Summary: The change in the hermes repository fixes the security vulnerability CVE-2020-1911. This vulnerability only affects applications which allow evaluation of uncontrolled, untrusted JavaScript code not shipped with the app, so React Native apps will generally not be affected. This revision includes a test for the bug. The test is generic JSI code, so it is included in the hermes and react-native repositories. Changelog: [Internal] Reviewed By: tmikov Differential Revision: D23322992 fbshipit-source-id: 4e88c974afe1ad33a263f9cac03e9dc98d33649a
1 parent 15e2ee3 commit 0dee0e6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ReactCommon/jsi/jsi/test/testlib.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,23 @@ TEST_P(JSITest, HostObjectTest) {
394394
.getBool());
395395
}
396396

397+
TEST_P(JSITest, HostObjectProtoTest) {
398+
class ProtoHostObject : public HostObject {
399+
Value get(Runtime& rt, const PropNameID&) override {
400+
return String::createFromAscii(rt, "phoprop");
401+
}
402+
};
403+
404+
rt.global().setProperty(
405+
rt,
406+
"pho",
407+
Object::createFromHostObject(rt, std::make_shared<ProtoHostObject>()));
408+
409+
EXPECT_EQ(
410+
eval("({__proto__: pho})[Symbol.toPrimitive]").getString(rt).utf8(rt),
411+
"phoprop");
412+
}
413+
397414
TEST_P(JSITest, ArrayTest) {
398415
eval("x = {1:2, '3':4, 5:'six', 'seven':['eight', 'nine']}");
399416

0 commit comments

Comments
 (0)