Junglewise Threat Intelligence

CVE-2026-77358: cpp-httplib use-after-free in TLS WebSocket client

CVE-2026-77358 · Severity: info · CVSS 7.5 · Published 2026-08-28

Technologies: Yhirose Cpp-Httplib. Vendors: Yhirose.

Executive brief

cpp-httplib is a C++ library used to build HTTP and WebSocket applications with encryption support. A flaw in the secure WebSocket client causes the library to free critical SSL/TLS session memory while still attempting to use it during connection shutdown, leading to potential crashes or unpredictable behavior when closing encrypted WebSocket connections.

Technical details

The vulnerability is a use-after-free flaw in the WebSocketClient::shutdown_and_close() method. The root cause is an ordering bug: the TLS session is freed via tls::free_session() before the WebSocket close frame is sent via ws_->close(). However, the WebSocket object's internal SSLSocketStream holds a raw pointer to that freed session and attempts to read from and write to it when sending the close frame. This results in reading and writing to freed memory. The defect is reachable through normal client teardown (destructor), the connect path, and explicit shutdown calls. No authentication or special preconditions are required; the use-after-free occurs during ordinary connection closure with TLS-enabled WebSocket clients. Valgrind testing confirmed 49 memory errors including invalid reads and writes on a freed 7,608-byte SSL object. The issue was fixed in version 0.50.1 by reordering operations to complete the WebSocket close before freeing the TLS session.

Affected products

  • yhirose cpp-httplib 0.33.0 through 0.50.0

Timeline

  • 2026-08-21: disclosed
  • 2026-08-28: patched: Fixed in version 0.50.1

References

Related threats