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

Merge bitcoin/bitcoin#36637: torcontrol: send -torpassword hex-encoded to avoid escaping bugs

Public commit record

What the developer wrote

Authored by Ava Chow

100/100 · Strong
Merge bitcoin/bitcoin#36637: torcontrol: send -torpassword hex-encoded to avoid escaping bugs

5a699cc2539856027d2a788b9604989d553b4d30 torcontrol: send -torpassword hex-encoded to avoid escaping bugs (jpk68)

Pull request description:

The Tor password was sent as a `QuotedString` with only double quotes escaped; as Tor interprets backslash escapes inside it, any password containing a backslash was mangled (or left the string unterminated).

The Tor Control spec deliberately allows the token to be sent as unquoted hex "to avoid escaping issues", as the `SAFECOOKIE` response already is. This patch does the same for the password, and also adds a functional test covering backslashes and quotes.

ACKs for top commit:
achow101:
ACK 5a699cc2539856027d2a788b9604989d553b4d30
winterrdog:
re-ACK 5a699cc2539856027d2a788b9604989d553b4d30
sedited:
Tested ACK 5a699cc2539856027d2a788b9604989d553b4d30
fjahr:
ACK 5a699cc2539856027d2a788b9604989d553b4d30

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

What changed, and why it matters

This change fixes how Bitcoin Core sends your Tor control password to the Tor daemon. Previously, the password was wrapped in quotes and only double-quote characters were escaped. If a password contained a backslash, Tor would misinterpret it, which could corrupt the password, fail authentication, or in theory allow command-injection-style tricks in the Tor control protocol. The fix sends the password as plain hexadecimal characters instead, which avoids escaping entirely. A new test verifies that passwords containing backslashes and quotes now work correctly.

Recommended action

Users who set -torpassword with special characters (especially backslashes or quotes) should upgrade. Reviewers should confirm the hex encoding matches Tor's control-spec grammar and that no other QuotedString fields remain under-escaped.

Security signals we found

01

Improper escaping of protocol string (QuotedString)

02

Potential Tor control command boundary confusion

03

Authentication bypass/failure risk for Tor control

04

Functional test added for backslash and quote characters

Risk score

Why this scored 49/100

Our methodology →
Potential impact 12/30
Exploitability 10/25
Stealth signal 8/15
Affected reach 7/15
Confidence 8/10
Evidence quality 4/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.