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

================= Bug Report (1/1) ==================
## Source: Red Hat Bugzilla
## URL: https://bugzilla.redhat.com/show_bug.cgi?id=1471782
## Description:
Bugzilla ID: 1471782
Title: There is an illegal address access in eval.cpp of libsass

Description
owl337 2017-07-17 12:33:50 UTC
Created attachment 1299841 [details]
Triggered by "./sassc POC"

Description of problem:

There is an illegal address access in eval.cpp of libsass

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

<= latest version

How reproducible:

./sassc $POC

Steps to Reproduce:
The debugging information is as follows:

$ ./sassc POC


Program received signal SIGSEGV, Segmentation fault.
Sass::Eval::operator() (this=0x7fffffffde20, m=0x646820) at eval.cpp:526
526       Expression_Ptr ex_val = m->at(key)->perform(this);
(gdb) bt
#0  Sass::Eval::operator() (this=0x7fffffffde20, m=0x646820) at eval.cpp:526
#1  0x00007ffff79ace11 in Sass::Eval::operator() (this=0x7fffffffde20, l=0x631630) at eval.cpp:491
#2  0x00007ffff79b053f in Sass::Eval::operator() (this=0x7fffffffde20, b_in=<optimized out>) at eval.cpp:721
#3  0x00007ffff79acbc3 in Sass::Eval::operator() (this=0x7fffffffde20, l=0x631080) at eval.cpp:503
#4  0x00007ffff79f2bb4 in Sass::Expand::operator() (this=<optimized out>, a=<optimized out>) at expand.cpp:330
#5  0x00007ffff7a09771 in Sass::Expand::append_block (this=0x7fffffffde10, b=<optimized out>) at expand.cpp:799
#6  0x00007ffff79e9f89 in Sass::Expand::operator() (this=0x7fffffffde10, b=0x630f10) at expand.cpp:81
#7  0x00007ffff7800358 in Sass::Context::compile (this=0x62ff40) at context.cpp:659
#8  0x00007ffff77fd303 in Sass::File_Context::parse (this=0x62ff40) at context.cpp:588
#9  0x00007ffff7b16376 in Sass::sass_parse_block (compiler=0x630480) at sass_context.cpp:227
#10 sass_compiler_parse (compiler=0x630480) at sass_context.cpp:476
#11 0x00007ffff7b15562 in sass_compile_context (c_ctx=0x62fda0, cpp_ctx=0x7ffff7fda050) at sass_context.cpp:364
#12 0x00007ffff7b1592a in sass_compile_file_context (file_ctx=0x62fda0) at sass_context.cpp:463
#13 0x0000000000402796 in compile_file (options=0x62fd20, input_path=<optimized out>, outfile=0x0) at sassc.c:145
#14 0x0000000000403117 in main (argc=<optimized out>, argv=<optimized out>) at sassc.c:335

The asan debug info is as follows:

ASAN:SIGSEGV
=================================================================
==31154==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f1450d3b64d bp 0x7ffdff76db10 sp 0x7ffdff76d8c0 T0)
    #0 0x7f1450d3b64c  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x53664c)
    #1 0x7f1450d3a3e2  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x5353e2)
    #2 0x7f1450d3feaa  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x53aeaa)
    #3 0x7f1450d3a14e  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x53514e)
    #4 0x7f1450daba49  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x5a6a49)
    #5 0x7f1450dcf9da  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x5ca9da)
    #6 0x7f1450d9d71a  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x59871a)
    #7 0x7f1450a931aa  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x28e1aa)
    #8 0x7f1450a8e3b3  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x2893b3)
    #9 0x7f1450f9fe60  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x79ae60)
    #10 0x7f1450f9eaa1  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x799aa1)
    #11 0x7f1450f9eee1  (/home/icy/secreal/libsass-asan/install/lib/libsass.so.1+0x799ee1)
    #12 0x4ddfc5  (/home/icy/secreal/sassc-asan/install/bin/sassc+0x4ddfc5)
    #13 0x4debe5  (/home/icy/secreal/sassc-asan/install/bin/sassc+0x4debe5)
    #14 0x7f144f590a3f  (/lib/x86_64-linux-gnu/libc.so.6+0x20a3f)
    #15 0x436508  (/home/icy/secreal/sassc-asan/install/bin/sassc+0x436508)

AddressSanitizer can not provide additional info.
==31154==ABORTING


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
Aurelien Bompard 2017-07-18 13:24:05 UTC
Reported upstream as https://github.com/sass/libsass/issues/2446

---

Comment 2
Jan Kurik 2017-08-15 09:11:45 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

---

Comment 3
Ben Cotton 2018-11-27 18:30:05 UTC
This message is a reminder that Fedora 27 is nearing its end of life.
On 2018-Nov-30  Fedora will stop maintaining and issuing updates for
Fedora 27. 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 '27'.

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 27 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.

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

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