Open YiWen-y opened 3 years ago
Thank you for the demo. Could you please state what you are reporting, is that the shell running out of memory?
@ppenzin Chakra (both the release and debug version of V1.12.0.0-beta) is crashed when running the above PoC which had triggered a CVE of Safari. Maybe Chakra produces the same issue with Safari, which allows remote attackers to execute arbitrary code or cause a denial of service.
In addition, if the for
statement is replaced as follows:
for (let i = 0; i < 100; i++)
gun.trigger();
Chakra can run it without any exception.
Thanks for your reply. As @yeguixin said, this PoC comes from CVE_2017-2531. When I execute this PoC using the newer versions of other engines, v8 and SpiderMonkey throw a syntax error SyntaxError: too many function arguments
, JavascriptCore passes normally, only chakra outputs Aborted (core dumped)
, which causes the program to exit abnormally and there is no additional information.
@yeguixin @YiWen-y thank you for the explanation. I believe we catch the attempt to go out of bounds, integer overflow is detected:
#7 0x00007ffff30a3f49 in Math::DefaultOverflowPolicy () at ~/ChakraCore/lib/Common/Common/MathUtil.cpp:37
#8 0x00007ffff33f5ddf in UInt16Math::Inc<void ()>(unsigned short&, void (&)()) (lhs=@0x7fffffff605e: 0, overflowFn=@0x7ffff30a3f40: {void (void)} 0x7ffff30a3f40 <Math::DefaultOverflowPolicy()>)
at ~/ChakraCore/lib/Common/Common/UInt16Math.h:32
https://github.com/chakra-core/ChakraCore/blob/master/lib/Common/Common/UInt16Math.h#L32
We probably do need a better error message instead of a silent core dump.
@rhuanjl I feel like we had a discussion about overflow handling before. From purely practical point of view, I feel it is OK for this kind of situations to get overly vague errors as long as nothing dangerous can happen. What do you think?
Hmm - this is detecting that running this (technically valid) code would result in going out of memory leading to arbitrary results - so it's calling abort to stop it.
It may be possible to throw a nicer error if we can ensure we're catching it long before the out of memory.
But the current behaviour is basically by design.
Version:
ch version 1.12.0.0-beta
PoC:
Command 1:
Output 1:
Backtrace (using gdb debugging) 1:
Command 2:
Output 2:
Backtrace (using gdb debugging) 2: