Skip to content

Commit

Permalink
[CVE-2018-0768] Use of PropertyString and SubString,GetString() could…
Browse files Browse the repository at this point in the history
… lead to UAF - Individual
  • Loading branch information
Atul Katti authored and Thomas Moore (CHAKRA) committed Jan 5, 2018
1 parent 5c26851 commit 985a82f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Runtime/Library/WebAssemblyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,14 @@ Var WebAssemblyModule::EntryCustomSections(RecyclableObject* function, CallInfo

WebAssemblyModule * module = WebAssemblyModule::FromVar(args[1]);
Var customSections = nullptr;
// C++ compiler optimizations can optimize away the sectionName variable while still keeping a reference to the underlying
// character buffer sectionNameBuf. The character buffer itself is managed by the recycler; however; we may move past the
// start of the character buffer while doing the comparison in memcmp. If a GC happens during CreateArrayBuffer, the character
// buffer can get collected as we don't have a reference to the start of the buffer on the stack anymore. To avoid this we need
// to pin sectionName.
ENTER_PINNED_SCOPE(JavascriptString, sectionName);
sectionName = JavascriptConversion::ToString(sectionNameVar, scriptContext);

const char16* sectionNameBuf = sectionName->GetString();
charcount_t sectionNameLength = sectionName->GetLength();

Expand Down

0 comments on commit 985a82f

Please sign in to comment.