Repository navigation
fix(memory): harden cross-device sync transport (git option injection + env leak) - #188
Merged
Merged
Conversation
… + env leak) Track C adversarial hardening of the 3.0 memory-sync surface. MEDIUM — git option injection. The remote/branch from ~/.kit/sync.toml reach git as positional argv (no shell), but a '-'-leading value is parsed as an option (remote = "--upload-pack=<cmd>" → RCE on clone) and ext::/fd:: remote helpers run commands by design. loadSyncConfig now rejects both; cloneOrInit passes --end-of-options before the positional operands; git() runs with protocol.ext/protocol.fd disabled. Config is operator-owned (low realistic severity) but this is defense-in-depth and future-proofs `sync init`. LOW — secret leak to the transport command. runTransportCmd handed the whole process.env (incl. KIT_MEMORY_PASSPHRASE) to the operator's push/pull command, which only ever needs to move the already-encrypted blob. A command that logs its env would spill the passphrase next to the ciphertext. The child env is now stripped of kit-managed PASSPHRASE/SECRET/TOKEN/PASSWORD/KEY vars; provider creds (AWS_*, etc.) still pass through. 2 new tests: loadSyncConfig rejects option-injecting remote/branch + ext::; the transport child env never contains KIT_MEMORY_PASSPHRASE. Full suite 1981 green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
|
✅ Docker image built successfully
|
This was referenced Jul 1, 2026
Merged
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
Track C — adversarial hardening of the 3.0 memory-sync surface (
src/memory/remote-sync.ts). Two findings, both fixed here.MEDIUM — git option injection on the remote/branch
remote/branchfrom~/.kit/sync.tomlreachgitas positional argv viaexecFileSync(no shell, so OS metacharacters are already inert), but two git-level vectors remained:-is parsed as an option — aremoteof--upload-pack=<cmd>turnsgit cloneinto arbitrary command execution;ext::/fd::remote helpers run commands by design (git clone ext::sh -c …).Fix:
loadSyncConfigrejects aremote/branchstarting with-, and anext::/fd::remote;cloneOrInitpasses--end-of-optionsbefore the positional operands;git()helper runs withprotocol.ext.allow=never protocol.fd.allow=never.Config is operator-owned (read only from
~/.kit/sync.toml, never the repo tree), so realistic severity is bounded — this is defense-in-depth, and it future-proofs anysync initthat ingests a remote from a less-trusted source.LOW — kit secrets leaked into the transport command's environment
runTransportCmdhanded the entireprocess.env(includingKIT_MEMORY_PASSPHRASE) to the operator'spush_cmd/pull_cmd. That command only ever moves the already-encrypted blob, so it never needs the passphrase — and a transport that logs its environment (aws --debug, aset -xshell, an error tracer) would spill the passphrase right next to the ciphertext it protects, collapsing the encryption guarantee.Fix: the child env is stripped of every kit-managed
*(PASSPHRASE|SECRET|TOKEN|PASSWORD|KEY)var; the operator's own provider credentials (AWS_*, etc.) still pass through, andKIT_MEMORY_BLOBis still provided.Tests
2 new tests:
loadSyncConfigrejects an option-injectingremote/branchandext::helpers (and still loads a normal config); thetransport = "command"child env never containsKIT_MEMORY_PASSPHRASE(or its value) while still receivingKIT_MEMORY_BLOB. Full suite 1981 green, prettier clean.Context
Final PR of the A→B→C hardening arc: #185 (docs) → #186 (external timestamp anchor) → #187 (PAL device-fence + device identity) → this (transport hardening). All findings came from an adversarial review of the new 3.0 surface; the memory content path itself was confirmed clean (travels as a GCM blob by path,
verify_cmddemoted on merge, path-traversal guarded).🤖 Generated with Claude Code
https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Generated by Claude Code