mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:50:37 +00:00
test: Add coverage for TorControl SAFECOOKIE authentication #36497
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36497
Loading…
Reference in a new issue
No description provided.
Delete branch "test/torcontrol-safecookie-auth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
adds functional test coverage for
SAFECOOKIEauthentication, includingsuccessful authentication,
AUTHCHALLENGEfailure, an invalid servernonce, a mismatched server hash, an invalid-length cookie file, and a
missing cookie file
while working on #35292, i realised we did not have coverage for
SAFECOOKIEauthentication either, so i added it hereThe following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
HASHEDPASSWORDauthentication by winterrdog)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
🟠 Minor · Guarantee that the fabricated server hash mismatches
feature_torcontrol.py:149-151 still replaces SERVERHASH with 32 zero bytes instead of flipping a bit of the computed hash. A mismatch is therefore near-certain (about 2^-256 chance of failure), not guaranteed. The comment now correctly says 'practically never'. Practical impact is negligible.
Location:
test/functional/feature_torcontrol.py:147(head).Review coverage was incomplete.
Reviewed:
141c4a798a82· Full review report · Previous reportspermalink
"Targeted" Test Coverage Improvements
cf80493e23)HEAD)src/torcontrol\.cpp$src/torcontrol\.cpp$src/torcontrol\.cpp$to get these results, i only ran
feature_torcontrol.pybefore and after thechange on the same build, using GCC's coverage instrumentation and lcov
2.0bash script used to get test coverage locally
ACK
141c4a798aConcept ACK
6827006f4fI introduced a few changes in
torcontrol.cppskipping the ServerHash comparison, dropping the ServerNonce length check, using the wrong key for the client hash and accepting any cookie length, all of this pass on master and fail on this branch, so the new tests catch them.🐙 This pull request conflicts with the target branch and needs rebase.
changes:
crACK
141c4a798aReviewed against
torcontrol.cpp:cookie + client_nonce + server_noncekeyed byTOR_SAFE_SERVERKEY/TOR_SAFE_CLIENTKEY— matchesComputeResponse()exactly, which writescookie→client_nonce→server_noncein that order (src/torcontrol.cpp:606-611).SAFECOOKIE authentication challenge failed,ServerNonce is not 32 bytes,does not match expected ServerHash,... could not be opened, and the short-cookie one (is not exactly %i bytesat :715, where%i→TOR_COOKIE_SIZE=32, so the asserted... is not exactly 32 bytesis a substring of the emitted line).Together with @mercie-ux's mutation testing, this confirms the six methods are genuine regression coverage rather than just line-hitting: happy path plus the five distinct failure branches, each pinned to a specific log line and an
ensure_forcheck that the node sends no further command. Nice bump (71.7%→81.9%).Minor, non-blocking: the six
ensure_for(duration=2)absence-checks add ~12s of fixed wait; unavoidable for asserting "no command follows," just noting it for total runtime.Code-review only — didn't build/run locally.
Tested ACK
141c4a798aRan the six new methods against a master build (v32.99.0-791173ae), all pass:
Upgrading my earlier code-review ACK — together with @mercie-ux's mutation testing this confirms the methods pass on correct code and fail when the checks are broken.