Security
What MonkeyTester protects, how, and what it leaves to you. This page describes the family of services after the security update: the viewer requires a login, uploads need a CI token, and every network service requires a token whenever it listens beyond loopback.
Threat model
MonkeyTester is built for a home LAN with a single owner: one person owns the machines, the phones and the code host, and is the viewer's admin (who can create accounts for other people). The lab's network is 192.168.125.0/24 (this lab's — substitute your own).
- In scope: other devices on the same LAN (guests, phones, smart-home gadgets) that can reach the services' ports, and web pages open in your browser that try to send requests to the viewer.
- Out of scope: someone with an account on, or physical access to, the Linux host or the Mac; and exposing any port to the internet. Do not port-forward these services.
No software is vulnerability-free, and this page does not claim MonkeyTester is. The goal is no known holes and a small attack surface: as few listening services as possible, each requiring authentication, with the gaps that remain written down below.
Default credentials: on first start the viewer has one account, admin / admin (role admin). Anyone on the LAN who knows that can sign in, so change the password right away.
Services, ports, binds and auth
The state after the security update. Addresses are this lab's; ports are the defaults.
| Service | Host | Port | Listens on | Authentication |
|---|---|---|---|---|
MonkeyTester viewer (app.py) | Linux host | 8089 | LAN | Login required on every page and API — always on, no localhost exemption, no switch to turn it off. No self sign-up: the admin creates accounts. The CI token is accepted only on the run-upload and result-polling endpoints used by submit.py; it grants no UI or Settings access. |
| ESP32 sensor device plugin | Linux host | 8091 | Loopback (127.0.0.1) by default | The viewer reaches it via 127.0.0.1, so no token is needed by default. Bound to any other address it requires a token. |
| ESP32 server (hub) device plugin | Linux host | 8093 | Loopback by default | Same rule as the sensor plugin; both plugins have identical defaults. |
| Its fake hub | Linux host | 8092 (lab) | LAN, by design | The real sensor board connects to it over Wi-Fi, so it has to be reachable from the LAN. |
| This website | Linux host | 8001 | LAN | None: static and public by design. It holds no secrets and must never serve .git or dotfiles. |
| MonkeyTester-Plugin-Mobile-Controller | Mac | 8090 | LAN | Token required (CONTROLLER_TOKEN) — it refuses to start on a non-loopback bind without one. |
| MonkeyTester-Plugin-Build-Local (build plugin) | Mac | 8094 | LAN | Token required (PLUGIN_TOKEN) — same rule. |
| MonkeyTester-Plugin-AI | Mac | 8091 | LAN (--lan) | Token required (MTAI_TOKEN, the pairing token). |
Rules every network service follows:
- Token mandatory on non-loopback binds. If a service is told to listen on anything other than
127.0.0.1,::1orlocalhostand no token is configured, it refuses to start with a clear error. On a loopback bind the token is optional. - Tokens are compared in constant time.
GET /healthmay stay unauthenticated, but it reveals no configuration and no secrets.
What else the update hardens
- Viewer sessions: the session cookie is
HttpOnlyandSameSite=Strict; state-changing requests must come from the viewer's own origin (or be the CI-token endpoints); repeated failed logins from one address are slowed down; passwords are stored as a salted, slow hash (scrypt or PBKDF2) — an older SHA-256 hash is upgraded at the next successful login, and plaintext passwords are no longer accepted. - Security headers on HTML pages stop MIME sniffing, framing by other sites and cross-site referrers.
- Input handling in every server: external commands run without a shell and with validated arguments; every route that maps a request value to a file checks that the resolved path stays under its root; requests have size limits (oversized bodies get
413), malformed JSON gets400, and handlers have socket timeouts. - Secrets are written to files with mode
0600, never logged and never returned by anyGET.
Setting up tokens
Generate each token as a long random string, for example openssl rand -hex 32. Never commit a token or paste it into a ticket.
- Change the viewer's admin password. Open
http://<viewer>:8089/and sign in asadmin/admin— the only account on first start — and change its password straight away. There is no self sign-up: the admin creates accounts for other people on the admin-only Settings → Users page (create, reset password, delete, change role). Every user can change their own password. - Give the Mac services their tokens. They run as LaunchAgents, so the tokens go into each plist's
EnvironmentVariables:CONTROLLER_TOKENfor the Mobile Controller,PLUGIN_TOKENfor build-local andMTAI_TOKENfor MonkeyTester-Plugin-AI (itsservice install --lanwrites the agent from your shell's environment, see Mac → Serve on the LAN). Reload each agent afterwards.<key>CONTROLLER_TOKEN</key> <string><CONTROLLER_TOKEN></string> <!-- monkeytester-mobile-controller --> <key>PLUGIN_TOKEN</key> <string><BUILD_LOCAL_TOKEN></string> <!-- monkeytester-build-local --> <key>MTAI_TOKEN</key> <string><MTAI_TOKEN></string> <!-- AI --> - Enter the same tokens in the viewer's Settings. Signed in, open Settings and enter the Mobile Controller token, the Build-Local token and the token of each device plugin that has one (the AI plugin's pairing token goes in its Configure panel, as before). Each field is write-only: the viewer checks the token against the service's authenticated endpoint before saving, and afterwards shows only whether a token is configured, its last four characters and when it was saved. Use Replace or Remove to change it.
- Generate the CI token. In Settings, click Generate new CI token. It is shown once: copy it straight away. Generating a new one replaces the old one.
- Store the CI token in each app repo. In every app repo that uploads to the viewer, add a Gitea Actions secret named
MT_CI_TOKENholding the CI token. See Build & Test → Upload.
Upgrading from environment variables. If Settings has no token yet, the viewer imports it once from the old variables — CONTROLLER_TOKEN / IOS_CONTROLLER_TOKEN, PLUGIN_TOKEN / MT_PLUGIN_TOKEN_<NAME>, MT_CI_TOKEN — and ignores those variables after that. Check Settings, then remove them from the viewer's unit.
The ESP32 device plugins listen on loopback by default and need no token. If you bind one to a LAN address, start it with a token and enter that token in the viewer's Settings.
What is not covered
- No TLS. Every service speaks plain HTTP, so passwords, session cookies and tokens cross the network unencrypted. Use the services only on a network you trust. For remote access use a VPN such as Tailscale or WireGuard; never expose the ports to the internet.
- Secrets are plaintext at rest. The tokens saved in the viewer's Settings live in a git-ignored JSON file next to
auth_config.json(mode0600); the services' own tokens sit in their LaunchAgent plists and config files. Anyone who can read those files as that user, or as root, has the tokens. - The build plugin runs the build scripts of the branches it builds. Run it as a dedicated, never-root user and add only trusted repos as projects.
- Tier 3–5 items from the roadmap: no TLS termination or VPN setup is shipped, the systemd units and LaunchAgents are not sandboxed, dependency and secret scanning do not run in CI yet, and the hand-written HTTP servers are kept rather than replaced by a framework.
Hardening roadmap
| Tier | What | Effort | Status |
|---|---|---|---|
| 1 | Viewer login (default admin account, admin-managed users, no self sign-up), CI token for uploads, tokens mandatory on non-loopback binds, ESP32 plugins on loopback by default, service tokens in viewer Settings, MonkeyTester-Mac archived | ≈ 1 day | Done |
| 2 | Code hardening in every server: no shell commands, input validation, path-traversal checks, request size limits and timeouts, secure session cookies, cross-site request checks, login throttling, salted password hashing, security headers, 0600 secret files | ≈ 3–5 days | Done |
| 3 | TLS or a VPN for remote access, systemd and launchd sandboxing | ≈ 2–3 days | Remaining |
| 4 | Scanning in CI: bandit, pip-audit, secret scanning | Ongoing | Remaining |
| 5 | Replacing the hand-written HTTP servers with a framework | Optional | Remaining |
Reporting issues
Found a hole? Open an issue in the affected repository on the project's Gitea (the lab's is http://192.168.125.70:3000/yurivibes, reachable on its LAN only), or tell the maintainer directly if it should not be public yet. Say which service and commit you tested, and how to reproduce it. Never include a real token, password or session cookie — use placeholders. Each repository also has a SECURITY.md covering its own service.