Last Comment Bug 787722 - (CVE-2012-4188) Heap-buffer-overflow in Convolve3x3
: Heap-buffer-overflow in Convolve3x3
: csectype-bounds, sec-critical, testcase
Product: Core
Classification: Components
Component: SVG (show other bugs)
: Trunk
: All All
-- normal (vote)
: mozilla18
Assigned To: Jonathan Watt [:jwatt]
: Jet Villegas (:jet)
Depends on:
  Show dependency treegraph
Reported: 2012-09-01 13:36 PDT by Atte Kettunen
Modified: 2014-07-24 13:44 PDT (History)
9 users (show)
dveditz: sec‑bounty+
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Repro-file (398 bytes, image/svg+xml)
2012-09-01 13:36 PDT, Atte Kettunen
no flags Details
patch (1.51 KB, patch)
2012-09-12 06:17 PDT, Jonathan Watt [:jwatt]
roc: review+
lukasblakk+bugs: approval‑mozilla‑aurora+
lukasblakk+bugs: approval‑mozilla‑beta+
lukasblakk+bugs: approval‑mozilla‑esr10+
Details | Diff | Splinter Review

Description User image Atte Kettunen 2012-09-01 13:36:00 PDT
Created attachment 657600 [details]

Reproducible with ASAN-build from


==1095== ERROR: AddressSanitizer heap-buffer-overflow on address 0x7fae06810023 at pc 0x7fae417985cc bp 0x7fff9dfb8c80 sp 0x7fff9dfb8c78
READ of size 1 at 0x7fae06810023 thread T0
    #0 0x7fae417985cc in Convolve3x3 /home/attekett/firefox/src/content/svg/content/src/nsSVGFilters.cpp:4926
0x7fae06810023 is located 3 bytes to the right of 4000-byte region [0x7fae0680f080,0x7fae06810020)
allocated by thread T0 here:
    #0 0x422e7c in posix_memalign ??:0
    #1 0x7fae428f6565 in TryAllocAlignedBytes /home/attekett/firefox/src/gfx/thebes/gfxImageSurface.cpp:89
    #2 0x7fae41764886 in nsSVGFE::SetupScalingFilter(nsSVGFilterInstance*, nsSVGFE::Image const*, nsSVGFE::Image const*, nsIntRect const&, nsSVGNumberPair*) /home/attekett/firefox/src/content/svg/content/src/nsSVGFilters.cpp:153
    #3 0x7fae41782077 in nsSVGFELightingElement::Filter(nsSVGFilterInstance*, nsTArray<nsSVGFE::Image const*, nsTArrayDefaultAllocator> const&, nsSVGFE::Image const*, nsIntRect const&) /home/attekett/firefox/src/content/svg/content/src/nsSVGFilters.cpp:5009
    #4 0x7fae4169d8e5 in nsSVGFilterInstance::Render(gfxASurface**) /home/attekett/firefox/src/layout/svg/base/src/nsSVGFilterInstance.cpp:583
    #5 0x7fae416944d4 in nsSVGFilterFrame::PaintFilteredFrame(nsRenderingContext*, nsIFrame*, nsSVGFilterPaintCallback*, nsRect const*) /home/attekett/firefox/src/layout/svg/base/src/nsSVGFilterFrame.cpp:444
Comment 1 User image Jonathan Watt [:jwatt] 2012-09-12 03:40:40 PDT
I'm looking into this, but it's going to take some time to grok this part of the filters code.
Comment 2 User image Jonathan Watt [:jwatt] 2012-09-12 06:08:53 PDT
I don't understand the relevant parts of the SVG filter code in enough detail to feel satisfied that it's doing the right thing. That said, the issue seems to be that in nsSVGFELightingElement::Filter we end up looping over sourceData and targetData for each pixel in dataRect, but dataRect is 24x11 px while the images that own sourceData and targetData are only 25x10 px. In other words we loop over 264 pixels when only 250 have been allocated for the images. The root cause of the problem seems to be that SetupScalingFilter (called right at the top of nsSVGFELightingElement::Filter) has a rounding issue when scaling aDataRect which causes it to return the 24x11 px result.mDataRect.
Comment 3 User image Jonathan Watt [:jwatt] 2012-09-12 06:17:35 PDT
Created attachment 660408 [details] [diff] [review]
Comment 5 User image Ed Morley [:emorley] 2012-09-13 13:57:36 PDT
Comment 6 User image Alex Keybl [:akeybl] 2012-09-13 16:25:52 PDT
Do we think the ESR affected by this bug?
Comment 7 User image Daniel Veditz [:dveditz] 2012-09-13 16:28:40 PDT
Assuming ESR-10 is affected because SVG Filters were around then.
Comment 8 User image Jonathan Watt [:jwatt] 2012-09-14 03:40:56 PDT
Comment on attachment 660408 [details] [diff] [review]

[Approval Request Comment]
Bug caused by (feature/regressing bug #): issue has been in the code since forever
User impact if declined: may or may not be exploitable in different ways in different versions and on different platforms
Testing completed (on m-c, etc.): baked on m-c for a couple of days
Risk to taking this patch (and alternatives if risky): very low risk
String or UUID changes made by this patch: none
Comment 11 User image Tracy Walker [:tracy] 2014-01-10 10:41:37 PST
mass remove verifyme requests greater than 4 months old

Note You need to log in before you can comment on or make changes to this bug.