Repository navigation
Audited source and repository ops record no credential - #190
Merged
Merged
Conversation
tracker.source.add, tracker.source.rotate and code.repo.add had no audit_subject, so their audit rows recorded the whole input, the tracker password and the repository access token included. Each now declares a subject that leaves the credential out, and a registry test fails any audited op with a credential-named input field and no audit_subject. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The tracker subjects take the normalised name and stored host from the response, the code.repo.add subject adds the extra branches' namespaces, and host_of strips user:pass@ so a credential typed into the host never reaches the stored host. The registry test matches credential names by part, exempts *_ref names, and recurses into nested models; a new test runs a real op's subject through post_handler_rows. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
The subject takes repo, branch, join_policy and classification from the response, so a blank branch or a restricted repository asked as open records what was registered. The registry test matches more credential names, exempts token budgets, and stops at a self-referencing model. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: zlareb1 <[email protected]>
zlareb1
force-pushed
the
fix/audit-subject-no-credential
branch
from
November 3, 2026 09:35
3ea35b8 to
c655701
Compare
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.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
The audit rows of
tracker.source.add,tracker.source.rotateandcode.repo.addno longer hold the tracker password or the repository access token given to the call.Why
An op with
audit=Trueand noaudit_subjectrecords its whole validated input as the audit subject (server/transport/post_rows.py::_audit_subject,input_obj.model_dump(mode="json")). The credential fields of these three ops are plainstr, so the dump wrote them in clear text:tracker.source.add:passwordtracker.source.rotate:passwordcode.repo.add:access_tokenloom.audit_logoutlives erasure, source removal and repository removal, and is hash-chained, so a credential written there cannot be rotated out of it; the password and token are otherwise only stored sealed (seal/unseal). The audit log must hold no secret.Each op now declares an
audit_subject:tracker.source.add: the input withoutpassword, withnameandhostas stored (from the response).tracker.source.rotate:org, the storednameand the newuser.code.repo.add: the input withoutaccess_token, plusauthenticated(whether a token was given);repo,branch,join_policy,classificationandnamespaceas registered and the extra branches' namespaces (also), all from the response, so a blank branch records the branch it resolved to and a restricted repository recordsapproval.host_of(server/tracker/domain/sources.py) now drops userinfo:https://u:p@hostandtok@hostboth givehost. Before, it returnedufor the first andtok@hostfor the second, so a credential typed into the host field could reach the stored host, the response and the subject; such a host usually failed the host gate, but nothing guaranteed it.A generic fallback fix (dropping
SecretStrfields) would not cover these ops, since their fields are notSecretStr, and changing them toSecretStrchanges the wire schema and every handler that reads them. A registry test now fails any audited op whose input has a credential-named field and noaudit_subject, so a future op cannot reintroduce the leak through the fallback. A field name is split on_and matches when a part ispassword,passwords,passwd,secret,secrets,token,credential,credentials,apikey,authorization,bearerorcookie, or it containsapi_key,private_key,signing_keyorencryption_key(a barekeyis a memory key, not a credential). Exempt: a name ending in_ref(an environment variable's name) and a name with abudgetpart (token_budget,section_token_budgets: a size in model tokens);*_tokenscounters do not match, sincetokensis not a part. The test recurses into fields typed as a model (through lists and optionals, stopping at a model already visited); adict[str, Any]field has no declared keys and is not checked, and the audited ops' dict fields (a tracker mapping, a contract report) hold no credential. On every registered op it finds exactly the three fields above. The other audited ops with secret-like names (webhook.register.secret_ref,inbox.register.webhook_secret_ref) carry the name of an environment variable, not a secret, and are left as they are.code.repo.set_sourcetakes no token and is untouched;code.repo.add_branchinherits the stored token and takes none.Scope and risk
Touches what the three ops' audit rows record, and
host_of, which also normalises the host of sources from the deployment's configuration: a configured host with userinfo now resolves to its hostname instead of a broken value. No wire, storage or auth change. Rows already inloom.audit_logkeep what they recorded; this change does not rewrite or delete audit rows (they are hash-chained and sealed into checkpoints), so a deployment that ran these ops should treat any tracker password or repository token registered before this change as exposed to readers of the audit log and rotate it (tracker.source.rotate, or a new token for the repository).Compatibility, rollout and rollback
Tests
tests/unit/test_audit_subject_credentials.py: one test per op that its subject has no credential key and no credential value, and keeps what an auditor needs (normalised name, stored host,also); one thatcode.repo.addrecords the registered branch and join policy for a blank branch and a restricted repository asked asopen; one for the matcher's lookalikes and one for a self-referencing model; one test that runstracker.source.add's real declaration throughpost_rows.post_handler_rowsand checks the subject handed to the audit emit (test_mcp_post_rows.pycoversaudit_subjectonly on a stand-in op); one registry test that every audited op with a credential-named input field declares anaudit_subject.tests/unit/test_qa_intel_client.py::test_host_drops_userinfo_from_a_url.repo_admin, plustest_public_copy: 367 passed.make format lint typecheck: clean.pytest tests/unit -p no:randomly) on the first push: 25326 passed, 20 skipped, 1 xfailed.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. Checked: every audited op's input fields against the credential names, the response shapes the subjects read, and that URLs with embedded credentials are refused before an audit row is written (
parse_remote).I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main(none).frontend/changed (unchanged).docs/describe the system as it now is (docs/architecture/security.md, Audit log).git commit -s).🤖 Generated with Claude Code