A minimal, locked-down Tridactyl
native messenger that does exactly one thing: hand the contents of a Firefox
textbox to a running Emacs daemon via emacsclient, and read the result back.
Unlike the stock messenger — whose run command executes arbitrary shell — this
one implements only the four messages the :editor flow needs (version,
temp, read, run) and refuses everything else.
- No shell.
runtokenises the command itself andexecs directly. - Only
/usr/bin/emacsclientmay be run, with a strict flag allowlist (-c/--create-frameand+line:colpositions only) and exactly one file argument.-e/--eval,-a/alternate-editor,-s/socket,-n/no-wait are rejected. - Files are confined to a private
0700directory under$XDG_RUNTIME_DIR(RAM-backed, wiped on logout). Only single-componenttmp_edit_*.txtfiles, owned by you, non-symlink, are read — viaO_NOFOLLOW— and deleted after one read. - Scrubbed environment, a bounded message/temp-file size and count, and a refusal to run as root.
Because edited text is opened in Emacs, also neutralise file-local-variable attacks in your Emacs init:
(setq enable-local-variables :safe
enable-local-eval nil)- Go (to build),
python3and coreutilsinstall(used bymake install) - A running Emacs daemon (
emacs --daemon) — the messenger forbids alternate-editor, so a server must be up.
make build # compile ./messenger
make test # run the black-box test suite
make roottest # privilege-dependent tests (uses sudo)
make install # install per tridactyl.json (see below)
make uninstallmake install treats tridactyl.json as the single source of truth: it installs
the binary to the manifest's "path" and the manifest to
~/.mozilla/native-messaging-hosts/<name>.json. Override the manifest directory
with make install MANIFEST_DIR=....
Then verify in Firefox with :native.
set editorcmd /usr/bin/emacsclient -c +%l:%c
Focus a textbox and run :editor (default Ctrl-i).