Project: libsass (sass/libsass), language: c++
Vulnerability instance: libsass.cve-2017-12964
Sanitizer: address

================= Bug Report (1/1) ==================
## Source: Red Hat Bugzilla
## URL: https://bugzilla.redhat.com/show_bug.cgi?id=1482397
## Description:
Bugzilla ID: 1482397
Title: There is a stack-overflow in the sassc of libsass library. This vulnerability is triggered in function Sass::Eval::operator() .

Description
owl337 2017-08-17 07:48:34 UTC
Created attachment 1314586 [details]
Triggered by "./sassc POC9"

Description of problem:

There is a stack-overflow in the sassc  of  libsass library.  This vulnerability is triggered in function Sass::Eval::operator() .

Version-Release number of selected component (if applicable):

<= latest version

How reproducible:

./sassc $POC

Steps to Reproduce:

The debugging information is as follows:

$ ./sassc POC9

Segmentation fault

ASAN debugging information:

$ ./sassc POC9
(gdb)  r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/icy/libsass-check/sassc-asan/install/bin/sassc id:000070,sig:11,src:009686,op:havoc,rep:4 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, Sass::Eval::operator() (this=<optimized out>, b_in=<optimized out>) at eval.cpp:542
542     Expression_Obj lhs = b_in->left();
(gdb) c 1194
Will ignore next 1193 crossings of breakpoint 1.  Continuing.

Breakpoint 1, Sass::Eval::operator() (this=<optimized out>, b_in=<optimized out>) at eval.cpp:542
542     Expression_Obj lhs = b_in->left();
(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00007ffff7819369 in Sass::Eval::operator()(Sass::Binary_Expression*) at eval.cpp:540
 breakpoint already hit 1195 times
...
(gdb) 
567     Binary_Expression_Obj b = b_in;
(gdb) 
Single stepping until exit from function Sass::Eval::operator()(Sass::Binary_Expression*),
which has no line number information.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7818ffb in Sass::Eval::operator() (this=0x7fffffffd880, b_in=<optimized out>) at eval.cpp:540
540   {
(gdb) 
0x00000000004bfbd0 in __asan::AsanOnSIGSEGV(int, void*, void*) ()
(gdb) 
Single stepping until exit from function _ZN6__asan13AsanOnSIGSEGVEiPvS0_,
which has no line number information.
ASAN:SIGSEGV
=================================================================
==6364==ERROR: AddressSanitizer: stack-overflow on address 0x7fffff7fe930 (pc 0x7ffff7818ffb bp 0x7fffff800310 sp 0x7fffff7fe7c0 T0)
    #0 0x7ffff7818ffa  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x545ffa)
    #1 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #2 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #3 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #4 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #5 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #6 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #7 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #8 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #9 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #10 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #11 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #12 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #13 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #14 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #15 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #16 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #17 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #18 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #19 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #20 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #21 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #22 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #23 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #24 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #25 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #26 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #27 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #28 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #29 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)
    #30 0x7ffff781a67f  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54767f)

 ...

==6364==ABORTING
[Inferior 1 (process 6364) exited with code 01]


This vulnerability was triggered in function

Sass::Eval::operator() (this=<optimized out>, b_in=<optimized out>) at eval.cpp
539   Expression_Ptr Eval::operator()(Binary_Expression_Ptr b_in)
540   {
541 
542     Expression_Obj lhs = b_in->left();
543     Expression_Obj rhs = b_in->right();
544     enum Sass_OP op_type = b_in->optype();
...
559     // Evaluate variables as early o
560     while (Variable_Ptr l_v = Cast<Variable>(lhs)) {
561       lhs = operator()(l_v);
562     }
563     while (Variable_Ptr r_v = Cast<Variable>(rhs)) {
564       rhs = operator()(r_v);
565     }
566 
567     Binary_Expression_Obj b = b_in;
568 



Actual results:

crash

Expected results:

crash

Additional info:

Credits:

This vulnerability is detected by team OWL337, with our custom fuzzer collAFL. Please contact ganshuitao   and chaoz.cn if you need more info about the team, the tool or the vulnerability.


Comments:
Comment 1
Fedora End Of Life 2018-02-20 15:36:09 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 28 development cycle.
Changing version to '28'.

---

Comment 2
Ben Cotton 2019-05-02 22:02:11 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

---

Comment 3
Michael Catanzaro 2020-11-02 15:12:33 UTC
Red Hat Bugzilla is not an appropriate forum for reporting security bugs in upstream components. As you can see, your bug report here has been ignored for three years, and will likely continue to be ignored, so I'm going to go ahead and close it. Please feel free to report this upstream if you want the developers to look at it.

Attachments:
Attachment 1314586: Triggered by "./sassc POC9" [Link: https://bugzilla.redhat.com/attachment.cgi?id=1314586]

Build script:
#!/bin/bash -eu
# Minimized build script with only core build commands
set -eu
export BUILD='static'
make -j$(nproc)

Dockerfile:
FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool
RUN git clone https://github.com/sass/libsass libsass
RUN git -C libsass checkout 31573210c0d120ae56aaea543a0dbab5255cdfb7
WORKDIR $SRC/libsass
COPY build.sh $SRC/

Additional files:
filename: data_context_fuzzer.cc
content: #include "sass.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
  char* sass_data = (char*) malloc(sizeof(char) * size + 1);
  if (sass_data == NULL) return 0;

  memcpy(sass_data, data, size);
  sass_data[size] = '\0';

  struct Sass_Data_Context* ctx = sass_make_data_context(sass_data);
  if (ctx == NULL) {
    free(sass_data);
    return 0;
  }

  struct Sass_Options* options = sass_make_options();
  if (options == NULL) {
    sass_delete_data_context(ctx);
    return 0;
  }

  sass_option_set_output_style(options, SASS_STYLE_NESTED);
  sass_option_set_precision(options, 5);

  sass_data_context_set_options(ctx, options);
  sass_compile_data_context(ctx);

  sass_delete_data_context(ctx);
  sass_delete_options(options);

  return 0;
}