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

================= Bug Report (1/1) ==================
## Source: Red Hat Bugzilla
## URL: https://bugzilla.redhat.com/show_bug.cgi?id=1474019
## Description:
Bugzilla ID: 1474019
Title: Heap-overflow in the sassc of libsass library

Description
hongphi.pham95 2017-07-23 06:55:13 UTC
Created attachment 1303012 [details]
Triggered by "./sassc POC

Description of problem:


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

<= latest version

How reproducible:

./sassc POC

Steps to Reproduce:
➜  bin git:(master) ./sassc POC
=================================================================
==8339==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xb4803ea1 at pc 0x0858ca45 bp 0xbfb394b8 sp 0xbfb394ac
READ of size 1 at 0xb4803ea1 thread T0
    #0 0x858ca44  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x858ca44)
    #1 0x8575b9c  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x8575b9c)
    #2 0x8497a36  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x8497a36)
    #3 0x8452fa6  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x8452fa6)
    #4 0x8449a3b  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x8449a3b)
    #5 0x84416d2  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x84416d2)
    #6 0x843d33f  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x843d33f)
    #7 0x8299b41  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x8299b41)
    #8 0x82b3a7b  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x82b3a7b)
    #9 0x824e49f  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x824e49f)
    #10 0x824d36e  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x824d36e)
    #11 0x824d720  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x824d720)
    #12 0x823a6af  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x823a6af)
    #13 0x80cd000  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x80cd000)
    #14 0xb7315636  (/lib/i386-linux-gnu/libc.so.6+0x18636)
    #15 0x816688b  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x816688b)

0xb4803ea1 is located 0 bytes to the right of 1569-byte region [0xb4803880,0xb4803ea1)
allocated by thread T0 here:
    #0 0x820abc4  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x820abc4)
    #1 0x83faea2  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x83faea2)
    #2 0x82b2b2b  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x82b2b2b)
    #3 0x824e49f  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x824e49f)
    #4 0x824d36e  (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x824d36e)

SUMMARY: AddressSanitizer: heap-buffer-overflow (/home/osboxes/Desktop/origin/libsass/sass/bin/sassc+0x858ca44)
Shadow bytes around the buggy address:
  0x36900780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x36900790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x369007a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x369007b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x369007c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x369007d0: 00 00 00 00[01]fa fa fa fa fa fa fa fa fa fa fa
  0x369007e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x369007f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x36900800: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x36900810: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x36900820: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==8339==ABORTING


Actual results:
crash

Expected results:
crash

Additional info:


Comments:
Comment 1
Jan Kurik 2017-08-15 07:31:51 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

---

Comment 2
Ben Cotton 2018-11-27 18:35:50 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.

---

Comment 3
Ben Cotton 2018-11-30 17:43:06 UTC
Fedora 27 changed to end-of-life (EOL) status on 2018-11-30. Fedora 27 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

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

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