Security
AFTAB protects sign-in with a login guard, two-factor sign-in and passkeys, keeps its secrets sealed in the database, signs what it hands to other servers, and checks every update before it runs. This page says what each protection does, how to set it, and where it stops.
Sign-in
Section titled “Sign-in”The Login guard, in Settings → Security, blocks an address after 5 failed sign-ins within 10 minutes, for 60 minutes. These are the defaults of guard_attempts, guard_window and guard_ban, and only the owner changes them (Failed attempts, Within (minutes) and Block for (minutes)). Blocks survive a panel restart, and for IPv6 the whole /64 counts as one address. The card lists the blocked addresses and unblocks them, and sudo aftab unban lifts them all, or sudo aftab unban ADDRESS one. Turn the guard off only if something in front of the panel already limits sign-in attempts.
The guard also protects each account name. After 10 failed sign-ins to one name within 10 minutes, from any addresses, each further sign-in to that name waits 30 seconds after the last failure. An address that signed in to the name within the last 30 days skips the wait, so guessing cannot lock the owner out. Wrong current-password checks on a signed-in session count toward the same per-account limit without skipping known addresses.
Two-factor authentication, in Settings → Account, makes sign-in ask for a 6-digit code from an authenticator app as well as the password. Scan the QR code, enter the code and confirm with your password. Passkeys, in the same tab, sign you in with a fingerprint, a face, a PIN or a security key, and work only when the panel is opened over HTTPS with a domain name. The require_2fa setting, in Settings → Security, makes admins and resellers use two-factor sign-in: an account without it can only set it up, and then carries on. The owner is not asked.
A lost phone is fixed on the server: sudo aftab 2fa-off turns off two-factor sign-in for the owner, and sudo aftab 2fa-off USERNAME for another account. The owner can also open Edit on the account’s row in Accounts, where the form says Two-factor sign-in is on for this account, and turn it off there.
A session lasts 168 hours (7 days) by default, which is session_hours, set under Settings → Panel as Session length (hours). Signed-in devices, in Settings → Account, lists where an account is signed in and ends any of them, and Sign out all other devices ends all but this browser. A new password, a switched-off account and a changed role end the account’s sessions.
API tokens
Section titled “API tokens”The API tokens card, in Settings → Security, lets your own scripts use the panel with the header Authorization: Bearer and the token, and is hidden until you turn on Selling and operator tools in Settings → Panel (the full_mode setting). Each has a name, an expiry and an access level: Full, which is what the account can do except the things below, Clients, which reads everything but changes only clients, and Read only, which cannot change anything. The token is shown once, and the panel keeps only a hash of it. No token can change the password, two-factor sign-in or tokens, make or restore backups, or install updates: these need a signed-in browser session.
Secrets at rest
Section titled “Secrets at rest”The panel’s secrets are kept sealed in the database: bot tokens, two-factor secrets, the key that signs sign-in cookies, the key that signs what bridges and servers are told, WARP and SOCKS5 logins and the backup key. Each is encrypted with AES-256-GCM under one key, the secrets key, kept in /etc/aftab/secrets.key with the mode 0400, which only the panel’s user can read. A value is bound to the place it lives in, so one copied to another place does not open there. A copy of the database file alone is of no use without the key.
This does not protect against someone who can read the data folder, because the key is there for the panel to read. It leaves clients’ WireGuard keys and subscription links as they were. Backups carry a copy of the secrets key so that a restore opens its secrets, which is why an unencrypted backup gives its secrets away as plainly as before sealing: see Backups and restore.
If the key is lost, those secrets read as not set, and the panel does not make new ones over them: signing in, which needs the key that signs its cookies, and what bridges and servers are told wait until the right secrets.key is back, then restart the panel. A join and a revoke wait with them: neither uses up a join secret nor cuts a bridge, an exit or a server off while nothing new can be signed for it. The panel says at each start which secrets do not open. To give them up instead, run sudo aftab compromised --nodes on the server: it makes a new key for sign-in and a new key for bridges and servers, and every bridge and exit then joins again with a new install command. Enter the tokens again. Two-factor sign-in stays on until you clear it with sudo aftab reset-admin --clear-2fa.
Who runs what
Section titled “Who runs what”On a server with systemd the installer makes two users that cannot log in. aftab-panel runs the panel and the DNS resolver with only three network permissions, inside a systemd sandbox, and owns /etc/aftab. aftab runs wstunnel and hev-socks5-tunnel, which cannot read the database. The few jobs that need root, such as kernel tuning, loading kernel modules, opening ports in ufw or firewalld, installing updates, AmneziaWG and Tor, go to aftab-helper.service, which does only those, with arguments it checks itself. The panel never runs as root: on a server where it cannot run this way, the installer stops before it changes anything and prints the fix in one line, and an update stops the same way if the server changed since.
Privacy and the web
Section titled “Privacy and the web”Hide clients’ IP addresses (privacy_hide_ips) stops the panel storing or showing clients’ own addresses, and a TLS handshake failure is counted without the visitor’s address. See Clients and plans. Behind Cloudflare or your own proxy, add it under Trusted proxies (trusted_proxies) so that sign-ins and blocks see the visitor’s real address. Tell browsers to use HTTPS only (HSTS) (hsts) makes a browser that saw the panel over HTTPS refuse plain HTTP for six months: turn it on only with a certificate browsers trust. See HTTPS.
What the panel looks up on the internet, all over HTTPS, and none of it carries a client’s data. Once a day it asks GitHub for the published release and checks its signature. When the server’s own address or country is not known yet, it asks api.ipify.org, ipv4.icanhazip.com or ifconfig.me for the address and api.country.is, ipinfo.io or ipapi.co for the country; these services see this server’s address, and aftab country ADDRESS sends the address you give it to them. Country address lists come from raw.githubusercontent.com and ipdeny.com, and rule lists from the GitHub releases you chose under Settings → Network. Certificates talk to Let’s Encrypt (and to Cloudflare for a DNS challenge), a WARP exit to Cloudflare, the Telegram bot to api.telegram.org, and checks of an exit go out through its own tunnel to the same echo services and to Cloudflare’s trace page. Nothing else leaves the server unless you set a webhook or a DNS-over-HTTPS resolver yourself.
If the panel may have been taken
Section titled “If the panel may have been taken”If someone may have copied the database, a backup or a signed-in session, open Settings → Security, and under If the panel may have been taken press Replace the secrets…. It asks for your password. You stay signed in on this browser, and every other session and every API token ends at once. The key that signs sign-in cookies is replaced. Also cut off bridges and exits, which is ticked by default, replaces the panel’s node key and every bridge’s and exit’s keys: each stops until you run its new install command. Also register WARP devices again needs Cloudflare. On the server, the same is sudo aftab compromised, with --nodes and --warp for the two extras, and you type COMPROMISED to confirm.
Still yours to change: the admin password (sudo aftab reset-admin), two-factor sign-in (turn it off and on again, because the copy holds its secret), the Telegram bot token, each webhook’s signing secret, and any other way into the server. It does not replace clients’ keys or links: for a client, New keys and New sub link do.
A lost or seized bridge or exit server is a smaller case: Revoke it. See Iran bridges.
Factory reset, at the bottom of Settings → Security, or sudo aftab factory-reset, takes the panel back to a fresh install and deletes every client, inbound, exit, bridge, rule, plan, account and token. Your sign-in and the panel’s address and port stay, and a backup is saved first.
What can go wrong
Section titled “What can go wrong”- You are blocked from signing in. Wait out the block, or run
sudo aftab unbanon the server. - You lost your password.
sudo aftab reset-adminsets a new random one and prints it. - A lost phone.
sudo aftab 2fa-off, as above. - A token leaked. Delete it in API tokens: anything using it stops working.
- A backup leaked. If it was not encrypted, run Replace the secrets…, change what is listed as still yours, and give clients New keys, because a backup holds every client’s keys.
- Secrets do not open after a restore. The key is not the one they were sealed with: see above.
- The activity log says it was changed. The log is a chain in which each event is tied to the one before it, and the Activity page says whether it is unbroken: see Monitoring and alerts.