Missing status checks in AddWeightedPathSegLists and SVGPathSegListSMILType::Interpolate cause memory-safety bugs
- Fixed in 26 days
- Paid in 31 days
- Disclosed after 26 days
AddWeightedPathSegLists (dom\svg\SVGPathSegListSMILType.cpp) calls SetLength on a FallibleTArray without checking the result in release builds. If FF is almost out of memory for some other reason and/or a page includes code that invokes this function with an SVG path with an unusually-large number of segments, SetLength could invisibly fail. AddWeightedPathSegLists would then overwrite memory that it doesn't own.
There is also a similar bug in SVGPathSegListSMILType::Interpolate in the same module.
The bugs are latent because the functions in which they occur don't seem to be called by anything in the codebase (please verify).
Details:
--------
The bug in AddWeightedPathSegLists is in lines 267-68: The assert message on line 268 is misleading...
236:static void
237:AddWeightedPathSegLists(double aCoeff1, const SVGPathDataAndInfo& aList1,
238: double aCoeff2, const SVGPathDataAndInfo& aList2,
239: SVGPathDataAndInfo& aResult)
...
266: if (aResult.IsIdentity()) {
267: DebugOnly<bool> success = aResult.SetLength(aList2.Length());
268: MOZ_ASSERT(success, "infallible nsTArray::SetLength should succeed");
269: aResult.SetElement(aList2.Element()); // propagate target element info!
270: }
271:
272: SVGPathDataAndInfo::iterator resultIter = aResult.begin();
273:
274: while ((!iter1 || iter1 != end1) &&
275: iter2 != end2) {
276: AddWeightedPathSegs(aCoeff1, iter1,
277: aCoeff2, iter2,
278: resultIter);
...because SVGPathDataAndInfo::SetLength actually resizes a FallibleTArray (dom\svg\SVGPathData.h):
239: class SVGPathDataAndInfo final : public SVGPathData
240: {
...
283: using SVGPathData::SetLength;
284: using SVGPathData::begin;
...
293: };
76: class SVGPathData
77: {
...
204: bool SetLength(uint32_t aLength) {
205: return mData.SetLength(aLength);
206: }
...
224: iterator begin() { return mData.Elements(); }
...
227: FallibleTArray<float> mData;
228:};
So if SetLength fails, SVGPathSegListSMILType.cpp line 272 derives an iterator to memory that it has no right to use, and the function call on lines 276-78 writes into that memory.
This bug is still present in 9/10/2015's Aurora (http://hg.mozilla.org/releases/mozilla-aurora/file/136110a23c39/dom/svg/SVGPathSegListSMILType.cpp , http://hg.mozilla.org/releases/mozilla-aurora/file/136110a23c39/dom/svg/SVGPathData.h ).
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 critical-severity security bug in SVG. Mozilla made it public on 7 October 2015 as CVE-2015-7199.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.