swftools icon indicating copy to clipboard operation
swftools copied to clipboard

global-buffer-overflow exists in countline() at lib/swf5compiler.flex:327

Open Diggingwei opened this issue 2 years ago • 0 comments

Summary

A global-buffer-overflow caused when using swfc.

Version

$ ./swfc -V
swfc - part of swftools 0.9.2
$ git log --oneline -1
772e55a2 (HEAD, origin/master, origin/HEAD, master)

Platform

$ uname -a
Linux 1cc373898f58 5.4.0-150-generic #167~18.04.1-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
clang version : 12.0.0

Reproduce

PoC : poc.zip Command Line:

$ ./swfc poc

Debug Info

==47121==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0000014986cd at pc 0x0000007c1de5 bp 0x7fffffffc250 sp 0x7fffffffc248
WRITE of size 1 at 0x0000014986cd thread T0
    #0 0x7c1de4 in countline /src/project/swftools_project/swftools/lib/swf5compiler.flex:327:21
    #1 0x7c1de4 in swf5lex /src/project/swftools_project/swftools/lib/swf5compiler.flex:305:6
    #2 0x7f48c6 in swf5parse /src/project/swftools_project/swftools/lib/swf5compiler.tab.c:3061:16
    #3 0x68383d in compileSWFActionCode /src/project/swftools_project/swftools/lib/action/actioncompiler.c:90:6
    #4 0x593963 in swf_ActionCompile /src/project/swftools_project/swftools/lib/modules/swfaction.c:1111:11
    #5 0x50114e in s_action /src/project/swftools_project/swftools/src/swfc.c:1966:13
    #6 0x5451f0 in c_action /src/project/swftools_project/swftools/src/swfc.c
    #7 0x51da0c in parseArgumentsForCommand /src/project/swftools_project/swftools/src/swfc.c:4475:5
    #8 0x51da0c in main /src/project/swftools_project/swftools/src/swfc.c:4598:2
    #9 0x7ffff7c39082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082)
    #10 0x41d61d in _start (/Sleuth_code/project_src/PoC/project/swftools_project/swftools/fuzz_issue-209/swfc_cov+0x41d61d)

0x0000014986cd is located 51 bytes to the left of global variable 'current_filename' defined in 'as3/files.c:56:7' (0x1498700) of size 8
0x0000014986cd is located 9 bytes to the right of global variable 'current_column' defined in 'as3/files.c:55:5' (0x14986c0) of size 4
SUMMARY: AddressSanitizer: global-buffer-overflow /src/project/swftools_project/swftools/lib/swf5compiler.flex:327:21 in countline
Shadow bytes around the buggy address:
  0x00008028b080: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x00008028b090: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x00008028b0a0: 04 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x00008028b0b0: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x00008028b0c0: 00 00 00 00 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
=>0x00008028b0d0: 00 f9 f9 f9 f9 f9 f9 f9 04[f9]f9 f9 f9 f9 f9 f9
  0x00008028b0e0: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x00008028b0f0: 00 f9 f9 f9 f9 f9 f9 f9 00 f9 f9 f9 f9 f9 f9 f9
  0x00008028b100: 04 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x00008028b110: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 00 00 00
  0x00008028b120: 00 00 00 00 f9 f9 f9 f9 00 00 00 00 00 00 00 00
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
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  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
  Shadow gap:              cc
==47121==ABORTING

Diggingwei avatar Jan 10 '24 12:01 Diggingwei