Banning a CJDNS peer from the Peers page does not take effect, and the entry is dropped at the next start #1124

Open
opened 2026-11-13 15:11:41 +00:00 by jarolrod · 0 comments
jarolrod commented 2026-11-13 15:11:41 +00:00 (Migrated from github.com)

On a node where Core treats fc00::/8 as CJDNS, banning a CJDNS peer from the Peers page adds a row to the banned list but bans nothing: the peer stays connected, Core does not count the address as banned, and the entry is not loaded at the next start.

To reproduce:

  1. Start the app with -cjdnsreachable=1 and a proxy for CJDNS (-proxy=127.0.0.1:<port>=cjdns), and connect a peer with addnode "[fc00::1]:18444" onetry. getpeerinfo lists it with network cjdns.
  2. Open Peers, click the [fc00::1]:18444 row, then … in the details pane, 1 hour, and Ban.

No error is shown, the footer reads "View 1 banned peer", and the list and listbanned have fc00::1/128. Compared with Core's own ban on the same node:

Check The app's Ban setban fc00::1 add 3600
Peer afterwards same peer id at 5 s and 30 s, still listed, "2 connected" gone from getpeerinfo in 0.3 s
debug.log no "disconnect by subnet" line disconnect by subnet=fc00::1 match
Stored entry fc00::1/128 fc00::1
A later setban fc00::1 add accepted "IP/Subnet already banned"
After quit and restart listbanned is [], the banned link is gone, log has "Dropping entry with unparseable address or subnet (fc00::1/128) from ban list" entry kept

The result was the same in 2 offscreen runs and 1 native run, and offscreen at eed1f426fcb6. The same clicks on a 127.0.0.1 peer under the same options banned and disconnected it, and that entry survived the restart.

banPeer gets the address as text and parses it again with LookupHost, which returns an IPv6 address, because a CJDNS address prints as plain IPv6 text:

github.com/bitcoin-core/gui-qml@2bd5a61e83/qml/models/nodemodel.cpp (L918-L929)

Core's setban applies MaybeFlipIPv6toCJDNS after the same lookup (rpc/net.cpp#L835-L839), and Bitcoin-Qt passes the peer's address object, by its source. The app's key is therefore an IPv6 /128 subnet, which never matches a CJDNS peer, and at start Core rejects fc00::1/128 because a CJDNS address cannot take a mask. By the same match an inbound connection from that address would be accepted; I did not observe that.

The text round trip came in with #529, part of the work in closed #507; the first version of the action looked the peer up by node id. This belongs under #921. Open #985 rewrites banPeer and keeps the same LookupHost call, so the fix could go there: pass the peer's address object, or apply MaybeFlipIPv6toCJDNS after the lookup.

Reach is small. CJDNS has to be enabled with a start-up option, which the app has no switch for, and -onlynet must not exclude it. The peer visibly stays in the list, setban from the console works, and the app's Unban removes the stored row.

Reproduced on qt6 at 2bd5a61e8304, macOS arm64 / Qt 6.9.0, isolated regtest, offscreen and native. Limits:

  • No real CJDNS network: the peer was a second local node reached through a SOCKS5 relay on 127.0.0.1, connected outbound with addnode.
  • Clicks went through the test bridge. Only the details-pane menu and the 1-hour duration were tried, not the row's right-click menu.
  • The app's Disconnect was not clicked on this peer; disconnectnode by id removed it.
  • Quit was SIGTERM with exit code 0. Bitcoin-Qt was read, not run.
On a node where Core treats `fc00::/8` as CJDNS, banning a CJDNS peer from the Peers page adds a row to the banned list but bans nothing: the peer stays connected, Core does not count the address as banned, and the entry is not loaded at the next start. To reproduce: 1. Start the app with `-cjdnsreachable=1` and a proxy for CJDNS (`-proxy=127.0.0.1:<port>=cjdns`), and connect a peer with `addnode "[fc00::1]:18444" onetry`. `getpeerinfo` lists it with network `cjdns`. 2. Open **Peers**, click the `[fc00::1]:18444` row, then **…** in the details pane, **1 hour**, and **Ban**. No error is shown, the footer reads "View 1 banned peer", and the list and `listbanned` have `fc00::1/128`. Compared with Core's own ban on the same node: | Check | The app's Ban | `setban fc00::1 add 3600` | |---|---|---| | Peer afterwards | same peer id at 5 s and 30 s, still listed, "2 connected" | gone from `getpeerinfo` in 0.3 s | | `debug.log` | no "disconnect by subnet" line | `disconnect by subnet=fc00::1 match` | | Stored entry | `fc00::1/128` | `fc00::1` | | A later `setban fc00::1 add` | accepted | "IP/Subnet already banned" | | After quit and restart | `listbanned` is `[]`, the banned link is gone, log has "Dropping entry with unparseable address or subnet (fc00::1/128) from ban list" | entry kept | The result was the same in 2 offscreen runs and 1 native run, and offscreen at `eed1f426fcb6`. The same clicks on a 127.0.0.1 peer under the same options banned and disconnected it, and that entry survived the restart. `banPeer` gets the address as text and parses it again with `LookupHost`, which returns an IPv6 address, because a CJDNS address prints as plain IPv6 text: https://github.com/bitcoin-core/gui-qml/blob/2bd5a61e8304d5143e32f1ce977a2de2aceb6413/qml/models/nodemodel.cpp#L918-L929 Core's `setban` applies `MaybeFlipIPv6toCJDNS` after the same lookup ([rpc/net.cpp#L835-L839](https://github.com/bitcoin/bitcoin/blob/44901d8f64cb617714707bd025ecd83f108353c2/src/rpc/net.cpp#L835-L839)), and Bitcoin-Qt passes the peer's address object, by its source. The app's key is therefore an IPv6 /128 subnet, which never matches a CJDNS peer, and at start Core rejects `fc00::1/128` because a CJDNS address cannot take a mask. By the same match an inbound connection from that address would be accepted; I did not observe that. The text round trip came in with #529, part of the work in closed #507; the first version of the action looked the peer up by node id. This belongs under #921. Open #985 rewrites `banPeer` and keeps the same `LookupHost` call, so the fix could go there: pass the peer's address object, or apply `MaybeFlipIPv6toCJDNS` after the lookup. Reach is small. CJDNS has to be enabled with a start-up option, which the app has no switch for, and `-onlynet` must not exclude it. The peer visibly stays in the list, `setban` from the console works, and the app's **Unban** removes the stored row. Reproduced on `qt6` at `2bd5a61e8304`, macOS arm64 / Qt 6.9.0, isolated regtest, offscreen and native. Limits: - No real CJDNS network: the peer was a second local node reached through a SOCKS5 relay on 127.0.0.1, connected outbound with `addnode`. - Clicks went through the test bridge. Only the details-pane menu and the 1-hour duration were tried, not the row's right-click menu. - The app's **Disconnect** was not clicked on this peer; `disconnectnode` by id removed it. - Quit was SIGTERM with exit code 0. Bitcoin-Qt was read, not run.
Sign in to join this conversation.
No description provided.