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 `reader_util.c:1507' #1980

Merged
merged 2 commits into from
May 20, 2023

Conversation

headshog
Copy link
Contributor

Hi! We've been fuzzing nDPI with sydr-fuzz security predicates and numeric truncation error was found in reader_util.c:1507.

In function packet_processing our tool has found numeric truncation error on line '1507'. We suggest to change the type uint32_t of variable ms on lines 1507, 1523 and 1542 to uint64_t type. Also then the type of parameter const u_int32_t value in function ndpi_data_add_value should be changed to const u_int64_t value.

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_8b9cb7917f68635994851de25846268a190f828f_num_trunc_1.txt
    
    
  4. Output:

    /nDPI/example/reader_util.c:1507:17: runtime error: implicit conversion from type 'u_int64_t' (aka 'unsigned long') of value 18447052351682937 (64-bit, unsigned) to type 'u_int32_t' (aka 'unsigned int') changed the value to 311638393 (32-bit, unsigned)
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /nDPI/example/reader_util.c:1507:17
    

@IvanNardi
Copy link
Collaborator

The change makes sense; could you update your PR, updating the unit tests results, please? (see CI failures in Github actions)

@utoni
Copy link
Collaborator

utoni commented May 16, 2023

Maybe we should think about integrating sydr-fuzz into nDPI.

@sonarcloud
Copy link

sonarcloud bot commented May 20, 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 1ab5318 into ntop:dev May 20, 2023
@IvanNardi
Copy link
Collaborator

Merged; I updated the results myself. Thanks for your contribution

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.

3 participants