Skip to content

Reject temporary buffers in Unique_BIO constructors - #8628

Open
Max (maxtropets) wants to merge 4 commits into
mainfrom
maxtropets-unique-bio-remove-bytes-ctor
Open

Max (maxtropets) wants to merge 4 commits into
mainfrom
maxtropets-unique-bio-remove-bytes-ctor

Conversation

@maxtropets

@maxtropets Max (maxtropets) commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Unique_BIO can take ownership of the raw memory released into it, but passing rvalue ref can (and almost always will) lead to dangling pointers. Removing those CTORs will prevent this footgun from happening. cpp Unique_BIO(const std::vector<uint8_t>&&) = delete; Unique_BIO(const Pem&&) = delete;

Max (maxtropets) and others added 2 commits October 23, 2026 15:04
Delete the rvalue overloads for std::vector<uint8_t> and Pem so that
passing a temporary (including a std::string implicitly converted to a
Pem) fails to compile instead of leaving the BIO over freed memory.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@maxtropets Max (maxtropets) self-assigned this Oct 23, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@maxtropets
Max (maxtropets) marked this pull request as ready for review October 23, 2026 14:23
@maxtropets
Max (maxtropets) requested a review from a team as a code owner October 23, 2026 14:23
Copilot AI balanced review requested due to automatic review settings October 23, 2026 14:23

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

1 open issue
What changed in this PR

Prevents ccf::crypto::OpenSSL::Unique_BIO from being constructed from temporary buffers which would leave OpenSSL’s BIO viewing freed memory, and bumps the project version accordingly.

Changes:

  • Deleted Unique_BIO constructors that accept rvalue std::vector<uint8_t> / Pem to avoid dangling-pointer footguns.
  • Bumped Python package version to 7.0.23.
  • Added changelog entry describing the behavioral change.
File Description
python/​pyproject.toml Bumps the Python project version to match the release containing the constructor restriction.
include/​ccf/​crypto/​openssl/​openssl_wrappers.h Deletes rvalue constructors for Unique_BIO to prevent temporaries from being passed.
CHANGELOG.md Documents the change in Unique_BIO behavior in release notes for 7.0.23.

Review effort: Lite

Comment thread include/ccf/crypto/openssl/openssl_wrappers.h
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

🟢 Approval recommended

The narrow overload change enforces the intended lifetime restriction, with only a non-blocking regression-coverage suggestion remaining.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment on lines +188 to +189
Unique_BIO(const std::vector<uint8_t>&&) = delete;
Unique_BIO(const Pem&&) = delete;

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants