Skip to content
Memory corruption Disclosed report CVE-2015-7178

Missing bounds check causes memory-safety bug in ProgramBinary::linkAttributes

q1 Follow

Originally disclosed on Mozilla

  • Fixed in 26 days
  • Paid in 28 days
  • Disclosed after 26 days
Text
Created attachment 8641769
HTML and JS files. Extract and use as in note [1].

ProgramBinary::linkAttributes (gfx\angle\src\libGLESv2\ProgramBinary.cpp) does not bounds-check accesses to its mShaderAttributes array. Because this is a fixed-length array (gfx\angle\src\libGLESv2\renderer\ProgramImpl.h):

122:    sh::Attribute mShaderAttributes[gl::MAX_VERTEX_ATTRIBS];

where

17:     MAX_VERTEX_ATTRIBS = 16,

(gfx\angle\src\libGLESv2\Constants.h),

and because of the absence of bounds checks elsewhere, it is possible to create more shader attributes than mShaderAttributes can accommodate. This causes ProgramBinary::linkAttributes to write data beyond the end of mShaderAttributes (and indeed beyond the end of *mProgram) into whatever other heap object lives there.

Attached is a proof-of-concept WebGL program [1] that causes this overwriting.

The best way to observe it is to attach a debugger to FF debug 39.0, set a breakpoint on ProgramBinary::linkAttributes:

683:        mProgram->getShaderAttributes()[attributeIndex] = attribute;

and observe how attributesIndex gets incremented beyond the end of mShaderAttributes. You can then open a memory window to ((char *) &mProgram->mShaderAttributes) + sizeof (mProgram->mShaderAttributes) and step into the assignment. In my limited testing, the memory beyond the end of mShaderAttributes contains data that makes line 50 of ShaderVariable::operator= (gfx\angle\src\compiler\translator\ShaderVars.cpp) fail with a write-to-nullptr:

45: ShaderVariable &ShaderVariable::operator=(const ShaderVariable &other)
46: {
47:     type = other.type;
48:     precision = other.precision;
49:     name = other.name;
50:     mappedName = other.mappedName;
51:     arraySize = other.arraySize;
52:     staticUse = other.staticUse;
53:     fields = other.fields;
54:     structName = other.structName;
55:     return *this;
56: }

after lines 47-49 have written 5 or so DWORDs into the unowned memory. However, the unowned memory probably can contain anything at all, and if the memory occupied by, e.g., mappedName were to contain a valid pointer to heap memory, the assignment on line 50 would free it, causing havoc down the road.

The proof-of-concept also crashes 40.0b8 Win64 release, in which it writes about 10 DWORDs of data into the unowned memory before crashing. I have not yet examined whether it frees any unowned memory before crashing.

[1] See attached HTML and JS; extract and name the JS "poc.js" and put it in the same folder as the extracted HTML, then load the HTML.

The original report as published on Mozilla's Bugzilla, by q1. 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.

What is known

A high-severity memory corruption bug in Graphics. Mozilla made it public on 26 August 2015 as CVE-2015-7178.

About 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.

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

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 q1

View all

71 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.