Security Audits and Tests
Trackarr is attacked on purpose before each major release: the code is reviewed, then the findings are reproduced against a running instance, fixed, and replayed. This page lists what was tested, what broke, and what changed. Numbers are the ones measured during the tests.
Findings are described here once a fix has shipped. Work that is still open is listed at the end without the details that would help an attacker.
How the tests are run
| Layer | What it is | How to run it |
|---|---|---|
| Unit tests | tests/security (request guards, description policy, rate limits, client IP resolution, panic mode crypto, session rules, honeypots) | npm run test:security |
| Tracker tests | Announce parsing, credit rules, limiter, snapshot, in tracker/src | cd tracker && cargo test |
| Attack bench | A production build on throwaway Postgres and Redis containers, client addresses simulated through the trusted proxy header, the Rust tracker compiled from source, and a real browser for anything that renders | manual, scripted with curl and Node |
| Live server | The same attacks replayed on a public demo instance behind Caddy, plus a full TCP port scan and a host review over SSH | manual |
| Dependencies | npm audit --omit=dev and cargo audit | also run in CI |
| Host | SSH, brute-force protection, updates, firewall. The script itself was run on a fresh Debian 13 machine, with and without an SSH key in place | sudo ./scripts/harden-host.sh --check |
The bench matters because several findings below passed code review for months: they only showed once a browser, a proxy and two accounts were involved.
December 2026 (v1.4.0)
Scope: the whole repository (188 API endpoints, the Rust tracker, Docker and Caddy configuration, install scripts, CI), then the attack bench and the demo server.
Tests and results
| # | Test | Before | After the fixes |
|---|---|---|---|
| 1 | One anonymous request with a crafted 8 KB query string | The request filter ran for 45 s and every other visitor waited (3.8 s with 4 KB on the demo server) | 400 in 3 ms |
| 2 | Three anonymous 250 MB bodies sent to the login endpoint | Process memory went from 86 MB to 1.7 GB. On the demo server two 200 MB bodies took the app from 106 MiB to 885 MiB of its 1 GiB limit | 413 in 4 ms, memory unchanged. Bodies of unknown size get 411 |
| 3 | A torrent description with a <style>, a fixed banner, a sign-in form and an image pointing to /.env, opened by a moderator in a real browser | Page restyled, banner shown above the site, form rendered, and the moderator's address blocked for 5 minutes because the image request hit a trap path | Markup removed, image dropped, the viewer is not affected |
| 4 | An HTML form posted from a sibling subdomain with the admin's cookie | A member was banned: the server never looked at where the request came from | 403, for forms, scripts and images sent by another origin |
| 5 | Ten wrong passwords for the admin's username from one address | The admin was refused for 15 minutes, with the right password, from any address | Only the attacking address is refused. Under an attack from many addresses, a browser that already signed in still gets in |
| 6 | Registering Alice and SEC_ADMIN next to alice and sec_admin | Both accepted | 409 Username already taken |
| 7 | Eleven writes in one minute (comments, or anonymous requests from a shared address) | The whole address was blocked from the site for 5 minutes | The eleventh gets 429. Only repeated violations lead to a block, which now doubles for repeat offenders as intended |
| 8 | Panic mode: a member edits their torrent while the database is encrypted, then the admin restores | Restore failed with the right password and the database stayed encrypted | The edit is refused (503) and restore tolerates such rows |
| 9 | Panic mode: two encryption requests at once; demoting then deleting the first admin | Ciphertext encrypted twice with a lost salt; panic password hash deleted | Second request refused; the account holding the hash cannot be deleted and is found whatever its role |
| 10 | Tracker: event=completed from an account that never downloaded | A snatch and a Hit and Run entry were recorded, which opens the seeding bonus | Ignored. A completion counts when the tracker saw the peer leech first |
| 11 | Tracker: announces from an account on hold or waiting for payment | Accepted | Account on hold / Payment pending |
| 12 | Tracker: 1,400 MiB of upload claimed in 15 s on a 1.2 KB torrent, with a second account as leecher | Credited silently | Still credited (see open work), and an alert reaches the admins |
| 13 | Paid registration: one Solana transfer naming the references of several invoices | Each invoice counted the full amount (found by review, not run on-chain) | Such a transfer pays nobody |
| 14 | A 2 MB salt sent at registration | Stored, and returned to anyone asking for a login challenge | Refused |
| 15 | Search for don't | 400: the request filter saw an attack | Works |
What changed in the code
- Request guards (
server/utils/requestGuards.ts): requests sent by a page of another origin are refused using the browser's Fetch Metadata headers, withOriginas a fallback. Bodies must be JSON or multipart, declare their length, and stay under 1 MB (11 MB for uploads). The pattern-matching filter on query strings is gone: queries are parameterized and output is escaped where it is rendered, so it protected nothing and was itself the vulnerability. - Descriptions (
shared/utils/descriptionPolicy.ts): an explicit list of tags and attributes, three allowed style properties, no image from the site's own pages, and links and images to other sites blocked by default outside a list of trusted hosts that admins edit in Admin → Security. - Rate limits: exceeding a limit answers
429; the address is blocked only when it keeps doing so. Trap paths no longer block a visitor whose browser was made to request them by a page. - Login: failures are counted per account and source address, and per account across all addresses. The second counter pauses logins except for browsers holding a known device token.
- Panic mode: one run at a time, torrents cannot be edited while encrypted, restore keeps rows it cannot decrypt instead of failing.
- Tracker: account state checked on every announce, snatches recorded from observed completions, seeding time counted once per member and torrent, hashed addresses in abuse events.
- Two-factor authentication: TOTP codes from any authenticator app, ten single-use recovery codes, and a setting that requires it for moderators and admins. Enrolling asks for the password again, a code cannot be replayed, and turning it on signs every other session out. See Two-Factor Authentication.
- Audit log: every state-changing staff action (57 admin and moderator endpoints, plus staff acting on a member's torrent, comment, forum post or bounty) is recorded with its author, target and a summary from which credentials are redacted. Admins read it in Admin → Security. Granting admin rights, changing payment details and panic mode events also raise an alert.
- Forum, bounties, invoices: topics and posts are paginated; a post in a locked topic can no longer be deleted by its author; nobody can accept a bounty fill that pays themselves; one open invoice per account and coin, a Bitcoin address index is never handed out twice, time-locked Monero outputs do not count as paid.
- Database: the application and the tracker connect with a role that is not a superuser and cannot create roles or databases.
scripts/db-split-role.shmigrates an existing install. - Security updates: a release that fixes a vulnerability shows a red banner to the admins of every instance that has not installed it, and an alert on their webhooks.
- Edge and host: Caddy caps request sizes and drops client addresses from its access logs, and the monitoring host can be limited to chosen addresses.
scripts/harden-host.shchecks SSH, fail2ban, the firewall and automatic security updates.scripts/backup.shmakes database backups, encrypted withagewhen a recipient key is set, andscripts/restore.sh --verifyproves a backup loads. - CI: the test suite and the dependency audits run on every pull request, with weekly dependency updates.
Checks on the new protections
The fixes and the features added with them were verified the same way, by a script of 41 requests against a production build, then in a browser:
- two-factor: no enrolment without the password, a used code refused, a recovery code accepted once, other sessions closed when it is turned on, staff without it stripped of every staff power while it is required
- audit log: staff actions recorded, no credential in any entry, closed to moderators and members
- security updates: a security release found behind a newer ordinary one, banner shown to admins only, one alert per release
- installer: a full unattended install on a fresh Debian 13 machine, then the first account, a backup, a verified and a full restore, the host hardening applied, and two more installer runs that changed no key of the configuration
What held
These were attacked and did not give way:
- Every API endpoint that is not meant to be public checks the session, and roles are read from the database on each request, never from the cookie.
- No SQL built from input, no script execution from member content (DOMPurify plus a nonce-based Content Security Policy).
- Client address headers cannot be forged through Caddy: a request with a fake
X-Forwarded-Forwas attributed to its real address on the demo server. - A full TCP scan of the demo server found ports 22, 80 and 443 only. Postgres, Redis and the tracker's private API are not reachable from outside.
- Private messages can only be read by their participants, staff included. Bonus point debits are atomic: no double spend through concurrent requests.
- No secret in the git history.
npm auditreports nothing on production dependencies.
Host findings
The demo server itself was the weakest part: SSH accepted passwords for root, 5,598 password guesses arrived in 24 hours, there was no fail2ban, no firewall, no automatic security update and no backup. None of this is specific to Trackarr, which is why the installer now offers to check the host. See Host hardening.
October 2026 (v1.0.0)
First full audit, centred on the Rust tracker that had just replaced the Node one.
| Finding | Fix |
|---|---|
| A member could register unlimited peers with random peer ids until the tracker ran out of memory | Peers capped per member and torrent |
| Random passkeys and info hashes each cost one database query | Shape check, and a per-address failure limiter in front of the database |
| A member could farm upload with their own leecher | Leechers of the same account do not count |
| No header timeout and no connection cap on the tracker | Accept loop with a timer and a connection limit |
| The login verifier was stored as is: a database dump was enough to sign in as anyone | Stored as a scrypt hash, converted at startup |
| Rate limits per full IPv6 address, none per account | Limits per /64 and per username |
| Sessions could not be revoked for 7 days | session_version checked on every request |
Database and Redis URLs inlined in the build, .env in the Docker build context | Read from the environment at runtime, .dockerignore |
| HA control plane (etcd, Patroni, Sentinel) without authentication | Passwords everywhere, dangerous Redis commands renamed |
| Panic mode left banned IPs, last IPs, private messages and shoutbox in clear | Covered |
| Content Security Policy allowed inline scripts | Per-response nonce |
Known limits and open work
- Upload and download figures come from the client. This is how BitTorrent works: the tracker cannot see transfers. Trackarr bounds what an announce can claim, refuses self-seeding between a member's own peers, and now alerts on amounts a swarm could not have taken. Matching each upload against the downloads of other members is planned.
- Sensitive settings are not behind a second confirmation. An admin session can change where payments are received without typing the password again; the change is logged and raises an alert.
- Payment settings stay readable in panic mode. The receiving keys are needed to recognise payments, so a seized database still links the instance to its wallet. Invoices themselves are encrypted.
- The multi-account guard compares exact addresses. Two addresses of the same IPv6 /64 are seen as different.
- Images from trusted hosts still reveal the viewer's address to that host. Keep the trusted list short, or leave only the built-in screenshot host.
Reporting a vulnerability
Please do not open a public issue. Use Security → Report a vulnerability on the GitHub repository (private vulnerability reporting), with the version, the steps to reproduce and what an attacker gains. Reports stay private until a fix is released, and you are credited in the release notes if you want to be.