termux-mcp gives whoever holds a full token shell access to your phone, plus the Android
APIs Termux has been granted: camera, microphone, location, contacts, SMS, notifications,
clipboard. There is no sandbox around the shell, by design. Deploy it the way you would deploy
an SSH server with password auth, not like a web app.
In scope
- A remote attacker who obtains a token, or who can reach the HTTP port.
- A malicious or confused agent that has a
fulltoken and follows instructions from untrusted content (a web page, a repository README, a file the user asked it to read). - A compromised client machine on the same network.
Out of scope
- Anything requiring root. Termux runs unprivileged; so does this server.
- Other Android apps on the device. The Termux sandbox still applies.
- Physical access to an unlocked device.
| Control | Detail |
|---|---|
| Destructive command gate | Commands matching the destructive set are refused unless the caller passes confirm: true. Covers recursive deletes, mkfs, dd to a device, block-device writes, fork bombs, package removal, reboots, su, SELinux tampering and /system writes. |
| Confirmation on mutating tools | fs_delete, fs_move over an existing target, fs_tar extract, pkg_upgrade, proc_kill, sms_send, tmux_kill all require confirm: true. |
| Jailed file API | fs_* tools resolve against paths.allow and subtract paths.deny, with per-entry except lists. The default deny list hides system partitions, /proc, /dev, /etc and other apps' data. |
| Protected files | The audit log and the config file cannot be written or deleted through any tool, so an agent cannot erase its own trail or escalate by rewriting the policy. |
| Token scopes | read reaches read-only tools; full reaches everything. The split is derived from each tool's readOnlyHint annotation, so it cannot drift from the tool list. |
| Constant-time token compare | Bearer tokens are compared as SHA-256 digests with crypto.timingSafeEqual. |
| Host and Origin validation | Requests whose Host is not in http.allowedHosts get 403, which blunts DNS-rebinding attacks against a locally bound server. Entries may be exact hosts, IPv4 CIDR ranges, or *. |
| IPv4-only listener | bind: 0.0.0.0 creates an IPv4 socket only, so a globally routable IPv6 address on the phone is not exposed by a wildcard bind. The server reports at startup if it finds one. |
| Path traversal | .. segments are resolved before the allow/deny check, so traversal cannot escape the jail. |
| Output caps | Per-command output, file reads, search matches, listing depth and concurrent jobs are all capped, so a runaway command cannot exhaust memory or the disk. |
| Timeout containment | Timed-out commands have their entire process group signalled, not just the direct child. |
| Audit log | Every tool call, refusal, auth attempt and process signal is written to ~/.termux-mcp/audit.log as JSON lines, rotating at 5 MiB. |
| stdio is unrestricted | A client that launches the server over stdio already has local code execution, so no token is required. Treat stdio as full trust. |
- It does not prevent an authorized agent from reading your Termux files, exfiltrating them over the network, or installing software. No design can, short of removing the tools.
- It does not protect the Termux:API permissions you have already granted. If Termux can read
your contacts, so can any tool that calls
contact_list. - It does not encrypt transport. Run it over a VPN or an SSH tunnel, not over an open network.
- Prefer
127.0.0.1or an SSH tunnel when you can.0.0.0.0is for the convenience case — a laptop on the phone's own hotspot — and it means anything on that network can reach the port. With SSH nothing is exposed at all. - If you bind
0.0.0.0, keep the private-range allowlist. The default192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10plus loopback is deliberate. Never put0.0.0.0/0or*inallowedHostson a network you do not control: that turns off the DNS-rebinding guard entirely, and bearer tokens become the only thing standing between a browser on your LAN and a shell on your phone. - Rotate the tokens after any hotspot use if you are not sure who joined.
node bin/termux-mcp.mjs --init --forceand checkaudit_tailfor the session. - Set
http.allowedHoststo the exact address clients use, or the ranges they use. A wildcard defeats the check. - Keep
config.jsonat600, inside Termux's private directory, never in a git repo. Note that/storageis world-readable to other apps on many devices, so do not keep the config there. - Use the
readtoken for any client that only browses. Reservefullfor deliberate interactive sessions. - Review the audit log after granting access to a new agent:
audit_tail, ortail -f ~/.termux-mcp/audit.log. - Prune the
readscope if a client does not needcontact_list,call_log,sms_list,camera_photoormic_record. Delete those tools fromsrc/tools/api.jsor deny them inapi.denyif you never want them reachable. - Revoke Termux:API permissions you do not need. The server cannot escalate past them, so tightening Android settings is the strongest control you have.
Please do not open a public issue for a security problem. Use GitHub's private vulnerability reporting on the repository, or email the maintainer. Include the version, how you reached the server, and what you were able to do.
We aim to acknowledge a report within a few days. Please give us a reasonable window to ship a fix before disclosing publicly.