Skip to content

Security

Headless Lab touches delicate things — system apps, memory, boot, input devices. This page explains the rationale behind each security decision and how the toolkit minimizes the risk of brick/bootloop.

The three principles

1. Show before touching

Every operation that changes device state first shows the plan and asks for confirmation. No "surprise actions".

Tool How it shows
appctl Table with →OFF next to each marked package; asks y/N
appctl --disable Lists matches; if more than one, aborts and asks to refine
createswap --dry-run / -n shows the "after" panel without applying
touch-ctl Before off, lists the device found and its major:minor
screen-toggle Shows "Screen on → sending SLEEP (223)..."

2. Always provide a way back

Tool Reversal mechanism
appctl JSON snapshot in ~/.appctl/snapshots before each batch; --restore last
createswap Automatic rollback: if step N+1 fails, undoes step N
touch-ctl EXIT trap restores the node if off fails after removal
screen-toggle Idempotent — re-reads state and confirms
appctl profiles Each profile has a counterpart (restaurar-leve, restaurar-tudo, ui)

3. Never break the boot

The only component that touches the boot is the createswap hook (--install-boot). It's written to be bootloop-proof:

  • waits for sys.boot_completed before acting;
  • logs errors to /data/local/tmp/createswap-boot.log;
  • always ends with exit 0 — even if everything fails, the boot continues;
  • has two kill switches: createswap --uninstall-boot (removes the hook) and touch /data/local/tmp/createswap.disable (flag the hook respects).

No other tool installs anything to the boot without you explicitly asking.

What the toolkit does NOT do

Nothing is uninstalled

appctl uses pm disable-user and pm enable — the package stays installed, just invisible/inactive for user 0. You can re-enable at any time, without reinstalling.

No secrets in code

None of the 7 tools reads, writes, or sends:

  • passwords, tokens, SSH keys;
  • IMEI, serial number, MAC;
  • IP (internal or public), Wi-Fi network name;
  • contacts, SMS, photos, call history.

The project's .gitignore also explicitly blocks .env, *.pem, *.key, id_rsa*, authorized_keys, tokens.sqlite, etc.

No network

The tools are 100% local. No script makes HTTP, gRPC, MQTT, or any other network call. You can run with Wi-Fi off.

No telemetry

No analytics, no phone home, no automatic error reports. What happens on your device stays on your device.

Blocked packages

appctl refuses to disable:

Package Why
com.android.settings Without Settings you can't re-enable anything via GUI
com.topjohnwu.magisk Without Magisk you lose root and the tools stop working
com.termux Without Termux you lose shell access
keyboard providers (com.android.inputmethod.*) Without keyboard, any GUI is unreachable
active launcher Without launcher, no home screen
Contact/Phone/Dialer (in non-headless mode) Basic phone function

Even a profile that tries to touch these is aborted before applying, with the list of what was blocked.

Root: how it's granted

Tools try root in this order:

  1. directly if already root (id -u == 0);
  2. su -c (Magisk — most cases);
  3. sudo (fallback, rare on Android).

Magisk asks for permission the first time each tool calls su. You grant it in Magisk → Superuser → Termux → Allow. If you deny, the tool prints the exact reason:

[-] couldn't run 'dumpsys power' as root (su: denied; sudo: not found).
    Open Magisk > Superuser and grant access to Termux.

Tip: authorize with a long timeout

In Magisk → Superuser → Termux → config, set the timeout to indefinite or 10 minutes instead of "always ask". That way, cron jobs and SSH sessions don't hang waiting for a screen tap.

Recommendations before testing

Before any change

  1. Have SSH access working — it's your safety net.
  2. Have ADB enabled and a PC with adb installed nearby.
  3. Back up important data (photos, contacts, files).
  4. Test with --dry-run / -n before applying anything.
  5. Notes: record what you disabled and when, to revert quickly.

What to do if something goes wrong

See Troubleshooting for a step-by-step by symptom (bootloop, touch unresponsive, swap not activating, SystemUI gone, etc.).

  • Software provided "as is", without warranties (see the MIT license).
  • You are responsible for backups and for having recovery means (recovery, ADB, SSH) before using.
  • The project is not affiliated with or endorsed by Samsung, Google, Unisoc, Termux, or Magisk. Trademarks belong to their owners.