| 1 | # Anonymity Networks with Monero |
| 2 | |
| 3 | Currently only Tor and I2P have been integrated into Monero. The usage of |
| 4 | these networks is still considered experimental - there are a few pessimistic |
| 5 | cases where privacy is leaked. The design is intended to maximize privacy of |
| 6 | the source of a transaction by broadcasting it over an anonymity network, while |
| 7 | relying on IPv4 for the remainder of messages to make surrounding node attacks |
| 8 | (via sybil) more difficult. |
| 9 | |
| 10 | |
| 11 | ## Behavior |
| 12 | |
| 13 | If _any_ anonymity network is enabled, transactions being broadcast that lack |
| 14 | a valid "context" (i.e. the transaction did not come from a p2p connection), |
| 15 | will only be sent to peers on anonymity networks. If an anonymity network is |
| 16 | enabled but no peers over an anonymity network are available, an error is |
| 17 | logged and the transaction is kept for future broadcasting over an anonymity |
| 18 | network. The transaction will not be broadcast unless an anonymity connection |
| 19 | is made or until `monerod` is shutdown and restarted with only public |
| 20 | connections enabled. |
| 21 | |
| 22 | Anonymity networks can also be used with `monero-wallet-cli` and |
| 23 | `monero-wallet-rpc` - the wallets will connect to a daemon through a proxy. The |
| 24 | daemon must provide a hidden service for the RPC itself, which is separate from |
| 25 | the hidden service for P2P connections. |
| 26 | |
| 27 | |
| 28 | ## P2P Commands |
| 29 | |
| 30 | Only handshakes, peer timed syncs and transaction broadcast messages are |
| 31 | supported over anonymity networks. If one `--add-exclusive-node` p2p address |
| 32 | is specified, then no syncing will take place and only transaction broadcasting |
| 33 | can occur. It is therefore recommended that `--add-exclusive-node` be combined |
| 34 | with additional exclusive IPv4 address(es). |
| 35 | |
| 36 | |
| 37 | ## Usage |
| 38 | |
| 39 | ### Outbound Connections |
| 40 | |
| 41 | Connecting to an anonymous address requires the command line option |
| 42 | `--tx-proxy` which tells `monerod` the ip/port of a socks proxy provided by a |
| 43 | separate process. On most systems the configuration will look like: |
| 44 | |
| 45 | ``` |
| 46 | --tx-proxy tor,127.0.0.1:9050,10 |
| 47 | --tx-proxy i2p,127.0.0.1:9000 |
| 48 | ``` |
| 49 | |
| 50 | which tells `monerod` that ".onion" p2p addresses can be forwarded to a socks |
| 51 | proxy at IP 127.0.0.1 port 9050 with a max of 10 outgoing connections and |
| 52 | ".b32.i2p" p2p addresses can be forwarded to a socks proxy at IP 127.0.0.1 port |
| 53 | 9000 with the default max outgoing connections. |
| 54 | |
| 55 | If desired, peers can be manually specified: |
| 56 | |
| 57 | ``` |
| 58 | --add-exclusive-node rveahdfho7wo4b2m.onion:28083 |
| 59 | --add-peer rveahdfho7wo4b2m.onion:28083 |
| 60 | ``` |
| 61 | |
| 62 | Either option can be listed multiple times, and can specify any mix of Tor, |
| 63 | I2P, and IPv4 addresses. Using `--add-exclusive-node` will prevent the usage of |
| 64 | seed nodes on ALL networks, which will typically be undesirable. |
| 65 | |
| 66 | ### Inbound Connections |
| 67 | |
| 68 | Receiving anonymity connections is done through the option |
| 69 | `--anonymous-inbound`. This option tells `monerod` the inbound address, network |
| 70 | type, and max connections: |
| 71 | |
| 72 | ``` |
| 73 | --anonymous-inbound rveahdfho7wo4b2m.onion:28083,127.0.0.1:28083,25 |
| 74 | --anonymous-inbound cmeua5767mz2q5jsaelk2rxhf67agrwuetaso5dzbenyzwlbkg2q.b32.i2p,127.0.0.1:30000 |
| 75 | ``` |
| 76 | |
| 77 | which tells `monerod` that a max of 25 inbound Tor connections are being |
| 78 | received at address "rveahdfho7wo4b2m.onion:28083" and forwarded to `monerod` |
| 79 | localhost port 28083, and a default max I2P connections are being received at |
| 80 | address "cmeua5767mz2q5jsaelk2rxhf67agrwuetaso5dzbenyzwlbkg2q.b32.i2p" and |
| 81 | forwarded to `monerod` localhost port 30000. |
| 82 | These addresses will be shared with outgoing peers, over the same network type, |
| 83 | otherwise the peer will not be notified of the peer address by the proxy. |
| 84 | |
| 85 | ### Wallet RPC |
| 86 | |
| 87 | An anonymity network can be configured to forward incoming connections to a |
| 88 | `monerod` RPC port - which is independent from the configuration for incoming |
| 89 | P2P anonymity connections. The anonymity network (Tor/i2p) is |
| 90 | [configured in the same manner](#configuration), except the localhost port |
| 91 | must be the RPC port (typically 18081 for mainnet) instead of the p2p port: |
| 92 | |
| 93 | ``` |
| 94 | HiddenServiceDir /var/lib/tor/data/monero |
| 95 | HiddenServicePort 18081 127.0.0.1:18081 |
| 96 | ``` |
| 97 | |
| 98 | Then the wallet will be configured to use a Tor/i2p address: |
| 99 | ``` |
| 100 | --proxy 127.0.0.1:9050 |
| 101 | --daemon-address rveahdfho7wo4b2m.onion |
| 102 | ``` |
| 103 | |
| 104 | The proxy must match the address type - a Tor proxy will not work properly with |
| 105 | i2p addresses, etc. |
| 106 | |
| 107 | i2p and onion addresses provide the information necessary to authenticate and |
| 108 | encrypt the connection from end-to-end. If desired, SSL can also be applied to |
| 109 | the connection with `--daemon-address https://rveahdfho7wo4b2m.onion` which |
| 110 | requires a server certificate that is signed by a "root" certificate on the |
| 111 | machine running the wallet. Alternatively, `--daemon-cert-file` can be used to |
| 112 | specify a certificate to authenticate the server. |
| 113 | |
| 114 | Proxies can also be used to connect to "clearnet" (ipv4 addresses or ICANN |
| 115 | domains), but `--daemon-cert-file` _must_ be used for authentication and |
| 116 | encryption. |
| 117 | |
| 118 | ### Network Types |
| 119 | |
| 120 | #### Tor & I2P |
| 121 | |
| 122 | Options `--add-exclusive-node` and `--add-peer` recognize ".onion" and |
| 123 | ".b32.i2p" addresses, and will properly forward those addresses to the proxy |
| 124 | provided with `--tx-proxy tor,...` or `--tx-proxy i2p,...`. |
| 125 | |
| 126 | Option `--anonymous-inbound` also recognizes ".onion" and ".b32.i2p" addresses, |
| 127 | and will automatically be sent out to outgoing Tor/I2P connections so the peer |
| 128 | can distribute the address to its other peers. |
| 129 | |
| 130 | ##### Configuration |
| 131 | |
| 132 | Tor must be configured for hidden services. An example configuration ("torrc") |
| 133 | might look like: |
| 134 | |
| 135 | ``` |
| 136 | HiddenServiceDir /var/lib/tor/data/monero |
| 137 | HiddenServicePort 28083 127.0.0.1:28083 |
| 138 | ``` |
| 139 | |
| 140 | This will store key information in `/var/lib/tor/data/monero` and will forward |
| 141 | "Tor port" 28083 to port 28083 of ip 127.0.0.1. The file |
| 142 | `/usr/lib/tor/data/monero/hostname` will contain the ".onion" address for use |
| 143 | with `--anonymous-inbound`. |
| 144 | |
| 145 | I2P must be configured with a standard server tunnel. Configuration differs by |
| 146 | I2P implementation. |
| 147 | |
| 148 | ## Privacy Limitations |
| 149 | |
| 150 | There are currently some techniques that could be used to _possibly_ identify |
| 151 | the machine that broadcast a transaction over an anonymity network. |
| 152 | |
| 153 | ### Timestamps |
| 154 | |
| 155 | The peer timed sync command sends the current time in the message. This value |
| 156 | can be used to link an onion address to an IPv4/IPv6 address. If a peer first |
| 157 | sees a transaction over Tor, it could _assume_ (possibly incorrectly) that the |
| 158 | transaction originated from the peer. If both the Tor connection and an |
| 159 | IPv4/IPv6 connection have timestamps that are approximately close in value they |
| 160 | could be used to link the two connections. This is less likely to happen if the |
| 161 | system clock is fairly accurate - many peers on the Monero network should have |
| 162 | similar timestamps. |
| 163 | |
| 164 | #### Mitigation |
| 165 | |
| 166 | Keep the system clock accurate so that fingerprinting is more difficult. In |
| 167 | the future a random offset might be applied to anonymity networks so that if |
| 168 | the system clock is noticeably off (and therefore more fingerprintable), |
| 169 | linking the public IPv4/IPv6 connections with the anonymity networks will be |
| 170 | more difficult. |
| 171 | |
| 172 | ### Intermittent Monero Syncing |
| 173 | |
| 174 | If a user only runs `monerod` to send a transaction then quit, this can also |
| 175 | be used by an ISP to link a user to a transaction. |
| 176 | |
| 177 | #### Mitigation |
| 178 | |
| 179 | Run `monerod` as often as possible to conceal when transactions are being sent. |
| 180 | Future versions will also have peers that first receive a transaction over an |
| 181 | anonymity network delay the broadcast to public peers by a randomized amount. |
| 182 | This will not completely mitigate a user who syncs up sends then quits, in |
| 183 | part because this rule is not enforceable, so this mitigation strategy is |
| 184 | simply a best effort attempt. |
| 185 | |
| 186 | ### Active Bandwidth Shaping |
| 187 | |
| 188 | An attacker could attempt to bandwidth shape traffic in an attempt to determine |
| 189 | the source of a Tor/I2P connection. There isn't great mitigation against |
| 190 | this, but I2P should provide better protection against this attack since |
| 191 | the connections are not circuit based. |
| 192 | |
| 193 | #### Mitigation |
| 194 | |
| 195 | The best mitigation is to use I2P instead of Tor. However, I2P |
| 196 | has a smaller set of users (less cover traffic) and academic reviews, so there |
| 197 | is a trade off in potential issues. Also, anyone attempting this strategy really |
| 198 | wants to uncover a user, it seems unlikely that this would be performed against |
| 199 | every Tor/I2P user. |
| 200 | |
| 201 | ### I2P/Tor Stream Used Twice |
| 202 | |
| 203 | If a single I2P/Tor stream is used 2+ times for transmitting a transaction, the |
| 204 | operator of the hidden service can conclude that both transactions came from the |
| 205 | same source. If the subsequent transactions spend a change output from the |
| 206 | earlier transactions, this will also reveal the "real" spend in the ring |
| 207 | signature. This issue was (primarily) raised by @secparam on Twitter. |
| 208 | |
| 209 | #### Mitigation |
| 210 | |
| 211 | `monerod` currently selects two outgoing connections every 5 minutes for |
| 212 | transmitting transactions over I2P/Tor. Using outgoing connections prevents an |
| 213 | adversary from making many incoming connections to obtain information (this |
| 214 | technique was taken from Dandelion). Outgoing connections also do not have a |
| 215 | persistent public key identity - the creation of a new circuit will generate |
| 216 | a new public key identity. The lock time on a change address is ~20 minutes, so |
| 217 | `monerod` will have rotated its selected outgoing connections several times in |
| 218 | most cases. However, the number of outgoing connections is typically a small |
| 219 | fixed number, so there is a decent probability of re-use with the same public |
| 220 | key identity. |
| 221 | |
| 222 | @secparam (twitter) recommended changing circuits (Tor) as an additional |
| 223 | precaution. This is likely not a good idea - forcibly requesting Tor to change |
| 224 | circuits is observable by the ISP. Instead, `monerod` should likely disconnect |
| 225 | from peers occasionally. Tor will rotate circuits every ~10 minutes, so |
| 226 | establishing new connections will use a new public key identity and make it |
| 227 | more difficult for the hidden service to link information. This process will |
| 228 | have to be done carefully because closing/reconnecting connections can also |
| 229 | leak information to hidden services if done improperly. |
| 230 | |
| 231 | At the current time, if users need to frequently make transactions, I2P/Tor |
| 232 | will improve privacy from ISPs and other common adversaries, but still have |
| 233 | some metadata leakages to unknown hidden service operators. |