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

Numeric truncation at kerberos.c:458 #2032

Merged
merged 1 commit into from
Jul 5, 2023

Conversation

headshog
Copy link
Contributor

@headshog headshog commented Jul 5, 2023

Hi! We've been fuzzing nDPI with sydr-fuzz security predicates and we found numeric truncation error in kerberos.c:458.

In function ndpi_search_kerberos on line 458 body_offset, koffset, pad_len variables has types u_int16_t. But due to integer promotion the right side of operator has int type, so the numeric truncation may occur. Also variable body_offset is used in if operator on line 460. For example, at packet->payload[body_offset] numeric truncation error is obvious. So we suggest to change the type u_int16_t of these variables to type u_int32_t.

Environment

How to reproduce this error

  1. Build docker container:

    sudo docker build -t oss-sydr-fuzz-ndpi .
    
    
  2. Run docker container:

    docker run --privileged --network host -v /etc/localtime:/etc/localtime:ro --rm -it -v $PWD:/fuzz oss-sydr-fuzz-ndpi /bin/bash
    
    
  3. Run on the following input:

    /nDPI/libfuzzer/fuzz_ndpi_reader sydr_e5d503700ad4e7b17c1c5ab8c721c99bf48cac22_num_trunc_18_unsigned.txt
    
    
  4. Output:

    protocols/kerberos.c:458:22: runtime error: implicit conversion from type 'int' of value 65548 (32-bit, signed) to type 'u_int16_t' (aka 'unsigned short') changed the value to 12 (16-bit, unsigned)
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior protocols/kerberos.c:458:22
    

@sonarcloud
Copy link

sonarcloud bot commented Jul 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@IvanNardi IvanNardi merged commit 2e5004d into ntop:dev Jul 5, 2023
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants