rust-openssl Use-After-Free Vulnerability in ALPN Protocol Selection

Vulnerability

A use-after-free vulnerability has been identified in the rust-openssl crate, specifically in versions 0.10.0 prior to 0.10.70. The issue arises in the `ssl::select_next_proto` function, which can return a slice pointing into the server buffer but with a lifetime tied to the client buffer. If the server buffer's lifetime is shorter than that of the client, it can lead to a use-after-free condition. This vulnerability may cause the server to crash or to leak arbitrary memory contents to the client.

Impact

Exploitation of this vulnerability can lead to a use-after-free condition, causing the server to crash or to return arbitrary memory contents to the client.

Reproduction

The vulnerability can be reproduced by constructing a server buffer within the callback passed to `SslContextBuilder::set_alpn_select_callback`. This will create a short-lived buffer that is freed when the callback returns, allowing `ssl::select_next_proto` to return a slice that points to freed memory.

Remediation

Users are advised to upgrade to rust-openssl version 0.10.70 or later, which fixes the vulnerability by properly constraining the output buffer's lifetime to match that of both input buffers.

Added: Jun 9, 2025, 7:46 PM
Updated: Jun 9, 2025, 7:46 PM

Vulnerability Rating

Custom Algorithm
spread
6.2
impact
1.3
exploitability
7.6
remediation
7.9
relevance
0.0
threat
6.4
urgency
2.9
incentive
1.7

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.