DEV Community

Cover image for I made a call over Tor and watched my own phone while it happened
Umbera
Umbera

Posted on

I made a call over Tor and watched my own phone while it happened

Last week I wrote about finding a hole in my own app's post-quantum key handling. Today's update ships something else I'd been working on for a while: calls over Tor.

It's easy to put "your IP stays hidden" in release notes. I wanted to actually see it, on a real phone, not just trust my own code. So I did.

What a call leaks even when it's encrypted

Voice and video in Umbera go over WebRTC and are encrypted end to end, the server can't decrypt them. But encryption hides the content, not the addresses. To connect two phones, WebRTC gathers what it calls candidates: every address you might be reachable at. Your LAN address, your public one, IPv6, a relay address. The other side gets that list and tries pairs until one works.

So on a normal call, the person you're talking to can learn your IP. Our relay server sees it too, it has to send packets somewhere. For most people that's fine, almost every calling app works this way. For some of our users it really isn't.

How the Tor call works

The idea is simple. Getting it to work reliably was not. The phone runs a tiny TCP server on 127.0.0.1. WebRTC thinks it's a normal TURN relay and sends everything there. Each of those connections then goes through the Tor network to our onion service, which hands the bytes to the real relay.

On top of that, WebRTC is only allowed to use the relay. No direct candidates at all. Otherwise there's no point: Tor on one side, and your LAN address leaking in the candidate list on the other.

From WebRTC's point of view the whole config is just:

turn:127.0.0.1:<port>?transport=tcp
Enter fullscreen mode Exit fullscreen mode

There's a cost. Tor adds latency, and a call takes a couple of seconds longer to connect. That's why it's off by default, you turn it on in Settings.

What if Tor isn't working right now? By default the call then goes through our regular relay, and the app tells you plainly that the relay can see your IP. The other person still can't, there are no direct paths in that case either. If you turn on "calls only through Tor", that call just won't happen.

The experiment

My phone is a Samsung on Android, version 2.1.7 from Google Play, not rooted. No root means no tcpdump on the phone. But over adb you can read /proc/net/tcp and /proc/net/udp, and every socket there has the owning app's uid. Once a second I dumped every Umbera socket:

adb shell 'for f in tcp tcp6 udp udp6; do
  awk "NR>1 && \$8==10803 {print \$2, \$3, \$4}" /proc/net/$f
done'
Enter fullscreen mode Exit fullscreen mode

At the same time I ran tcpdump on our server for anything coming from my home IP. That way I could see both ends: where the phone connects, and what the server receives.

Two calls to the same person. First with Tor, then without.

Over Tor

While the call was up, this is everything Umbera had open to the outside (I've masked our own addresses):

18:49:49  tcp  51.75.126.205:9001     <- Tor relay
          tcp  64.65.0.45:443         <- Tor relay
          tcp  <our server>:443       <- the app's regular channel
          lo   127.0.0.1:35337        <- opened when I hit call
Enter fullscreen mode Exit fullscreen mode

I checked both outside addresses against the Tor Project's public relay directory (onionoo): AmberFalcon and mchawking, both Tor relays. Port 35337 on localhost is the local "relay", it showed up the second I started the call.

Not a single address belonging to the other person. None of our relays on port 3478 either.

On the server, zero UDP packets from my IP for those two minutes. Only TCP on 443, which is the app's regular channel. More on that below.

Same call, no Tor

I switched the setting off and called again:

18:52:24  tcp   <relay 1>:3478
          tcp   <relay 2>:3478
          tcp   <relay 3>:3478
          tcp   192.168.27.x:50962        <- the other person, LAN
          tcp6  2a02:xxxx:...:50967       <- the other person, public IPv6
          tcp   10.x.x.x / 11.x.x.x       <- more of their addresses
Enter fullscreen mode Exit fullscreen mode

And the server immediately sees the media stream coming from my home address:

18:52:31  IN  <my IP>.60240 > <server>.3478: UDP, length 100
Enter fullscreen mode Exit fullscreen mode

Per minute on the server it's pretty clear:

minute   TCP    UDP
18:49   1369      0   <- Tor call
18:50   1160      0
18:51   1461      0
18:52   5413    139   <- regular call
18:53   1695     34
Enter fullscreen mode Exit fullscreen mode

The other person happened to be on the same home network, so on the regular call the phone went straight to their LAN address. Fast and convenient. Also a nice illustration of how much the other side learns about you.

What Tor doesn't hide here

I don't want to oversell this. In this test Tor covered the call only. The app's regular channel, the one that carries messages and call signaling, went to the server directly. You can see it in the table, TCP on 443 the whole time. So the server knew someone at my address was using Umbera. But no voice or video from my address reached it, or reached the other person.

One more thing. Tor hides the address, not the fact that a call happened. The server that relays signaling knows there was a call. It can't see what was said, but it knows the call took place. Hiding that too is a separate, much bigger problem, and I haven't solved it yet.

So

I wanted to see this with my own eyes rather than take my code's word for it. The difference came out roughly how I expected, just more obvious: on one call the phones swapped every address they had, on the other they swapped none.

If you want to try this yourself, all you need is adb and an Android phone. The script above works without root on any app, you just need its uid (cmd package list packages -U your.package.name). Try it on whatever app you normally call with. It can be interesting.

Top comments (2)

Collapse
 
userxnom profile image
Abdullah Naseer •

This is the kind of privacy claim I actually believe, precisely because you didn't ask me to believe it — you showed the sockets. Zero UDP from your home IP during the Tor call, versus the regular call lighting up the server with UDP the moment you dialed, is a cleaner proof than any architecture diagram. The detail that stuck with me is the fallback: if Tor isn't working, the call quietly goes through the regular relay. I get why — a failed call is worse than a less private one for most people — but for the users who turn this setting on, is failing open the right default? I'd want a strict mode that refuses the call rather than leaking my IP when Tor is down. Did you measure how much Tor actually added to connect time in practice, and did it ever push call setup into timeouts?

Collapse
 
umberaapp profile image
Umbera •

Thanks, that was exactly the point of doing it with real sockets instead of a diagram.

Strict mode is already there. In Settings, next to calls over Tor, you can turn on "calls only through Tor". With it on, if the Tor path isn't up, the call just doesn't start, nothing goes through the regular relay. Without it, the fallback isn't silent either: the app tells you that the relay can see your IP on that call. I went with that as the default because most people who flip the Tor switch still expect calls to work, but I see your point, and for some users strict is the only sane choice.

On timing, honestly I didn't log exact numbers in this test. It felt like a couple of extra seconds to connect, which matches what I'd expect from one extra Tor round trip each way. No timeouts in these runs. Measuring it properly across different networks is a good idea for the next write-up.

One note for iPhone users: the iOS side of this lands with the update that's currently in Apple review. Android and desktop have it now.