Security
How to report a vulnerability: SECURITY.md. This page is the threat model and the controls.
What Tunnex protects
| Asset | Where |
|---|---|
| Webhook payloads (customer and payment data) | Server database until retention; developer machines' local stores |
| Inbox signing secrets | Server database, encrypted (AES-GCM, key derived from TUNNEX_SECRET_KEY) |
| API tokens, console sessions | Tokens: SHA-256 in the database, shown once. Sessions: HMAC-signed cookies |
| The developer's local services | Reached only through the developer's own client |
| Captured local traffic | ~/.tunnex and the inspector on 127.0.0.1:4040 |
Actors and trust boundaries
- The internet reaches
<sub>.<domain>(tunnels and inboxes) andconnect.<domain>(console, API, client endpoint). Everything it sends is untrusted. - Providers (Stripe, GitHub, …) post to inboxes; authenticity comes from their signatures, checked at the edge.
- Team members act within their role (member, admin, owner); tokens act within their scopes.
- The server operator sees everything stored on the server (event bodies, request metadata) and can read basic-auth credential hashes. Self-hosting exists so this operator is your company.
- Other websites in the developer's browser must not reach the local inspector.
Controls
Edge
- Policies are enforced on the server, before the request reaches the developer's machine: IP and path
allowlists, API keys, basic auth, email SSO (GitHub-verified emails only), rate limits, a stream limit per
tunnel (503 beyond it), and a warning page in front of anonymous tunnels.
- X-Forwarded-For/X-Real-IP are accepted only from server.trusted_proxies and rebuilt otherwise; incoming
X-Tunnex-* headers are stripped so apps can trust the identity headers the edge adds.
- Paths must be origin-form (/…); the client builds local URLs from the tunnel's own target, so a crafted path
cannot redirect a request to another host.
- Inboxes: size limit, per-inbox rate limit, IP allowlist, signature verification with constant-time compares
and a 5-minute tolerance on timestamped schemes, invalid signatures rejected by default.
Accounts and access
- Passwords: scrypt, computed in a thread pool so a login burst cannot stall the event loop; login and signup
are rate limited.
- Console cookie: HttpOnly, Secure over HTTPS, SameSite=Lax; state-changing requests with a cookie need a
same-origin Origin (CSRF). "Log out everywhere" invalidates every session (session_epoch).
- API tokens: scopes (tunnels, listen, inboxes:read, inboxes:write, account), optional expiry (≤ 365
days), last-use tracking; revocation disconnects live clients using the token.
- Team roles are checked in the domain layer for every action (one table: tunnex_server/domain/teams.py); a
team always keeps an owner; invite codes are single-use, expire, and are stored hashed.
- Linking GitHub to an existing password account with the same email removes the password, revokes its tokens
and sessions — an attacker who pre-registered the email loses access.
- Redirect targets (next=) must be same-origin paths; control characters and anything a browser would
resolve elsewhere are rejected. SSO codes are single-use, short-lived and bound to the exact tunnel host.
- Audit log of account, token, team, invite and inbox changes, readable by team admins.
Client and inspector
- The inspector listens on loopback by default, accepts only its own Host values (DNS rebinding), rejects
foreign Origins including on its WebSocket (cross-site WebSocket hijacking), requires a custom header for
writes (CSRF), and sends no CORS headers.
- Replay from the inspector goes only to the tunnel's own local target.
- Tokens never go in tunnex.yaml (the loader rejects a token: key); they come from TUNNEX_TOKEN or the
profile file (~/.tunnex/config.json).
Operations
- Logs redact tokens, whsec_ secrets, Authorization values and password|secret|token= parameters.
- Control-plane responses carry X-Content-Type-Options: nosniff, X-Frame-Options: DENY,
Referrer-Policy: same-origin and HSTS over HTTPS; edge pages are no-store and noindex.
- tunnex.org (the website, not the product) counts visits with a self-hosted Umami: no cookies, the script and
its endpoint are served from tunnex.org, the visitor's IP is used for a country lookup and not stored, and
browsers sending Do Not Track are not counted. Self-hosted Tunnex servers include no analytics. The admin
dashboard reads the database through a read-only role without access to passwords, tokens, secrets, webhook
bodies or IP addresses (deploy/admin/).
- The console and the inspector are served with a strict Content-Security-Policy (own scripts, styles, fonts
and API only; no inline scripts, no framing) and load nothing from third parties.
- Handshakes are rate limited per IP; anonymous clients are limited per IP.
- The server refuses to start over HTTPS without a secret key.
Accepted risks
- Basic-auth hashes. The client sends
SHA-256(user:password)so the server never sees the password, but the hash is unsalted and an operator could brute-force a weak password. Use basic auth for demos; use SSO or API keys to protect anything that matters. - Stored payloads. Inboxes store webhook bodies by design. Keep retention short for sensitive providers, restrict who is on the team, and back up the database as carefully as the data in it.
- Anonymous tunnels can be abused for phishing; the warning page, rate limits and the abuse contact are the
mitigations. Private servers turn them off with
auth.anonymous_tunnels: false(and signup off). - Single node. A crash disconnects clients until restart; events are only acknowledged after they are stored.
Review log
A full review was done on 2026-10-14 (baseline 9a53b80, release 26.10.10.22). Findings and their status:
| # | Severity | Finding | Status |
|---|---|---|---|
| S1 | High | The inspector's WebSocket checked only Host: any website could read captured traffic live. |
Fixed: Origin must be absent or the inspector's own. |
| S2 | High | GitHub sign-in linked to an existing password account by email (account pre-hijacking). | Fixed: the password, tokens and sessions are revoked on first link. |
| S3 | Medium | Open redirect via next=/%09/evil.com (browsers strip TAB/CR/LF). |
Fixed: one validator, control characters rejected, property tests. |
| S4 | Medium | /sso/authorize?host=myapp.tunnex.org:443@evil.com redirected with a signed code. |
Fixed: the host must be exactly <sub>.<domain>[:port]. |
| S5 | Medium | scrypt on the event loop: login bursts stalled every tunnel. | Fixed: thread pool. |
| S6 | Medium | Handshakes not rate limited; each anonymous HELLO could insert a row. | Fixed: per-IP handshake limit. |
| S7 | Medium | No limit on concurrent streams per tunnel (memory exhaustion). | Fixed: max_streams_per_tunnel. |
| S8 | Medium | Replay and forwarding concatenated http://127.0.0.1:<port> with the path (@evil.com/x). |
Fixed: origin-form paths only, URLs built from the target. |
| S9 | Low | No "log out everywhere". | Fixed. |
| S10 | Low | API tokens had no scopes or expiry. | Fixed: scopes, expiry, audit log, disconnect on revoke. |
| S11 | Low | Client-supplied X-Forwarded-For passed through. |
Fixed: rebuilt at the edge. |
| S12 | Low | Inspector unusable in containers without disabling the Host check. |
Fixed: --inspector-host and an explicit allowlist. |
| S13 | Low | Unsalted basic-auth hashes. | Accepted, documented above. |
| S14 | Low | UDP reflection through public UDP ports. | Removed with UDP tunnels. |
Also verified without findings: HMAC signer with purpose and expiry, constant-time comparisons, host-only SSO cookies, single-use SSO codes, path allowlist normalisation, escaping in server pages and in the UIs.