The ability to do that has been added in tor-0.4.9.2-alpha. Previous versions return a syntax error to the ADD_ONION command with PoWDefensesEnabled=1, so the approach here is to try with PoW and if we get syntax error, then retry without PoW.
Also update doc/tor.md with a hint on enabling PoW on manually configured Tor hidden services.
DrahtBot added the label
P2P
on Sep 17, 2025
DrahtBot
commented at 10:40 am on September 17, 2025:
contributor
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
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:
#34158 (torcontrol: Remove libevent usage by fjahr)
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.
dergoegge
commented at 12:52 pm on September 17, 2025:
member
Should we then also add PoW to the connections that we make to other nodes running behind hidden services?
willcl-ark
commented at 2:27 pm on September 17, 2025:
member
Should we then also add PoW to the connections that we make to other nodes running behind hidden services?
Reading the linked FAQ, the feature still supports “older clients” (which don’t have PoW defence capability), but they may take a lower priority when a service considers itself under DoS. So no PoW is required on the client side.
When the client-side tor is new-enough, my understanding is that the puzzle-solving is automatically handled by Tor, and doesn’t need client-side changes to the connection code, as it happens during the introduction. But I am not 100% certain.
fanquake
commented at 1:03 pm on September 23, 2025:
member
DrahtBot added the label
Needs rebase
on Dec 2, 2025
fanquake
commented at 12:27 pm on February 16, 2026:
member
What is the status of this?
in
src/test/fuzz/torcontrol.cpp:56
in
5aefa08017outdated
willcl-ark
commented at 9:34 pm on February 16, 2026:
I think tor_control_reply_code = 512 could be added here, to hit this expected path more frequently than random?
vasild
commented at 11:12 am on February 19, 2026:
Right, good catch! Done and also moved the TOR_REPLY_* constants to torcontrol.h so this fuzz test can use them instead of hardcoding numbers. Thanks!
willcl-ark
commented at 9:55 pm on February 16, 2026:
member
Approach and lightly-tested ACK on PoW-enabled Tor (version 0.4.8.22).
02026-02-16T21:44:26Z [tor] Get SOCKS port command yielded 127.0.0.1:9050
12026-02-16T21:44:26Z [tor] Configuring onion proxy for 127.0.0.1:9050
22026-02-16T21:44:26Z [tor] ADD_ONION failed with PoW defenses, retrying without
32026-02-16T21:44:26Z [tor] ADD_ONION successful (PoW defenses disabled)
Seems very reasonable to me to implement this configuration in order that we fare better during DoS attacks on the Tor network. Noting for others that as far as I read, due to the dynamic difficulty the (tor) PoW is ~ free on idle, and the cost only applies during an attack, which seems nice.
I quite like the pragmatism of “detecting” the tor version via the failure mode. It appears that the 512 failure happens early on the Tor side, before any service is created. So failing and retrying is “clean”.
What is the status of this?
Looks like it needs a pretty trivial rebase at the moment is all.
vasild force-pushed
on Feb 19, 2026
vasild
commented at 10:50 am on February 19, 2026:
contributor
8a526d39d8a00edff2361ceaa012574d1337b77b...206da5e5e420ab43857e4d15ddb7d1c603d6e762: rebase due to conflicts
What is the status of this?
Needed a rebase.
tor, fuzz: reuse constants instead of duplicating
`src/torcontrol.cpp` used to define some constants that are used
explicitly in `src/torcontrol.cpp` and implicitly in
`src/test/fuzz/torcontrol.cpp` by duplicating their values.
Move the constants to `src/torcontrol.h` and reuse them in
`src/test/fuzz/torcontrol.cpp` to avoid duplication and magic
numbers.
fb993f7604
tor: enable PoW defenses for automatically created hidden services
Enable PoW defenses [1] for hidden services that we create via
Tor Control using the `ADD_ONION` command [2].
The ability to do that has been added in tor-0.4.9.2-alpha [3]. Previous
versions return a syntax error to the `ADD_ONION` command with
`PoWDefensesEnabled=1`, so the approach here is to try with PoW and if
we get syntax error, then retry without PoW.
[1] https://tpo.pages.torproject.net/onion-services/ecosystem/technology/security/pow/
[2] https://spec.torproject.org/control-spec/commands.html#add_onion
[3] https://gitlab.torproject.org/tpo/core/tor/-/commit/02c18044464bfe45f168b55297a785244094cfd5
4c6798a3d3
doc: add a hint to enable PoW defenses to manual hidden services4bae84c94a
doc: add release notes for Tor PoW defensesc68e3d2c57
vasild force-pushed
on Feb 19, 2026
DrahtBot added the label
CI failed
on Feb 19, 2026
vasild
commented at 11:11 am on February 19, 2026:
contributor
Just realised though that my tor, although it has PoWDefenses compiled in, does not support it via ADD_ONION yet
0❯ tor --list-modules
1relay: yes
2dirauth: yes
3dircache: yes
4pow: yes
5 6❯ nc 127.0.0.1 9051 7AUTHENTICATE "" 8250 OK
9ADD_ONION NEW:ED25519-V3 PoWDefensesEnabled=1Port=38333,127.0.0.1:38333
10512 Bad arguments to ADD_ONION: Unrecognized keyword argument "PoWDefensesEnabled"
I think it might only be for pre-configured services unti addition to the ONION keyword in 0.4.9.5. That said, it does show the fallback mechanism, even in this edge case, works as intended… (and in fact that querying the binary modules would have been a bug here?).
vasild
commented at 11:50 am on February 19, 2026:
contributor
and in fact that querying the binary modules would have been a bug here?
I think yes, better to actually check if the ADD_ONION command supports pow (like in this PR).
willcl-ark approved
willcl-ark
commented at 12:07 pm on February 19, 2026:
member
ACKc68e3d2c57dcab5cea22ad5986fcd2b147a7daaa
Tested with two versions of tor. ON 0.4.8.22 automatic PoWDefense via ONION message (correctly) does not work and falls back to without.
On 0.4.9.5 I see:
02026-02-19T12:04:04Z torcontrol thread start
12026-02-19T12:04:04Z [tor] Reading cached private key from /xxxxxxxx/onion_v3_private_key
22026-02-19T12:04:04Z [tor] Successfully connected!
32026-02-19T12:04:04Z [tor] Connected to Tor version 0.4.9.5
42026-02-19T12:04:04Z [tor] Supported authentication method: NULL
52026-02-19T12:04:04Z [tor] Using NULL authentication
62026-02-19T12:04:04Z [tor] Authentication successful
72026-02-19T12:04:04Z [tor] Get SOCKS port command yielded 127.0.0.1:9050
82026-02-19T12:04:04Z [tor] Configuring onion proxy for 127.0.0.1:9050
92026-02-19T12:04:04Z [tor] ADD_ONION successful (PoW defenses enabled)
The changes look clean and correct to me.
DrahtBot removed the label
CI failed
on Feb 19, 2026
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-03-09 21:13 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me