Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong crash line in new python version #55

Open
hkctkuy opened this issue Jan 31, 2023 · 1 comment
Open

Wrong crash line in new python version #55

hkctkuy opened this issue Jan 31, 2023 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@hkctkuy
Copy link

hkctkuy commented Jan 31, 2023

Hi! I've been fuzzing with atheris and found the problem with wrong crash line in new python versions.

For example I will use this simple wrapper fuzz.py:

import atheris                                                                   
                                                                                 
with atheris.instrument_imports():                                               
    import sys                                                                   
    import module                                                                
                                                                                 
def TestOneInput(data):                                                          
    module.crash(data)                                                           
                                                                                 
def main():                                                                      
    atheris.Setup(sys.argv, TestOneInput)                                        
    atheris.Fuzz()                                                               
                                                                                 
if __name__ == "__main__":                                                       
    main()

with this simple module module.py:

def crash(data):                                                                 
    print("wrong line!")                                                         
    return 1/0

I will use an empty file as a crash file.

Output If I use python3.8 ./fuzz.py crash command is:

INFO: Instrumenting module
INFO: Using built-in libfuzzer
WARNING: Failed to find function "__sanitizer_acquire_crash_state".
WARNING: Failed to find function "__sanitizer_print_stack_trace".
WARNING: Failed to find function "__sanitizer_set_death_callback".
INFO: Seed: 663688448
./fuzz.py: Running 1 inputs 1 time(s) each.
Running: crash
wrong line!

 === Uncaught Python exception: ===
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "./fuzz.py", line 8, in TestOneInput
    module.crash(data)
  File "/home/hkctkuy/atheris/module.py", line 3, in crash
    return 1/0

==3581292== ERROR: libFuzzer: fuzz target exited
SUMMARY: libFuzzer: fuzz target exited

Output If I use python3.10 ./fuzz.py crash command is:

INFO: Instrumenting module
INFO: Using built-in libfuzzer
WARNING: Failed to find function "__sanitizer_acquire_crash_state".
WARNING: Failed to find function "__sanitizer_print_stack_trace".
WARNING: Failed to find function "__sanitizer_set_death_callback".
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 32997823
./fuzz.py: Running 1 inputs 1 time(s) each.
Running: crash
wrong line!

 === Uncaught Python exception: ===
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "/home/hkctkuy/atheris/./fuzz.py", line 8, in TestOneInput
    module.crash(data)
  File "/home/hkctkuy/atheris/module.py", line 2, in crash
    print("wrong line!")
ZeroDivisionError: division by zero

==3581304== ERROR: libFuzzer: fuzz target exited
SUMMARY: libFuzzer: fuzz target exited

As you can see I have one line offset in Traceback.

I have larger offsets in more complex projects.

@jvoisin jvoisin added the bug Something isn't working label Mar 20, 2023
@jvoisin jvoisin added this to the 2.2.3 milestone Mar 20, 2023
@sam-xif
Copy link

sam-xif commented Oct 3, 2024

I have been experiencing this as well. It seems to have something to do with atheris's bytecode instrumentation, because when I play around with commenting out the instrumentation calls that I have in my code, the lines shift around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants