New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 138672 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Email to this user bounced
Closed: Dec 2012
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug-Security

Restricted
  • Only users with EditIssue permission may comment.



Sign in to add a comment

Heap-double-free in xsltCompileStepPattern

Reported by nicolas....@agarri.fr, Jul 24 2012

Issue description

VULNERABILITY DETAILS

When processing an invalid XPath expression, libxslt will attempt to free twice a specific object.

VERSION

xsltproc: libxml 20706, libxslt 10126 and libexslt 815
Chromium: 18.0.1025.151 (Dev 130497 Linux) Ubuntu 10.04
Chromium+ASan: 21.0.1180.49 (147161)

REPRODUCTION CASE

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="key(//text()">
	Should crash libxslt because of a double free() ...
</xsl:template>
</xsl:stylesheet>

ADDITIONAL INFORMATION

Valgrind + xsltproc:

==31327== Invalid free() / delete / delete[]
==31327==    at 0x4024B3A: free (vg_replace_malloc.c:366)
==31327==    by 0x40D16E8: xsltCompileStepPattern (pattern.c:1690)
==31327==    by 0x40D1BF4: xsltCompileRelativePathPattern (pattern.c:1710)
==31327==    by 0x40D2826: xsltCompilePatternInternal (pattern.c:1795)
==31327==    by 0x40D2C59: xsltAddTemplate (pattern.c:2040)
==31327==    by 0x40CA3A2: xsltParseStylesheetTop (xslt.c:5413)
==31327==    by 0x40CA868: xsltParseStylesheetProcess (xslt.c:6414)
==31327==    by 0x40CAD2B: xsltParseStylesheetImportedDoc (xslt.c:6627)
==31327==    by 0x40CADDE: xsltParseStylesheetDoc (xslt.c:6666)
==31327==    by 0x804A7F3: main (xsltproc.c:830)
==31327==  Address 0x43e5d30 is 0 bytes inside a block of size 5 free'd
==31327==    at 0x4024B3A: free (vg_replace_malloc.c:366)
==31327==    by 0x40D109E: xsltCompileIdKeyPattern (pattern.c:1497)
==31327==    by 0x40D1A5F: xsltCompileStepPattern (pattern.c:1559)
==31327==    by 0x40D1BF4: xsltCompileRelativePathPattern (pattern.c:1710)
==31327==    by 0x40D2826: xsltCompilePatternInternal (pattern.c:1795)
==31327==    by 0x40D2C59: xsltAddTemplate (pattern.c:2040)
==31327==    by 0x40CA3A2: xsltParseStylesheetTop (xslt.c:5413)
==31327==    by 0x40CA868: xsltParseStylesheetProcess (xslt.c:6414)
==31327==    by 0x40CAD2B: xsltParseStylesheetImportedDoc (xslt.c:6627)
==31327==    by 0x40CADDE: xsltParseStylesheetDoc (xslt.c:6666)
==31327==    by 0x804A7F3: main (xsltproc.c:830)
==31327== 
compilation error: file df.xsl line 2 element template
xsltCompilePattern : failed to compile 'key(//text()'

Asan + Chromium:

==2558== ERROR: AddressSanitizer attempting double-free on 0x7f4ba9e7b880:

    #0  00000000092a5942 <free+0x22>:
 92a5942:	4c 8d b5 d8 fd ff ff 	lea    -0x228(%rbp),%r14
    #1  xsltCompileStepPattern+0x719
    #2  xsltCompileRelativePathPattern+0x1c
    #3  xsltCompilePatternInternal+0x1852
    #4  xsltAddTemplate+0xfb
    #5  xsltParseStylesheetProcess+0x2380
    #6  xsltParseStylesheetImportedDoc+0x495
    #7  xsltParseStylesheetDoc+0x1c
    #8  _ZN7WebCore13XSLStyleSheet17compileStyleSheetEv+0x5b
    #9  _ZN7WebCore13XSLTProcessor17transformToStringEPNS_4NodeERN3WTF6StringES5_S5_+0x4b4
    #10  _ZN7WebCore13XSLTProcessor19transformToFragmentEPNS_4NodeEPNS_8DocumentE+0x2bd
    #11  _ZN7WebCore15V8XSLTProcessor27transformToFragmentCallbackERKN2v89ArgumentsE+0x51c
    #12  _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE+0x710
    #19  _ZN2v88internalL6InvokeEbNS0_6HandleINS0_10JSFunctionEEENS1_INS0_6ObjectEEEiPS5_Pb+0x686
    #20  _ZN2v88Function4CallENS_6HandleINS_6ObjectEEEiPNS1_INS_5ValueEEE+0x3ec
    #21  _ZN7WebCore7V8Proxy24instrumentedCallFunctionEPNS_5FrameEN2v86HandleINS3_8FunctionEEENS4_INS3_6ObjectEEEiPNS4_INS3_5ValueEEE+0x1044
    #22  _ZN7WebCore7V8Proxy12callFunctionEN2v86HandleINS1_8FunctionEEENS2_INS1_6ObjectEEEiPNS2_INS1_5ValueEEE+0x67
    #23  _ZN7WebCore19V8LazyEventListener20callListenerFunctionEPNS_22ScriptExecutionContextEN2v86HandleINS3_5ValueEEEPNS_5EventE+0x1ab
    #24  _ZN7WebCore23V8AbstractEventListener18invokeEventHandlerEPNS_22ScriptExecutionContextEPNS_5EventEN2v86HandleINS5_5ValueEEE+0x327
    #25  _ZN7WebCore23V8AbstractEventListener11handleEventEPNS_22ScriptExecutionContextEPNS_5EventE+0x10b
    #26  _ZN7WebCore11EventTarget18fireEventListenersEPNS_5EventEPNS_15EventTargetDataERN3WTF6VectorINS_23RegisteredEventListenerELm1EEE+0x58f
    #27  _ZN7WebCore11EventTarget18fireEventListenersEPNS_5EventE+0x70
    #28  _ZN7WebCore9DOMWindow13dispatchEventEN3WTF10PassRefPtrINS_5EventEEENS2_INS_11EventTargetEEE+0x31e
    #29  _ZN7WebCore9DOMWindow17dispatchLoadEventEv+0x402

0x7f4ba9e7b880 is located 0 bytes inside of 5-byte region [0x7f4ba9e7b880,0x7f4ba9e7b885)
freed by thread T0 here:

    #0  00000000092a5942 <free+0x22>:
 92a5942:	4c 8d b5 d8 fd ff ff 	lea    -0x228(%rbp),%r14
    #1  xsltCompileStepPattern+0x584
    #2  xsltCompileRelativePathPattern+0x1c
    #3  xsltCompilePatternInternal+0x1852
    #4  xsltAddTemplate+0xfb
    #5  xsltParseStylesheetProcess+0x2380
    #6  xsltParseStylesheetImportedDoc+0x495
    #7  xsltParseStylesheetDoc+0x1c
    #8  _ZN7WebCore13XSLStyleSheet17compileStyleSheetEv+0x5b
    #9  _ZN7WebCore13XSLTProcessor17transformToStringEPNS_4NodeERN3WTF6StringES5_S5_+0x4b4
    #10  _ZN7WebCore13XSLTProcessor19transformToFragmentEPNS_4NodeEPNS_8DocumentE+0x2bd
    #11  _ZN7WebCore15V8XSLTProcessor27transformToFragmentCallbackERKN2v89ArgumentsE+0x51c
    #12  _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE+0x710
    #19  _ZN2v88internalL6InvokeEbNS0_6HandleINS0_10JSFunctionEEENS1_INS0_6ObjectEEEiPS5_Pb+0x686
    #20  _ZN2v88Function4CallENS_6HandleINS_6ObjectEEEiPNS1_INS_5ValueEEE+0x3ec
    #21  _ZN7WebCore7V8Proxy24instrumentedCallFunctionEPNS_5FrameEN2v86HandleINS3_8FunctionEEENS4_INS3_6ObjectEEEiPNS4_INS3_5ValueEEE+0x1044
    #22  _ZN7WebCore7V8Proxy12callFunctionEN2v86HandleINS1_8FunctionEEENS2_INS1_6ObjectEEEiPNS2_INS1_5ValueEEE+0x67
    #23  _ZN7WebCore19V8LazyEventListener20callListenerFunctionEPNS_22ScriptExecutionContextEN2v86HandleINS3_5ValueEEEPNS_5EventE+0x1ab
    #24  _ZN7WebCore23V8AbstractEventListener18invokeEventHandlerEPNS_22ScriptExecutionContextEPNS_5EventEN2v86HandleINS5_5ValueEEE+0x327
    #25  _ZN7WebCore23V8AbstractEventListener11handleEventEPNS_22ScriptExecutionContextEPNS_5EventE+0x10b
    #26  _ZN7WebCore11EventTarget18fireEventListenersEPNS_5EventEPNS_15EventTargetDataERN3WTF6VectorINS_23RegisteredEventListenerELm1EEE+0x58f
    #27  _ZN7WebCore11EventTarget18fireEventListenersEPNS_5EventE+0x70
    #28  _ZN7WebCore9DOMWindow13dispatchEventEN3WTF10PassRefPtrINS_5EventEEENS2_INS_11EventTargetEEE+0x31e

previously allocated by thread T0 here:

    #0  00000000092a5a02 <malloc+0x22>:
 92a5a02:	4c 8d b5 d8 fd ff ff 	lea    -0x228(%rbp),%r14
    #1  xmlStrndup+0x2a
    #2  xsltScanNCName+0x324
    #3  xsltCompileStepPattern+0x2d5
    #4  xsltCompileRelativePathPattern+0x1c
    #5  xsltCompilePatternInternal+0x1852
    #6  xsltAddTemplate+0xfb
    #7  xsltParseStylesheetProcess+0x2380
    #8  xsltParseStylesheetImportedDoc+0x495
    #9  xsltParseStylesheetDoc+0x1c
    #10  _ZN7WebCore13XSLStyleSheet17compileStyleSheetEv+0x5b
    #11  _ZN7WebCore13XSLTProcessor17transformToStringEPNS_4NodeERN3WTF6StringES5_S5_+0x4b4
    #12  _ZN7WebCore13XSLTProcessor19transformToFragmentEPNS_4NodeEPNS_8DocumentE+0x2bd
    #13  _ZN7WebCore15V8XSLTProcessor27transformToFragmentCallbackERKN2v89ArgumentsE+0x51c
    #14  _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE+0x710
 
Summary: Heap-double-free in xsltCompileStepPattern
Detailed report: https://cluster-fuzz.appspot.com/testcase?key=83062498

Uploader: jschuh@chromium.org

Crash Type: Heap-double-free
Crash Address: 
Crash State:
  - crash stack -
  xsltCompileStepPattern
  xsltCompileRelativePathPattern
  - free stack -
  xsltCompileStepPattern
  xsltCompileRelativePathPattern
  
Regressed: https://cluster-fuzz.appspot.com/revisions?range=114961:114982

Minimized Testcase (0.37 Kb): https://cluster-fuzz.appspot.com/download/AMIfv94JznkqTtnlG6yt0Z5hA2BpsSCJL7mf-luGgBXTEzZUbchokzbla2lEUl5so-emjTTFdUff8oOQth6650wOpQamc6DoLq32zevog8rvcODZJX6sjGca0s-bGX4ezn45RDsQ4g2mDESqpCbEfI0PwQSUsn838pgt-ey2pAQQHChREor1Diw
Cc: veill...@gmail.com
Labels: -Pri-0 -Area-Undefined Pri-1 Area-WebKit SecImpacts-Stable SecImpacts-Beta OS-All Mstone-20 SecSeverity-High Stability-Valgrind Stability-AddressSanitizer
Status: Available
Labels: -Area-WebKit Area-Internals
Labels: -Mstone-20 Mstone-21 reward-topanel
Owner: cevans@chromium.org
Status: Assigned
Thank you Nicolas for the two recent bugs. Sorry that we haven't jumped on them with our usual brutal efficiency ;-) I'll try and take care of both either this week or next.
Labels: Security-CodeYellow
Please do read Mark's email titled "Code Yellow: Security Bug Backlog" on chrome-team mailing list.
Status: Started
Labels: -SecSeverity-High SecSeverity-Low
Ok, I think I finally correctly root-caused this and have a simple fix in review (https://chromiumcodereview.appspot.com/10830177/)

Sorry to be the bearer of bad news but I think this one might also be Low severity. Let me know if I've got this one wrong. The sequence is xmlFree(), xmlFree() -- with almost no intervening code and certainly not a malloc() etc. It seems to be a condition which tcmalloc cleanly aborts on (although interestingly it fires DieFromMemoryCorruption() instead of DieFromDoubleFree() for me.
Project Member

Comment 8 by bugdroid1@chromium.org, Aug 6 2012

The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=150123

------------------------------------------------------------------------
r150123 | cevans@chromium.org | 2012-08-06T19:03:44.180286Z

Changed paths:
   M http://src.chromium.org/viewvc/chrome/trunk/src/third_party/libxslt/README.chromium?r1=150123&r2=150122&pathrev=150123
   M http://src.chromium.org/viewvc/chrome/trunk/src/third_party/libxslt/libxslt/pattern.c?r1=150123&r2=150122&pathrev=150123

Handle a bad XSLT expression better.

BUG= 138672 
Review URL: https://chromiumcodereview.appspot.com/10830177
------------------------------------------------------------------------
Labels: -Restrict-View-SecurityTeam -reward-topanel Restrict-View-SecurityNotify Merge-Approved
Status: FixUnreleased
Ok, this patch I'm fairly confident in, if you wanted to pull it upstream Daniel?

Project Member

Comment 10 by ClusterFuzz, Aug 7 2012

ClusterFuzz has detected this issue as fixed in range 150111:150125.

Detailed report: https://cluster-fuzz.appspot.com/testcase?key=83062498

Uploader: jschuh@chromium.org

Crash Type: Heap-double-free
Crash Address: 
Crash State:
  - crash stack -
  xsltCompileStepPattern
  xsltCompileRelativePathPattern
  - free stack -
  xsltCompileStepPattern
  xsltCompileRelativePathPattern
  
Regressed: https://cluster-fuzz.appspot.com/revisions?range=114961:114982
Fixed: https://cluster-fuzz.appspot.com/revisions?range=150111:150125

Minimized Testcase: https://cluster-fuzz.appspot.com/download/AMIfv94JznkqTtnlG6yt0Z5hA2BpsSCJL7mf-luGgBXTEzZUbchokzbla2lEUl5so-emjTTFdUff8oOQth6650wOpQamc6DoLq32zevog8rvcODZJX6sjGca0s-bGX4ezn45RDsQ4g2mDESqpCbEfI0PwQSUsn838pgt-ey2pAQQHChREor1Diw

If you suspect that the result above is incorrect, try re-doing that job on the testcase report page.
Okay, I agree with your patch. But that whole parsing code leaks like hell on
errors and I want to fix it differently upstream (the first free
should never happen
in xsltCompileIdKeyPattern())
So sounds fine to me just that I will come with something more
complete upstream.

Daniel
Labels: -Merge-Approved Merge-Merged
Project Member

Comment 13 by bugdroid1@chromium.org, Aug 24 2012

Labels: merge-merged-1180
The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=153294

------------------------------------------------------------------------
r153294 | cevans@chromium.org | 2012-08-24T21:31:06.974592Z

Changed paths:
   M http://src.chromium.org/viewvc/chrome/branches/1180/src/third_party/libxslt/libxslt/pattern.c?r1=153294&r2=153293&pathrev=153294

Merge 150123 - Handle a bad XSLT expression better.

BUG= 138672 
Review URL: https://chromiumcodereview.appspot.com/10830177

TBR=cevans@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10882041
------------------------------------------------------------------------
Labels: CVE-2012-2870
BTW I fixed it upstream with that commit,

http://git.gnome.org/browse/libxslt/commit/?id=8566ab4a10158d195adb5f1f61afe1ee8bfebd12

Daniel
Project Member

Comment 16 by bugdroid1@chromium.org, Oct 14 2012

Labels: Restrict-AddIssueComment-Commit
This issue has been closed for some time. No one will pay attention to new comments.
If you are seeing this bug or have new data, please click New Issue to start a new bug.
Status: Fixed
Project Member

Comment 18 by bugdroid1@chromium.org, Jan 18 2013

Labels: Restrict-View-EditIssue
Restrict-View-EditIssue is preferred since it allows anyone who can edit an issue (committers and contributors) to view the bug.
Project Member

Comment 19 by bugdroid1@chromium.org, Jan 18 2013

Restrict-View-EditIssue is preferred since it allows anyone who can edit an issue (committers and contributors) to view the bug.
Project Member

Comment 20 by bugdroid1@chromium.org, Mar 10 2013

Labels: -Type-Security -Area-Internals -SecImpacts-Stable -SecImpacts-Beta -Mstone-21 -SecSeverity-Low -Stability-Valgrind -Stability-AddressSanitizer Security-Severity-Low Security-Impact-Stable Security-Impact-Beta Performance-Valgrind M-21 Cr-Internals Performance-Memory-AddressSanitizer Type-Bug-Security
Project Member

Comment 21 by bugdroid1@chromium.org, Mar 14 2013

Labels: -Restrict-AddIssueComment-Commit Restrict-AddIssueComment-EditIssue
Labels: -Restrict-View-SecurityNotify -Restrict-View-EditIssue
Project Member

Comment 23 by bugdroid1@chromium.org, Mar 21 2013

Labels: -Security-Severity-Low Security_Severity-Low
Project Member

Comment 24 by bugdroid1@chromium.org, Mar 21 2013

Labels: -Security-Impact-Stable Security_Impact-Stable
Project Member

Comment 25 by bugdroid1@chromium.org, Mar 21 2013

Labels: -Security-Impact-Beta Security_Impact-Beta
Project Member

Comment 26 by bugdroid1@chromium.org, Apr 1 2013

Labels: -Performance-Memory-AddressSanitizer Stability-Memory-AddressSanitizer
Project Member

Comment 27 by bugdroid1@chromium.org, Apr 1 2013

Labels: -Performance-Valgrind Stability-Valgrind
Project Member

Comment 28 by sheriffbot@chromium.org, Jun 14 2016

Labels: -security_impact-beta
Project Member

Comment 29 by sheriffbot@chromium.org, Oct 1 2016

This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 30 by sheriffbot@chromium.org, Oct 2 2016

This bug has been closed for more than 14 weeks. Removing security view restrictions.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Labels: allpublic
Labels: CVE_description-submitted

Sign in to add a comment