azerothcore / mod-eluna

Eluna Lua Engine © for WoW Emulators
https://elunaluaengine.github.io/
GNU General Public License v3.0
98 stars 128 forks source link

Segmentation Fault in HttpManager::HttpWorkerThread on SSL Verification Failure #166

Open blkht01 opened 8 months ago

blkht01 commented 8 months ago

I encountered a segmentation fault within the HttpManager::HttpWorkerThread method when making HTTPS requests that fail SSL verification. The segmentation fault occurs specifically when attempting to access properties (status, body, headers) of a null HTTP response object, which is null due to an SSL server verification error.

Steps to Reproduce

Actual Behavior

The application crashes with a segmentation fault when the HTTP response object is null due to an SSL server verification failure.

Environment

AzerothCore Version: a2f21bd Module: Eluna OS: Ubuntu 22.04 Compiler: clang Debug Information GDB backtrace revealed that the crash occurs at:

HttpManager::HttpWorkerThread (this=0x7ffff29aafc0) at /path/to/HttpManager.cpp:170
170 responseQueue.push(new HttpResponse(req->funcRef, res->status, res->body, res->headers));
The HTTP response object (res) was null due to an httplib::Error::SSLServerVerification error.

Workaround

Installing a valid SSL certificate (e.g., from Let's Encrypt) on the server being queried resolved the issue by allowing SSL verification to succeed.

Suggested Fix

Implement additional error handling within the HttpManager::HttpWorkerThread method to check for null HTTP response objects before attempting to access their properties. Consider logging SSL verification failures and other HTTP errors in a way that does not lead to a null dereference and application crash.