Menu

#21 stack-buffer-overflow in function get_signed_expression()

1.09
open
nobody
None
5
2021-04-06
2021-04-06
chiba taiki
No

Hi,
While fuzzing ATasm 1.09, I found stack-buffer-overflow in function get_signed_expression() in setparse.c.

==3821483==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffcdc09c170 at pc 0x7f7c3dea515d bp 0x7ffcdc09bfe0 sp 0x7ffcdc09b788
WRITE of size 6 at 0x7ffcdc09c170 thread T0
    #0 0x7f7c3dea515c  (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x9c15c)
    #1 0x56438a68d1f2 in get_signed_expression /homeatasm/setparse.c:321
    #2 0x56438a690884 in get_expression /homeatasm/setparse.c:160
    #3 0x56438a65dd83 in add_label /homeatasm/asm.c:918
    #4 0x56438a67201f in do_cmd /homeatasm/asm.c:1988
    #5 0x56438a67201f in do_cmd /homeatasm/asm.c:1976
    #6 0x56438a672424 in assemble /homeatasm/asm.c:2034
    #7 0x56438a650341 in main /homeatasm/asm.c:2446
    #8 0x7f7c3dc220b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
    #9 0x56438a651ddd in _start (/homeatasm/atasm+0xdddd)

Address 0x7ffcdc09c170 is located in stack of thread T0 at offset 320 in frame
    #0 0x56438a68bc4f in get_signed_expression /homeatasm/setparse.c:163

  This frame has 7 object(s):
    [32, 45) 'math' (line 168)
    [64, 320) 'buf' (line 164) <== Memory access at offset 320 overflows this variable
    [384, 640) 'work' (line 164)
    [704, 960) 'err' (line 142)
    [1024, 1280) 'err' (line 142)
    [1344, 1600) 'err' (line 142)
    [1664, 1920) 'err' (line 142)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x9c15c)
Shadow bytes around the buggy address:
  0x10001b80b7d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10001b80b7e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10001b80b7f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10001b80b800: 00 00 00 00 00 00 f1 f1 f1 f1 00 05 f2 f2 00 00
  0x10001b80b810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10001b80b820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00[f2]f2
  0x10001b80b830: f2 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00
  0x10001b80b840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10001b80b850: 00 00 00 00 00 00 f2 f2 f2 f2 f2 f2 f2 f2 00 00
  0x10001b80b860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10001b80b870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f2 f2
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
==3821483==ABORTING

reproduce:

atasm  stack_buffer_over_01_get_signed_expression
1 Attachments

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.