Repository navigation
remote: keep the data address and device code out of every program's arguments - #2113
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
sqlite3by 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
sqlite3arguments, from_remote_json_field(every_remote_device_fieldcaller: 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 watchednode.The fix is at the source, not per caller:
agmsg_sqlite_mem_stdin(next toagmsg_sqlite_mem): the same in-memory sqlite, with the statement read from standard input._remote_sql, which gives the statement on standard input. No call site changes its statement._remote_json_fieldand_remote_json_array_lengthno 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_fieldhas 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: onemktemp, onechmodand onermreplace onesed(two more processes per call)._remote_read_config_field: thesedthat escaped the config is gone (one fewer per call).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_sqlgoes 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_fieldalso extracts_remote_sql.AGMSG_HOMEandAGMSG_INSTALL_HOMEunset: everytests/test_remote*.batsandtests/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-*.shpass 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_memare unchanged.Notes for the release