Bug 1470927 - There is a heap-use-after-free in reference() funtion of cflow.
There is a heap-use-after-free in reference() funtion of cflow.
Status: NEW
Product: Fedora
Classification: Fedora
Component: cflow (Show other bugs)
27
x86_64 Linux
unspecified Severity urgent
: ---
: ---
Assigned To: Terje Røsten
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-13 23:00 EDT by owl337
Modified: 2017-08-15 05:11 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-07-25 10:35:35 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Triggered by "./cflow $POC" (680 bytes, application/x-rar)
2017-07-13 23:00 EDT, owl337
no flags Details

  None (edit)
Description owl337 2017-07-13 23:00:36 EDT
Created attachment 1298073 [details]
Triggered by  "./cflow $POC"

Description of problem:

There is a heap-use-after-free  in  reference() funtion of  cflow.

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

<= latest version

How reproducible:

./cflow $POC

Steps to Reproduce:

The information is as follows:

$./cflow  POC2
 
Segmentation fault


The ASAN debugging  information is as follows:

$./cflow POC2

=================================================================
==26111==ERROR: AddressSanitizer: heap-use-after-free on address 0x60e00000c4d0 at pc 0x0000004fd9fa bp 0x7ffd71c71750 sp 0x7ffd71c71748
READ of size 8 at 0x60e00000c4d0 thread T0
    #0 0x4fd9f9  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x4fd9f9)
    #1 0x50267f  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x50267f)
    #2 0x4fc013  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x4fc013)
    #3 0x4fbc2f  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x4fbc2f)
    #4 0x4fb5b5  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x4fb5b5)
    #5 0x4f2085  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x4f2085)
    #6 0x7fabd69d3abf  (/lib/x86_64-linux-gnu/libc.so.6+0x20abf)
    #7 0x438938  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x438938)

0x60e00000c4d0 is located 144 bytes inside of 152-byte region [0x60e00000c440,0x60e00000c4d8)
freed by thread T0 here:
    #0 0x4bf622  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x4bf622)
    #1 0x5072cd  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x5072cd)

previously allocated by thread T0 here:
    #0 0x4bf902  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x4bf902)
    #1 0x52edce  (/home/icy/real/cflow-1.5-asan/cflow-1.5/install/bin/cflow+0x52edce)

Shadow bytes around the buggy address:
  0x0c1c7fff9840: 00 00 00 00 00 00 00 fa fa fa fa fa fa fa fa fa
  0x0c1c7fff9850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c1c7fff9860: 00 00 00 fa fa fa fa fa fa fa fa fa 00 00 00 00
  0x0c1c7fff9870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
  0x0c1c7fff9880: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
=>0x0c1c7fff9890: fd fd fd fd fd fd fd fd fd fd[fd]fa fa fa fa fa
  0x0c1c7fff98a0: fa fa fa fa fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c1c7fff98b0: fd fd fd fd fd fd fd fa fa fa fa fa fa fa fa fa
  0x0c1c7fff98c0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c1c7fff98d0: fd fd fd fa fa fa fa fa fa fa fa fa fd fd fd fd
  0x0c1c7fff98e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd 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
==26111==ABORTING


The vulnerability was triggered in function reference () at parser.c:1275.

(gdb) p &caller->callee 
$13 = (struct linked_list **) 0x60e00000c4d0

heap-use-after-free on address 0x60e00000c4d0 at pc 0x0000004fd9fa bp 0x7ffd71c71750 sp 0x7ffd71c71748

1266	void
1267	reference(char *name, int line)
1268	{
1269	     Symbol *sp = add_reference(name, line);
1270	     if (!sp)
1271		  return;
1272	     if (caller) {
1273		  if (!data_in_list(caller, sp->caller))
1274		       linked_list_append(&sp->caller, caller);
1275		  if (!data_in_list(sp, caller->callee))
1276		       linked_list_append(&caller->callee, sp);
1277	     }
1278	}
1279	


Actual results:

crash

Expected results:

crash

Additional info:

This vulnerability is detected by team OWL337, with our custom fuzzer collAFL. Please contact ganshuitao@gmail.com   and chaoz@tsinghua.edu.cn if you need more info about the team, the tool or the vulnerability.
Comment 3 Jan Kurik 2017-08-15 05:11:33 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

Note You need to log in before you can comment on or make changes to this bug.