AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 24 Bitcoin

Merge bitcoin/bitcoin#36581: subprocess: fix command line memory leak on Windows

Public commit record

What the developer wrote

Authored by merge-script

93/100 · Strong
Merge bitcoin/bitcoin#36581: subprocess: fix command line memory leak on Windows

cf30d0a4123bb4237495f04e723ce9f706c2edf2 subprocess: fix command line memory leak on Windows (stickies-v)

Pull request description:

`Popen::execute_process()` copied the command line into a buffer from `new[]`, but did not delete it. This leaked memory each time a process started on Windows.

`CreateProcessA` [needs](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa#:~:text=characters%2E-,The,violation) a writable command line buffer. Since C++17, `std::string::data()` supplies one, so give the `std::string` buffer directly and remove the copy.

This only affects Windows. It is only reachable if `-signer=<cmd>` is set, through authenticated RPC or the GUI. Each call leaks only the startup-defined `<cmd>`, and the rate is limited by process spawn time, so the impact is limited.

_edit: this was fixed upstream in https://github.com/arun11299/cpp-subprocess/pull/131, but since this codebase is C++20 it seems better to avoid the copy (and the const cast). A direct backport isn't possible anyway, since #35704 switched us to CreateProcessA._

ACKs for top commit:
jpk68:
ACK cf30d0a4123bb4237495f04e723ce9f706c2edf2
hebasto:
re-ACK cf30d0a4123bb4237495f04e723ce9f706c2edf2.
winterrdog:
reACK cf30d0a4123bb4237495f04e723ce9f706c2edf2

Tree-SHA512: 873a5b69e4094dfc1cba0f822af1e431f7d6e29f2fac58e0712ffa060296022db0cbff55ab6f7a4416168e4958bcaa1567ad568f2a3a662e3cb4603bbb786816
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a small memory leak in Bitcoin Core on Windows. When starting an external signer program, the code previously copied the command string into a freshly allocated buffer but never freed it. The fix passes the string's own buffer directly to Windows, eliminating both the copy and the leak. The leak only occurs when an optional external signer is configured, and each leak is tiny (just the command string), so the practical security impact is very low.

Recommended action

No urgent action needed beyond applying the patch. Operators using external signers on Windows should upgrade in due course; the leak is small and slow. No workaround is required.

Security signals we found

01

Memory leak in Windows-only subprocess creation path

02

Reachable only when external signer command is configured

03

No memory corruption, use-after-free, or command-injection vector present

04

Fix removes unnecessary heap allocation and const-cast workaround

Risk score

Why this scored 24/100

Our methodology →
Potential impact 3/30
Exploitability 2/25
Stealth signal 2/15
Affected reach 3/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.