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

================= Bug Report (1/1) ==================
## Source: Red Hat Bugzilla
## URL: https://bugzilla.redhat.com/show_bug.cgi?id=1482335
## Description:
Bugzilla ID: 1482335
Title: There is an illegal address access in libsass that is similar as Bug 1471782 which is fixed by vendor.

Description
owl337 2017-08-17 03:52:40 UTC
Created attachment 1314525 [details]
Triggered by ./sassc POC8

Description of problem:

There is an illegal address access in libsass that is similar as Bug 1471782 which is fixed by vendor.

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

The latest version

How reproducible:

./sassc $POC

Steps to Reproduce:

$ ./sassc 8

Segmentation fault

ASAN debugging information:

$ ./sassc POC8
(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\:000047\,sig\:11\,src\:011626\,op\:arith8\,pos\:30\,val\:-21 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 3, Sass::Eval::operator() (this=<optimized out>, m=<optimized out>) at eval.cpp:526
526       Expression_Ptr ex_val = m->at(key)->perform(this);
(gdb) c
Continuing.

Breakpoint 3, Sass::Eval::operator() (this=<optimized out>, m=<optimized out>) at eval.cpp:526
526       Expression_Ptr ex_val = m->at(key)->perform(this);
...
(gdb) s
Single stepping until exit from function Sass::Eval::operator()(Sass::Map*),
which has no line number information.

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff78185ad in Sass::Eval::operator() (this=<optimized out>, m=<optimized out>) at eval.cpp:526
526       Expression_Ptr ex_val = m->at(key)->perform(this);
(gdb) 
0x00000000004bfbd0 in __asan::AsanOnSIGSEGV(int, void*, void*) ()
(gdb) bt
#0  0x00000000004bfbd0 in __asan::AsanOnSIGSEGV(int, void*, void*) ()
#1  <signal handler called>
#2  0x00007ffff78185ad in Sass::Eval::operator() (this=<optimized out>, m=<optimized out>) at eval.cpp:526
#3  0x00007ffff7817343 in Sass::Eval::operator() (this=<optimized out>, l=<optimized out>) at eval.cpp:491
#4  0x00007ffff78170af in Sass::Eval::operator() (this=<optimized out>, l=<optimized out>) at eval.cpp:503
#5  0x00007ffff781690d in Sass::Eval::operator() (this=<optimized out>, l=<optimized out>) at eval.cpp:509
#6  0x00007ffff78170af in Sass::Eval::operator() (this=<optimized out>, l=<optimized out>) at eval.cpp:503
#7  0x00007ffff788898a in Sass::Expand::operator() (this=<optimized out>, a=<optimized out>) at expand.cpp:330
#8  0x00007ffff78ac92b in Sass::Expand::append_block (this=<optimized out>, b=<optimized out>) at expand.cpp:799
#9  0x00007ffff787a65b in Sass::Expand::operator() (this=<optimized out>, b=<optimized out>) at expand.cpp:81
#10 0x00007ffff7566b9b in Sass::Context::compile (this=<optimized out>) at context.cpp:659
#11 0x00007ffff7561da4 in Sass::File_Context::parse (this=<optimized out>) at context.cpp:588
#12 0x00007ffff7a7eed1 in Sass::sass_parse_block (compiler=0x6040000097d0) at sass_context.cpp:227
#13 sass_compiler_parse (compiler=<optimized out>) at sass_context.cpp:476
#14 0x00007ffff7a7db12 in sass_compile_context (c_ctx=0x611000009f00, cpp_ctx=0x7ffff7fd8778) at sass_context.cpp:364
#15 0x00007ffff7a7df52 in sass_compile_file_context (file_ctx=0x611000009f00) at sass_context.cpp:463
#16 0x00000000004ddfc6 in compile_file (options=0x60c00000bf80, input_path=<optimized out>, outfile=0x0) at sassc.c:145
#17 0x00000000004debe6 in main (argc=<optimized out>, argv=<optimized out>) at sassc.c:335
(gdb) c
Continuing.
ASAN:SIGSEGV
=================================================================
==44443==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7ffff78185ad bp 0x7fffffffc370 sp 0x7fffffffc120 T0)
    #0 0x7ffff78185ac  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x5455ac)
    #1 0x7ffff7817342  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x544342)
    #2 0x7ffff78170ae  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x5440ae)
    #3 0x7ffff781690c  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x54390c)
    #4 0x7ffff78170ae  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x5440ae)
    #5 0x7ffff7888989  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x5b5989)
    #6 0x7ffff78ac92a  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x5d992a)
    #7 0x7ffff787a65a  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x5a765a)
    #8 0x7ffff7566b9a  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x293b9a)
    #9 0x7ffff7561da3  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x28eda3)
    #10 0x7ffff7a7eed0  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x7abed0)
    #11 0x7ffff7a7db11  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x7aab11)
    #12 0x7ffff7a7df51  (/home/icy/libsass-check/libsass-asan/install/lib/libsass.so.1+0x7aaf51)
    #13 0x4ddfc5  (/home/icy/libsass-check/sassc-asan/install/bin/sassc+0x4ddfc5)
    #14 0x4debe5  (/home/icy/libsass-check/sassc-asan/install/bin/sassc+0x4debe5)
    #15 0x7ffff605ea3f  (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #16 0x436508  (/home/icy/libsass-check/sassc-asan/install/bin/sassc+0x436508)

AddressSanitizer can not provide additional info.
==44443==ABORTING
[Inferior 1 (process 44443) exited with code 01]
(gdb) 


This vulnerability was triggered in function

Sass::Eval::operator() (this=<optimized out>, m=<optimized out>) at eval.cpp:526
526       Expression_Ptr ex_val = m->at(key)->perform(this);


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:05 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:15 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:11:11 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 1314525: Triggered by ./sassc POC8 [Link: https://bugzilla.redhat.com/attachment.cgi?id=1314525]

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;
}