-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
unit-test-server crashes with invalid pointer #750
Comments
I'm trying to help out with this because I package libmodbus for Fedora and EPEL, but I'll be honest, I'm not quite sure how the test server works. I was trying to reproduce the crash directly, without starting off in gdb. If I do this on Fedora rawhide:
... nothing happens. Should it? |
Same result as with your other report. This is a duplicate of #748
I suggest to just close the issue. |
Thank you @psychon for the bisect. |
libmodbus version
libmodbus v3.1.6
OS and/or distribution
Ubuntu 18
Environment
..
Description
A vulnerability has been identified in libmodbus v3.1.6, which can be triggered by sending a specific message to unit-test-server. The vulnerability appears to be due to the modbus_receive() function incorrectly manipulating a query pointer or out-of-bounds array after executing malloc() to allocate memory, causing the program to crash with an invalid pointer at free(query).
Actual behavior if applicable
free(): invalid pointer
Expected behavior or suggestion
no crash
Steps to reproduce the behavior (commands or source code)
POC:
POC.zip
libmodbus output with debug mode enabled
The location of the crash can be further determined by debugging with gdb
Put breakpoints in unit-test-server.c wherever query is used and debug again
After the modbus_receive(), the value of the pointer changed, and it was this change that caused the crash at free(query).
Continuing the trace, it turns out that it ends up in the recv()
I'm guessing that there could be an array out of bounds due to insufficient memory allocated by the malloc?
The text was updated successfully, but these errors were encountered: