DEV Community

Cover image for legalPrivacy: Hyper-realistic Traffic Analysis Killer [Open Source!]
Ason Peikoff
Ason Peikoff

Posted on

legalPrivacy: Hyper-realistic Traffic Analysis Killer [Open Source!]

There is a glaring hole in network privacy and security, and almost nobody has a defence against it.

Your traffic is encrypted now. Almost everything you load is HTTPS, and your DNS might be too. So your ISP cannot read your pages anymore.

But it can still watch the shape of you.

What time you get up. When you go quiet at lunch. The burst of searches at 9pm, the long silence after midnight, the same handful of sites every morning, the way you always check the weather before you check the news. None of that is content. All of it is visible to anyone who can see your connection: your ISP, your DNS provider, the Wi-Fi at the hotel, the network admin at work.

That metadata is a fingerprint, and it is a good one. Researchers have shown you can identify people and infer a lot about them from traffic patterns alone, without ever decrypting a single packet.

Most users have nothing for this at all. No tool, no setting, no defence. Encryption solved the easy half of the problem and left the other half wide open.

That is the hole I built legalPrivacy to fill.

The Tor paradox: trying to hide can make you stand out more

This hole is worst for the people who care most about privacy.

If you use Tor, your ISP cannot see what sites you visit. But it can see that you are using Tor. That alone marks you out. You are not one ordinary connection among millions anymore. You are the one connection using Tor, and that gets you flagged for extra scrutiny and extra analysis, precisely because you tried to hide.

The same is true, in a smaller way, for a VPN and for other conspicuous privacy tools. The tool that is supposed to protect you announces itself. It puts a label on your traffic that says: this person has something to hide, look closer.

So privacy-conscious users end up more highly surveilled and analyzed, not less. They did everything right, and they still stand out from the crowd.

legalPrivacy takes the opposite approach. Do not stand out. Blend in. Look ordinary. Make the pattern itself uninformative, so there is nothing worth flagging in the first place.

It is open source (GPLv3), it runs on my own machine, and it generates browsing, searches, and DNS lookups that look like a person made them, because in most ways, they were made the way a person makes them: in a real browser, with pauses, scrolls, and a daily rhythm. Your real traffic is mixed in with believable noise, so the combined pattern stops being a clean portrait of you.

This does not replace Tor when you need Tor. Tor still does a job nothing else does. But Tor leaves a hole, and in a way it creates one, by marking you as a Tor user. legalPrivacy covers that hole. Use Tor for what Tor is for, and let ordinary-looking noise cover the rest of your day.

Why random browsing doesn't work

The naive version is a script that opens random URLs on a timer. That fails, because real people don't browse uniformly at random. They have steady interests, search in runs, browse in sittings, are busy in the evening and quiet at 4am, read some pages for ten seconds and some for ten minutes, go back to re-read, hover, get distracted.

Every one of those regularities is a signal. A stream of uniform random requests has a different regularity — perfectly flat, perfectly even — and that stands out just as much as doing nothing. Noise that doesn't look human doesn't hide you. It adds a second, easily filtered pattern next to yours.

So the job isn't "make traffic." It is "make traffic that survives being compared to a real person's traffic." And that is also why nothing in legalPrivacy is always one thing. A fixed pattern is itself a fingerprint. So almost everything below is a mix: a great default that favours human-looking behaviour, plus randomness, so no fixed series of behaviours can be used to identify the noise.

The full list: every kind of logic in here

Browsers and lanes

  • Real browser first: by default your own Firefox, on a private copy of your profile, in a hidden window. Visible and offscreen windows are options, not the default.
  • Browser engine is a choice, not a fixed thing: mine (your Firefox, else a mix), mix, auto, chromium, or firefox. Chromium runs through Playwright, using Chrome, Edge, Brave, or Chromium already on your machine.
  • Plain-HTTP lane: pages fetched with plain requests, no JavaScript, no scrolling. Default weight 0, so it is mostly a fallback when a real browser can't start — raise it if you want more of it.
  • Traffic mix: default browser 100, plain 0, onion 40 (only when Tor is on), pattern drift by default, with blend (same mix every hour) and alternate (one kind at a time for 1–3 hours) as options. Every hour the lane shares and the phone share wander by a random walk, and each engine wanders on its own too, so no two kinds keep a fixed ratio hour after hour. You can nudge the mix in 10-point steps.
  • Second tab: about one desktop visit in eight opens a link in a second tab while the first is read, then glances at it for a few seconds and closes it. On by default, not on search pages, not in the Tor lane, not for phones.
  • Long sessions: now and then it stays on one page a long time, or leaves it open for hours and comes back. On by default.

Pacing and rhythm

  • Rate: level 1–10, from 1 to 70 searches an hour. Default level 5 is about 11 an hour, roughly 165 over a 15-hour day.
  • Diurnal curve: peaks roughly 7–10pm, trough roughly 4–5am, range 0.35–1.6. A smoothed random walk keeps each hour close to the last, each day gets its own volume, and "away" spells ramp in and out over hours instead of switching off.
  • Sittings: about 3.6 hits per sitting, gaps of seconds inside a sitting, longer gaps between sittings, sized from the time and hits left in the hour.
  • Active hours are off by default; turn them on and it only runs 8am–11pm by default. Your own activity is off by default too; backoff pauses the noise while your own traffic is above 400 kbit/s, follow paces with it.
  • Data cap is 0 by default, meaning no cap. Low-data mode skips images, video, and fonts in the real browser. Failures back off exponentially, with jitter.

Reading, scrolling, and searching

  • Dwell is log-normal with a long tail: about 1 in 25 visits lasts a minute or more, 1 in 100 three minutes or more, 1 in 500 ten minutes or more. Reading pauses average a few seconds, about 3% are long 20–55 second "got distracted" pauses.
  • Depth is a mix: 35% skim, 45% partial read, 20% full read. Scrolls come in eased bursts, slow-fast-slow, with back-scrolls and re-reads. The mouse moves on curved paths and hovers before clicking. Sometimes it highlights a line.
  • Search results: three modes — quick glance, half a screen down with a longer pause, or one smooth skim — then it clicks a result about 85% of the time, usually near the top.
  • Search engines are weighted tiers: Google and DuckDuckGo about 70% between them, Bing, Brave, and Startpage about 24%, Ecosia, Mojeek, Qwant, and DDG Lite about 6%. No engine gets more than 20 searches an hour. Robot-check pages trigger an engine cooldown. Typos are off by default; turn them on and it occasionally swaps, doubles, or drops a letter, as people do.
  • Searches come in related runs — a topic, then a narrower question, then "best X", "reviews", a year, "X vs Y" — because researchers separate query noise from real searching by clustering queries by meaning.

Interests, personas, and sources

  • Interests are opt-in themes: 21 of them, 3 active at a time, rotating every 10 days, seeded per machine so the rotation is stable for you and different for everyone else. When on, about 30% of visits and searches follow the themes.
  • About 80% of themed searches are real queries real people typed, sampled from MS MARCO (Bing) and GooAQ (Google). The rest are built from the theme's topics.
  • Personas: Default mix is my shape, roughly 30% data science, 22% Objectivism, the rest everyday life, followed about 80% of the time, the rest random. Other personas include Data scientist, Developer, Sports fan, Student, Home cook and gardener, and Traveller.
  • Feeds: Google Trends, Wikipedia most-read, BBC headlines, MS MARCO and GooAQ queries, and Tranco top sites re-ranked by real Chrome usage (CrUX). They ship as a bundled snapshot, so nothing is fetched unless you ask for a refresh.

Identities — keeping the story straight

  • Each identity is a pinned bundle — user agent, language, pace, query taste — that stays consistent, then rotates after a random number of visits, never on a fixed beat.
  • User agents: mix by default, your own browser's agent for about 85%, a random library one for the rest. rotate (hourly or daily) and pin are options. The pool mirrors real, frequency-weighted browser populations.
  • Phones are about 10% of identities by default, deliberately few, because they are emulated here and a site that checks deeply can tell. Default device is iPhone 13, or a mix.
  • Client hints only on Chromium identities — a hint on a Firefox agent is an instant giveaway. No DNT, because DNT is dead and sending it marks you. Sec-GPC only at realistic low rates.
  • Cookies last about a day by default, and each cookie jar lives 60–140% of that, so wipes are not on a fixed beat. A fingerprint audit checks for contradictions, like a Windows agent with a Linux platform hint. Browser fingerprint values — canvas, WebGL, fonts, audio, window size — come from one seed that lasts 8–24 hours, then rotates. Tor Browser is left alone, except for window size, because it already makes every user look the same.

DNS, files, and package noise

  • DNS mode is mix by default: about 85% of the time on your normal DNS, the rest on secure resolvers, switching in random 10–60 minute blocks. Default secure primaries are three OpenNIC servers in Germany, Quad9 as fallback only when primaries are down or slower than 250 ms.
  • Honesty checks: a made-up .invalid name must not resolve, resolvers must agree, and if every answer comes back from the same machine, the dashboard says your network is intercepting DNS.
  • Browser-like DNS: A, plus AAAA and HTTPS records, and about 85% of lookups are followed tens of milliseconds later by a burst of usually 3–4 related names, the fonts, scripts, and other hosts a real page load pulls in.
  • File transfers are on by default: now and then it downloads a real public file and throws the bytes away, or uploads 10 KB to 3 MB of random bytes to Cloudflare's speed-test endpoint. Downloads come from the Internet Archive — Flickr Commons photos, Prelinger films, Project Gutenberg, open-source audio — median about 1.5 MB, capped at 20 MB, budget 10 a day. Over Tor, onion-page file links are downloaded through Tor, capped at 8 MB.
  • Package noise is auto by default: real pip and npm traffic in a throwaway environment, installs removed again, downloads deleted, sometimes a whole requirements file of 3–14 packages, with pip's cache off so nothing is kept.

Tor

  • Tor is off by default. When on, the onion lane visits only .onion sites — official mirrors of lawful public sites, plus links found on them. Ordinary web traffic, DNS, and package installs never go through Tor.
  • Tor Browser lane is off by default, because it opens a window. Turn it on and onion sites are driven through the real Tor Browser at Safest, with a throwaway profile each time; the plain requests lane is the fallback. Tor Browser can share this app's Tor, so your own browsing and the noise use the same Tor.
  • Circuits rotate every 10–40 minutes, a new identity follows 2–5 consecutive failures, and 8 identities share a circuit by default. Bridges are off by default, with automatic fallback to built-in obfs4, Snowflake, or meek bridges if Tor can't connect directly. By default it avoids US relays and relays that look governmental, and it never uses them even if that means Tor can't connect, unless you turn that strictness off.
  • Community relay: middle relay or bridge only, never an exit — the code only ever emits ExitPolicy reject *:*. Off by default, and the first run is practice mode, loopback only, nothing published.

Safety and what it doesn't keep

  • Safety screening blocks adult, gambling, weapons, drugs, violence, self-harm, hacking, and government sites. Login-walled pages get a short look, then the site rests for hours; the noise never logs in.
  • Signed-in browsing to your own Google or Microsoft accounts is off by default, read-only, clearnet browser only, never Tor. You sign in by hand in a visible window; the app never sees, stores, or types a password. A spare account is safer there.
  • MAC spoofing is Linux only, needs root, and is a separate command: random, stable, or fixed address, permanent MAC recorded first, the interface carrying the default route skipped unless forced, nothing surviving a reboot unless you pass --persist.
  • The live log and activity list live in memory only and are cleared when the app quits. No log file is written. Your own connections are never named or saved — only per-minute counts, kept for seven days, on your own machine. The dashboard listens only on your own computer and needs a token in its link. There is a Panic button: stop now, or also clear the log and cookies, or also stop Tor and delete what was recorded about connections. Metrics are off by default.

Proof, ML, health, tools, and remote

  • Proof tab: a sampler every 5 seconds sorts connections by owning program — you, legalPrivacy, or Tor — and draws a live map and a six-hour timeline with the noise-on minutes shaded, so you can stop the noise, start it again, and see the difference.
  • "Does it look like you?" is 1 minus the Kolmogorov–Smirnov distance on four rhythm comparisons — hour of day, burst length, gap length, busyness of an active minute — with p-values. Baseline priority: an imported HAR file first, then minutes observed with noise off, then browser history. With too little data it says so instead of inventing a score. "Adjust to my rhythm" turns the noise up to 2× in hours you're away and down to ½ in your busy hours, weekdays and weekends kept apart.
  • ML tab: it trains a classifier to tell your real browsing apart from the noise, using only what an ISP or DNS provider could see, and reports ROC AUC — 50% means it can't tell them apart at all. It names which signals give the noise away and which setting fixes each one, and there is a demo mode against a built-in typical person.
  • Health tab: a recommended-settings check compares the human-like switches — long sessions, second tab, DNS bursts, DNS in the browser, cookie lifetime, user-agent mix — with the recommended values and offers a one-click fix that changes only those. Tools tab: DNS leak check, resolver check, speed test (10 MB down, 2 MB up, clearnet only), proxy tester, and a polite scraper that follows robots.txt, waits a random few seconds between requests, and mixes in noise between its own requests.
  • Remote machines: run the noise on other computers you own, over SSH. One small stdlib-only file and a settings file are copied over, intensity light, normal, or busy, browser auto or off, with data caps.
  • Duck.ai chats are off by default: short made-up chats, only if you switch them on and accept duck.ai's terms.

What it doesn't keep

The live log and the activity list live in memory only and are cleared when the app quits. No log file is written. Your own connections are never named or saved, only per-minute counts, kept for seven days, on your own machine. Imported history and bookmarks are read on your computer, only site names and counts are used, and nothing is kept until you approve it. The dashboard listens only on your own computer and needs a token in its link. And there's a Panic button: stop now, or also clear the log and cookies, or also stop Tor and delete what was recorded about connections. Your settings are never deleted.

The noise also polices itself. Searches and sites are screened so it never visits anything embarrassing or risky to have on your connection, adult, gambling, weapons, drugs, violence, self-harm, hacking, government sites. Pages that demand a login get a short look and then the site rests for a few hours; it never logs in. Signed-in browsing to your own Google or Microsoft accounts is possible but off by default, read-only, and never over Tor, and honestly, a spare account is safer there.

The honest limits

Noise does not make you anonymous. A determined observer who has other data about you, your accounts, your devices, your location, can still tell. Fingerprinting at the router or CDN level is out of scope. And noise is not a substitute for Tor when you need Tor, or for a VPN when you need one. It's one layer: it makes bulk, pattern-based analysis less useful. If anyone tells you a tool like this makes you invisible, they're selling something.

That is also why the Tor point matters twice. Tor is essential when you need it, and using it marks you. legalPrivacy does not fix that marking, and it does not pretend to. What it does is cover the hole Tor leaves behind: the rest of your browsing, the ordinary hours, the pattern that gives you away even when you are not on Tor at all. Blend in there, and the moments you do need Tor stand out less, because they are not sitting on top of an otherwise perfectly readable daily pattern.

It also isn't finished. Windows and macOS ready-made downloads aren't built yet, Linux, pip install, and Docker are the ways in today, and the source launchers work on Windows and Mac.

I have built everything I can think of. Now I need help.

I want to be direct about where this stands. I have literally added every single feature I or any AI could think of, after many rounds and multiple AI providers tried to think of additional privacy-preserving features or anti-analysis logic. That is not a boast. It is where I am stuck: I have run out of ideas of my own to add, and I need other people to find what I have missed.

So please, try it, and then tell me what is missing. Run it, open the Proof tab, look at the six-hour timeline and the similarity scores, and tell me where it falls short. What would make you trust it enough to run it? That is the feedback I cannot get from my own machine.

And I am eager for others to join and take over as maintainers or developers, or to fork it. I am a data scientist type, not a true software maintainer. I will probably keep this up for myself over time, but I may not make community-facing additions unless other people join the project.

That is a real invitation, not a disclaimer. If you can maintain it, improve it, review it, break it, or take it in a direction I have not thought of, please do. Fork it, open an issue, open a pull request, or just tell me what you would change. This hole is too big for one person, and it is too important to leave to one person.

Try it, please

Please just try it. It takes a few minutes, and you can see for yourself whether the noise looks believable, instead of taking my word for it.

Grab the Linux download, chmod +x legalprivacy-launch-linux, and run it, or pip install . then legalprivacy-launch, or docker compose up -d. The first run asks three questions (how much noise, whether to add Tor onion noise, whether to start automatically) and then starts. Everything else already has a recommended value, and the dashboard is a local web page.

Repo: https://github.com/asonpeikoff/legalprivacy

Run it, open the Proof tab, stop the noise, start it again, and watch the timeline change. Then tell me what you see, and what you would add. I really want to hear it.

The project is named after Amy Peikoff's blog Legalizing Privacy, writing about why and how to legalize privacy, using the principles of private property and freedom of contract. That's the idea behind the tool: privacy shouldn't depend on asking permission from the people watching the wires. Sometimes you can just make the wires less informative.

Top comments (0)