Lack of NULL check in OOM allows arbitrary write
- Fixed in 41 hours
- Paid in 2.4 years
- Disclosed after 41 hours
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13
Build Identifier: 3.6.13
When parsing MIME types (for example the "text/javascript" here: <script type="text/javascript">...) the following code in netwerk/mime/src/nsMIMEHeaderParamImpl.cpp is called:
function nsMIMEHeaderParamImpl::GetParameterInternal
158 // aParamName is empty. return the first (possibly) _unnamed_ 'parameter'
159 // For instance, return 'inline' in the following case:
160 // Content-Disposition: inline; filename=.....
161 if (!aParamName || !*aParamName)
162 {
163 for (; *str && *str != ';' && !nsCRT::IsAsciiSpace(*str); ++str)
164 ;
165 if (str == start)
166 return NS_ERROR_UNEXPECTED;
167 *aResult = (char *) nsMemory::Clone(start, (str - start) + 1);
168 (*aResult)[str - start] = '\0'; // null-terminate
169 NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
170 return NS_OK;
171 }
If the Clone call fails (returning NULL), then a null byte is still written to a controlled arbitrary address (0x0 + (str - start)) (where str-start is the length of the MIME type string.)
The address which could be written to does depend on the size of the string which is required to fail the Clone call, but it's still useably arbitrary (and, importantly, is an absolute address :-) ).
Lack of a mapped null page in modern OSes doesn't stop this, since 0x0 is never dereferenced here but a controlled, suitably large offset from it.
One possible exploitation scenario would be using this vuln to overwrite a refcount somewhere, setting it to 0 allowing a use-after-free.
I don't have a PoC unfortunately, I tried to knock up some suitable heap grooming JS but I couldn't get the right layout to trigger the Clone failing. That's not to say it's not possible!
The following html will hit the line of code though:
<html><head>
<script type="text/javascriptAAAAAAAAAAAA"> </script>
</head><body>x</body></html>
[obviously, you want a MUCH longer run of AAA's :-) ]
Reproducible: Couldn't Reproduce
Steps to Reproduce:
Exhaust memory suitably, document.write() a script tag with a long MIME type
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A security bug in Networking. Mozilla made it public on 23 February 2011 as CVE-2011-0078.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.