Skip to content

rustls: fix a potential memory issue#19425

Closed
x2018 wants to merge 1 commit into
curl:masterfrom
x2018:rustls_double_free
Closed

rustls: fix a potential memory issue#19425
x2018 wants to merge 1 commit into
curl:masterfrom
x2018:rustls_double_free

Conversation

@x2018

@x2018 x2018 commented Nov 9, 2025

Copy link
Copy Markdown
Contributor

In rustls_client_config_builder_build(), the config_builder is consumed via try_box_from_ptr!(builder) and ownership is transferred to Rust. Calling rustls_client_config_builder_free() afterwards would result in double-free.

An additional evidence is from the usage in rustls-ffi's test code at https://github.com/rustls/rustls-ffi/blob/main/librustls/tests/client.c#L431, where the builder is not freed and set to NULL after calling rustls_client_config_builder_build().

may need to further evaluate its security impact...

Other: backend->config is set if rustls_client_config_builder_build() is ok.

@github-actions github-actions Bot added the TLS label Nov 9, 2025
@bagder

bagder commented Nov 10, 2025

Copy link
Copy Markdown
Member

/cc @cpu

@cpu cpu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you, good catch.

@bagder bagder closed this in 3f1a8db Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants