Repository navigation
feat(logging): redact session secrets where the log is written, not where it is collected - #283
Merged
Merged
Conversation
…re written A value an agent reads through get_config_item travels to the model in a request body, so it lands verbatim in /var/log/mitm/http.log, and in the agent pane if the agent echoes it. The pane is piped to two sinks at once — the file the collector uploads and /proc/1/fd/1, which is the container's stdout and so the cluster's log stack. Nothing scrubbed that second one at all; the collector-side pass could only ever clean the copy it pulled out. Add the filters that clean at the point of writing instead: a shared list loader in both languages that write http.log (the mitmproxy addon and the HTTP/2 logger, which append to the same file), and a streaming filter in front of the pane's tee. The stream filter holds back only the smallest tail that could begin a secret, so the live terminal does not lag, and it degrades to the bare tee rather than risking a pane that captures nothing. The list they read is written in the next commit; until then they are a no-op. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
…a secret get_config_item is the only channel by which a session receives a credential, so it is also the only place that knows a value is about to become loggable. It now publishes the session's secrets into the container before it answers, derived from config_item_accesses so the list holds exactly what this session has been handed and nothing else — which is what makes writing it into the container safe. A secret is not returned if arming failed: one that reaches a log ahead of its entry is one no later pass can take back out of bytes already written. A plain variable is not worth refusing over, since nothing is being hidden. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
docker/base/logger carries an importable module now, so running its filters locally leaves a __pycache__ behind. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
This was referenced Sep 17, 2026
aixle-com Bot
pushed a commit
that referenced
this pull request
Nov 24, 2026
…nge (#273) (#872) * refactor(sessions): one lifecycle service for every session state change Add Sessions::Lifecycle as the only code that fires TerminalSession events, four machine events for the moves finalize_session wrote past the machine, and route every caller (admission service, strategies, cleanup, suspension, runners) through it. Effects stay in the model callbacks (change 4, #283). Signed-off-by: Alex <[email protected]> * test(sessions): assert a nil error message with assert_nil Signed-off-by: Alex <[email protected]> * fix(sessions): finalize makes no move for suspended and restored sessions Signed-off-by: Alex <[email protected]> --------- Signed-off-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
aixle-com Bot
pushed a commit
that referenced
this pull request
Nov 24, 2026
…ect state writes (#283) (#874) * Sessions: lifecycle effects in Sessions::Lifecycle.transition!, hard guard on direct state writes (#283) Signed-off-by: Alex <[email protected]> * Sessions: move effect tests onto Lifecycle.transition!, fix test setup for the state guard Signed-off-by: Alex <[email protected]> * Sessions: fire the effect tests' events through transition! Signed-off-by: Alex <[email protected]> * Sessions: use model predicates in lifecycle effects Signed-off-by: Alex <[email protected]> --------- Signed-off-by: Alex <[email protected]> Co-authored-by: Alex <[email protected]>
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.
Why
Step 1 of removing the size cap on log collection (#282 put a 4 MB tail in as the stopgap).
The cap is not there because of storage. It is there because redaction forces the bytes through us:
Sessions::SecretRedactorruns in the worker, so every log has to be copied out of the container, through the k8s API server, into a Ruby string, before it can be cleaned. That chain is what the 120-second cleanup budget and the 4 MB tail are both about. Clean at the point of writing and the whole chain — and with it the cap — stops being necessary.There is a second reason to do this regardless of the cap.
tmux pipe-panefeeds two sinks:/proc/1/fd/1is the container's stdout, and therefore the cluster's log stack. Nothing has ever scrubbed that one — the collector-side pass only cleans the copy it pulls out.get_config_item's own warning to the agent ("visible to … the cluster's log stack if it is printed") describes exactly this hole.What this changes
The filters (
docker/base/logger/):aixle_redact.py/aixle-redact.js— one list loader per language, because two processes append tohttp.log: the mitmproxy addon and the HTTP/2 logger. Both clean the entry before serialization rather than the serialized line, so a value carrying a quote is matched in its own form instead of in JSON's escaping of it. Longest-first, matchingSecretRedactor.redact-stream.py— the pane filter, in front of the existingtee. Two properties a whole-file pass never had to think about: it withholds only the smallest tail that could still begin a secret (almost always nothing, so the live terminal does not lag), and it catches a secret split across two writes.entrypoint.shdegrades to the bareteeif the filter cannot start — a pipeline whose first stage dies captures nothing, and a session with no terminal output is one the no-output watchdog reaps half an hour later.The list (
Sessions::SecretRegistry): derived fromconfig_item_accesses, so it holds exactly the values this session has already been handed — which is what makes writing it into the container safe. It tells the container nothing the container did not ask for. Root-owned so the agent cannot quietly empty it, world-readable because the pane filter runs as the agent's user while the proxy runs as root, one base64 line per value so a secret containing newlines stays on one line.The ordering rule (
get_config_item): the list is armed before the value is returned, and a secret is not returned if arming failed — one that reaches a log ahead of its entry is one no later pass can take back out of bytes already written. A plain variable is not worth refusing over.Sessions::SecretRedactorstays exactly as it is, on the collection path and on the live tail. Two passes, and the outer one is now the belt rather than the braces.What this does not do
curl --upload-filestraight to a presigned S3 PUT (Api::V1::AssetsController#presignalready signs those;read_tool_resultalready hands the agent presigned URLs) and the app records only the key.collect_usagethen moves out of cleanup into a job that streams from S3.docker/base/logger/ships viaCOPY base/logger/ /opt/mitm/in each agent Dockerfile; until the images are republished the filters are not present and the Ruby half is a list nobody reads.Verification
test/services/internal_tools,test/services/sessions,test/services/container_strategies,test/services/context_buildersand the config-items integration test: 663 runs, 2320 assertions, 0 failures, 0 errors.rubocopclean on the changed Ruby,brakemanclean on the tree (0 warnings). Fullcheck_allis CI's — this worktree is outside the compose mount.The container scripts have no test harness in this repo, so they were exercised directly against a real list file:
Bearer <redacted:session-secret>— not leakedredact_objover a nested entry (body / headers / array)json.dumpsredactover the same entryJSON.stringifyRuby-side coverage: the list is published for secrets and not for variables, rewritten whole so a republish heals a container that missed a write, one line per value however many newlines it holds, written as root with mode 0644, success for a session with no container (no log is being written), failure when the container cannot take it — and, in the tool, that a secret is refused when arming fails while a variable still returns.
🤖 Generated with Claude Code