-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
The value of the ctx->backend pointer has been accidentally modified, leading to a Use-After-Free (UAF) vulnerability #749
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
Comments
Sorry that I missed this one before. It's yet another duplicate of your other reports (#748 and #750). Your reproduction instructions are missing a The result with commit bd1c85f is:
The result with commit b4ef4c1 is:
|
Thank you for your reports @balckgu1. It's important to run such analysis on dev version or at least on lastest release. |
libmodbus version
libmodbus v3.1.6
OS and/or distribution
Ubuntu 18
Environment
...
Description
A UAF vulnerability exists in unit-test-server that is triggered when a specific message is sent to unit-test-server. The vulnerability appears to be caused by the ctx->backend pointer at line 171 in modbus.c being incorrectly modified after multiple calls or used after free.
Actual behavior if applicable
==7657==ERROR: AddressSanitizer: SEGV on unknown address 0x605ffffffe90 (pc 0x56a769c5088e bp 0x7ffdc458eb90 sp 0x7ffdc458e900 T0)
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 vulnerability can be further determined through gdb debugging:
Breakpoint at line 171 of modbus.c and run:
The first time a breakpoint is hit, check the variable information:
next
On the second hit, the pointer is modified and the program crashes:
The text was updated successfully, but these errors were encountered: