Skip to content
Memory corruption Disclosed report Advanced CVE-2019-17017

BigInt and Object type confusion vulnerability exploitable via XSLTProcessor setParameter method

A type confusion flaw in Firefox's XSLTProcessor.setParameter method allows a BigInt value to be treated as an object, leading to a crash. An attacker could potentially exploit this to execute arbitrary code.

bo13oy Follow

Originally disclosed on Mozilla

  • Fixed in 20 days
  • Paid in 26 days
  • Disclosed after 20 days

Created attachment 9115128 pocs.zip

Hello,

There is a Type confusion between BigInt and Object Vulnerability in Firefox.

Tested Platforms:

1)Ubuntu 64-bit 16.04.3 (Memory 8G)+ firefox release version nightly 71.0 (64-bit)

When using firefox to load the poc.html, it manifests itself in the form of the following crash:

---cut---

[----------------------------------registers-----------------------------------] RAX: 0x7ffc8dd921f0 --> 0x2ac4b96192040 RBX: 0xac3e674300ed4900 RCX: 0xac3e674300ed4900 RDX: 0x7ffc8dd9208c --> 0x8dd921f000007ffc RSI: 0x7ffc8dd921f0 --> 0x2ac4b96192040 RDI: 0x2ac4b96192040 RBP: 0x7ffc8dd91fb0 --> 0x7ffc8dd91fd0 --> 0x7ffc8dd91ff0 --> 0x7ffc8dd92040 --> 0x7ffc8dd920a0 --> 0x7ffc8dd920f0 (--> ...) RSP: 0x7ffc8dd91fb0 --> 0x7ffc8dd91fd0 --> 0x7ffc8dd91ff0 --> 0x7ffc8dd92040 --> 0x7ffc8dd920a0 --> 0x7ffc8dd920f0 (--> ...) RIP: 0x7fdb2df3367c (<js::GetObjectClass(JSObject const*)+12>: mov rdi,QWORD PTR [rdi]) R8 : 0xac3e674300ed4900 R9 : 0x0 R10: 0x7ffc8dd91c08 --> 0x7ffc8dd92410 --> 0x34a50a6004a0 --> 0x2c4b9615d610 --> 0x7fdb39940c70 --> 0x7fdb37415616 (--> ...) R11: 0xac3e674300ed4900 R12: 0x8 R13: 0x7fdb296bc098 --> 0xfff9800000000000 R14: 0x7fdb2a05c601 --> 0x2560000000b R15: 0x1 EFLAGS: 0x10206 (carry PARITY adjust zero sign trap INTERRUPT direction overflow) [-------------------------------------code-------------------------------------] 0x7fdb2df33671 <js::GetObjectClass(JSObject const*)+1>: mov rbp,rsp 0x7fdb2df33674 <js::GetObjectClass(JSObject const*)+4>: mov QWORD PTR [rbp-0x8],rdi 0x7fdb2df33678 <js::GetObjectClass(JSObject const*)+8>: mov rdi,QWORD PTR [rbp-0x8] => 0x7fdb2df3367c <js::GetObjectClass(JSObject const*)+12>: mov rdi,QWORD PTR [rdi] 0x7fdb2df3367f <js::GetObjectClass(JSObject const*)+15>: mov rax,QWORD PTR [rdi] 0x7fdb2df33682 <js::GetObjectClass(JSObject const*)+18>: pop rbp 0x7fdb2df33683 <js::GetObjectClass(JSObject const*)+19>: ret
0x7fdb2df33684: nop WORD PTR cs:[rax+rax1+0x0] [------------------------------------stack-------------------------------------] 0000| 0x7ffc8dd91fb0 --> 0x7ffc8dd91fd0 --> 0x7ffc8dd91ff0 --> 0x7ffc8dd92040 --> 0x7ffc8dd920a0 --> 0x7ffc8dd920f0 (--> ...) 0008| 0x7ffc8dd91fb8 --> 0x7fdb2df56165 (<js::IsProxy(JSObject const)+21>: mov rdi,rax) 0016| 0x7ffc8dd91fc0 --> 0x10000002a1a6c78 0024| 0x7ffc8dd91fc8 --> 0x2ac4b96192040 0032| 0x7ffc8dd91fd0 --> 0x7ffc8dd91ff0 --> 0x7ffc8dd92040 --> 0x7ffc8dd920a0 --> 0x7ffc8dd920f0 --> 0x7ffc8dd92240 (--> ...) 0040| 0x7ffc8dd91fd8 --> 0x7fdb34b04515 (<JSObject::isjs::ProxyObject() const+21>: and al,0x1) 0048| 0x7ffc8dd91fe0 --> 0x7ffc8dd92208 --> 0xfffcac4b96192040 0056| 0x7ffc8dd91fe8 --> 0x2ac4b96192040 [------------------------------------------------------------------------------] Legend: code, data, rodata, value Stopped reason: SIGSEGV 0x00007fdb2df3367c in js::GetObjectClass (obj=0x2ac4b96192040) at /home/bo13oy/Desktop/firefox_build/mozilla-release/objdir-frontend/dist/include/jsfriendapi.h:613 613 return reinterpret_cast<const shadow::Object*>(obj)->group->clasp; gdb-peda$

gdb-peda$ bt #0 0x00007fdb2df3367c in js::GetObjectClass (obj=0x2ac4b96192040) at /home/bo13oy/Desktop/firefox_build/mozilla-release/objdir-frontend/dist/include/jsfriendapi.h:613 #1 0x00007fdb2df56165 in js::IsProxy (obj=0x2ac4b96192040) at /home/bo13oy/Desktop/firefox_build/mozilla-release/objdir-frontend/dist/include/js/Proxy.h:381 #2 0x00007fdb34b04515 in JSObject::isjs::ProxyObject (this=0x2ac4b96192040) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/vm/ProxyObject.h:148 #3 0x00007fdb34c7c815 in js::GetBuiltinClass (cx=0x7fdb2a02a000, obj=..., cls=0x7ffc8dd9208c) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/jsfriendapi.cpp:264 #4 0x00007fdb34c3ef0e in IsGivenTypeObject (cx=0x7fdb2a02a000, obj=..., typeClass=@0x7ffc8dd920d4: js::ESClass::Array, isType=0x7ffc8dd921c7) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/jsapi.cpp:3124 #5 0x00007fdb34c3ee85 in JS_IsArrayObject (cx=0x7fdb2a02a000, obj=..., isArray=0x7ffc8dd921c7) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/jsapi.cpp:3134 #6 0x00007fdb2f170d70 in XPCArrayHomogenizer::GetTypeForArray (cx=0x7fdb2a02a000, array=..., length=0xc, resultType=0x7ffc8dd923d8, resultID=0x7ffc8dd92490) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/xpconnect/src/XPCVariant.cpp:191 #7 0x00007fdb2f170787 in XPCVariant::InitializeData (this=0x7fdb2a1a6c40, cx=0x7fdb2a02a000) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/xpconnect/src/XPCVariant.cpp:336 #8 0x00007fdb2f16fe93 in XPCVariant::newVariant (cx=0x7fdb2a02a000, aJSVal=...) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/xpconnect/src/XPCVariant.cpp:105 #9 0x00007fdb2f1946b1 in nsXPConnect::JSToVariant (this=0x7fdb2b91ed00, ctx=0x7fdb2a02a000, value=..., _retval=0x7ffc8dd92638) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/xpconnect/src/nsXPConnect.cpp:867 #10 0x00007fdb3232bad3 in txMozillaXSLTProcessor::SetParameter (this=0x7fdb29148280, aCx=0x7fdb2a02a000, aNamespaceURI=..., aLocalName=..., aValue=..., aRv=...) at /home/bo13oy/Desktop/firefox_build/mozilla-release/dom/xslt/xslt/txMozillaXSLTProcessor.cpp:1114 #11 0x00007fdb30c7f784 in mozilla::dom::XSLTProcessor_Binding::setParameter (cx=0x7fdb2a02a000, obj=..., self=0x7fdb29148280, args=...) at /home/bo13oy/Desktop/firefox_build/mozilla-release/objdir-frontend/dom/bindings/XSLTProcessorBinding.cpp:246 #12 0x00007fdb310596e8 in mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions> ( cx=0x7fdb2a02a000, argc=0x3, vp=0x7ffc8dd93830) at /home/bo13oy/Desktop/firefox_build/mozilla-release/dom/bindings/BindingUtils.cpp:3198 #13 0x00007fdb34b04160 in CallJSNative (cx=0x7fdb2a02a000, native=0x7fdb31059040 <mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*)>, reason=js::CallReason::Call, args=...) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/vm/Interpreter.cpp:458 #14 js::InternalCallOrConstruct (cx=0x7fdb2a02a000, args=..., construct=js::NO_CONSTRUCT, reason=js::CallReason::Call) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/vm/Interpreter.cpp:550 #15 0x00007fdb34b04e83 in InternalCall (cx=0x7fdb2a02a000, args=..., reason=js::CallReason::Call) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/vm/Interpreter.cpp:619 #16 0x00007fdb34b04cff in js::CallFromStack (cx=0x7fdb2a02a000, args=...) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/vm/Interpreter.cpp:623 #17 0x00007fdb355002c1 in js::jit::DoCallFallback (cx=0x7fdb2a02a000, frame=0x7ffc8dd938c8, stub=0x7fdb28846590, argc=0x3, vp=0x7ffc8dd93830, res=...) at /home/bo13oy/Desktop/firefox_build/mozilla-release/js/src/jit/BaselineIC.cpp:2938 #18 0x00003d32d56df798 in ?? () #19 0x00007ffc8dd98100 in ?? () #20 0x00007ffc8dd937f0 in ?? () #21 0xfff9800000000000 in ?? () #22 0x00007fdb374024c8 in js::jit::vmFunctions () from /home/bo13oy/Desktop/firefox_build/mozilla-release/objdir-frontend/dist/bin/libxul.so

---cut---

Here's a snippet of the method. -----source code -------

// static

bool XPCArrayHomogenizer::GetTypeForArray(JSContext* cx, HandleObject array, uint32_t length, nsXPTType* resultType, nsID* resultID) { Type state = tUnk; Type type;

RootedValue val(cx); RootedObject jsobj(cx); for (uint32_t i = 0; i < length; i++) { if (!JS_GetElement(cx, array, i, &val)) { return false; }

if (val.isInt32()) {
  type = tInt;
} else if (val.isDouble()) {
  type = tDbl;
} else if (val.isBoolean()) {
  type = tBool;
}
else if (val.isUndefined() || val.isSymbol()) {
  state = tVar;
  break;
} else if (val.isNull()) {
  type = tNull;
} else if (val.isString()) {
  type = tStr;
}

/***************** add patch sample code start ********************/

else if(val.isBigInt()) //patch 
{
	type = tBigInt; 
}  

/*****************add patch sample code end ********************/

else {
  MOZ_ASSERT(val.isObject(), "invalid type of jsval!");
  jsobj = &val.toObject();

  bool isArray;
  if (!JS_IsArrayObject(cx, jsobj, &isArray)) {
    return false;
  }

  if (isArray) {
    type = tArr;
  } else if (xpc::JSValue2ID(cx, val)) {
    type = tID;
  } else {
    type = tISup;
  }
}

...... -----source code -------

Thank you, bo13oy Qihoo 360 Vulcan Team.

The original report as published on Mozilla's Bugzilla, by bo13oy. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The XPCArrayHomogenizer::GetTypeForArray function does not handle BigInt values, causing them to fall through to the object case and leading to type confusion.

Impact

An attacker could potentially execute arbitrary code by exploiting this type confusion, though the report only demonstrates a crash.

What the attacker needed

Victim uses Firefox; victim loads a malicious page

The fix

The code should be patched to handle BigInt values explicitly, as shown in the sample patch.

How it was found

  1. Load the provided poc.html in Firefox.
  2. The browser crashes with a segmentation fault.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This report describes a bug in the Firefox browser where a special type of number (BigInt) is mistakenly handled as if it were an object. When a specific method is called with this value, the browser crashes, and in the wrong hands, this could let an attacker run their own code on your computer.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by bo13oy

View all

10 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.