Skip to content

remote: keep the data address and device code out of every program's arguments - #2113

Merged
fujibee merged 1 commit into
integration/1.10-cloudfrom
fix/no-doc-on-argv
Nov 29, 2026
Merged

fujibee merged 1 commit into
integration/1.10-cloudfrom
fix/no-doc-on-argv

Conversation

@fujibee

@fujibee fujibee commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

What

No program remote.sh starts has a secret in its arguments any more. An argument is readable by every process on the machine for as long as the program runs. A device approval's data address (a capability URL), its device code, and a team config that records that address were being put in the SQL statement given to sqlite3 by the helpers that pick a field out of a JSON document.

Found by recording every launch's arguments (a PATH spy) through a device connect and a device pull: the approved address and the device code were in sqlite3 arguments, from _remote_json_field (every _remote_device_field caller: the code request, each token poll, the grant) and from the helpers that read or rewrite the team config (_remote_read_config_field, the binding writer, the feature check, the previous-binding archive, the team writers). The earlier test only watched node.

The fix is at the source, not per caller:

  • agmsg_sqlite_mem_stdin (next to agmsg_sqlite_mem): the same in-memory sqlite, with the statement read from standard input.
  • remote.sh runs all of its in-memory statements through _remote_sql, which gives the statement on standard input. No call site changes its statement.
  • _remote_json_field and _remote_json_array_length no longer put the document in the statement at all: it is written to a private (0600) temporary file that sqlite reads, so only the file's name and the (public) JSON path are in the statement. _remote_read_config_field has sqlite read the team config file directly.

Nothing about what is stored, sent or printed changes.

Process spawns

  • _remote_json_field / _remote_json_array_length: one mktemp, one chmod and one rm replace one sed (two more processes per call).
  • _remote_read_config_field: the sed that escaped the config is gone (one fewer per call).
  • Every other statement: no change in processes (standard input is a shell redirection, not a program).
  • These are per-call counts from reading the helpers, not an end-to-end measurement; the device flow makes a handful of field reads per approval and none per message, cycle or timer.

Tests

  • tests/test_remote_device.bats (+2): through a device connect and through a device pull, no program started by remote.sh (sqlite3, node, curl, python3, sed, grep, ...) has the approved address or the device code in its arguments. Both go red when _remote_sql goes back to an argument (checked).
  • tests/test_remote_escrow.bats: the escrow spy test also asserts the approved address is absent.
  • tests/test_remote.bats: the probe that extracts _remote_read_config_field also extracts _remote_sql.
  • Run with AGMSG_HOME and AGMSG_INSTALL_HOME unset: every tests/test_remote*.bats and tests/test_key.bats (493 tests). One test, the engine start restores all three traps the acquire takes (#762), failed in the combined run and passes when its file runs alone, on this branch and on the base without this change; it is not touched by this change. The four .github/scripts/check-*.sh pass at their baselines.

Not in this PR

Programs other than remote.sh's own sqlite3 calls (the sync engine already takes the address from its environment). The device flow is covered end to end by the tests above; other scripts that read a team config through agmsg_sqlite_mem are unchanged.

Notes for the release

  • remote: the data address and the device code of a device approval are no longer visible in the arguments of the programs remote.sh starts.

@fujibee
fujibee merged commit 2c02a3f into integration/1.10-cloud Nov 29, 2026
19 of 31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant