Repository navigation
fix(config): trust each project pack manifest by its exact content - #245
Conversation
Project packs under .qq/packs/ and packs named by project packs: entries were admitted whenever the directory's config files were trusted, which held vacuously for a pack-only repository and never covered the manifest bytes. Each project pack.ron is now its own trust subject keyed by path and SHA-256: untrusted manifests are withheld and listed as pending in both the load and the qq trust scan, and editing one asks again. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e458586ed1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Explicit `packs:` entries in an untrusted project file are now loaded for review before consent, but `load_explicit` did not count against MAX_PACKS. A repository could make every `qq` start, `qq trust`, and `qq doctor` read and parse an unbounded number of 64 KiB manifests and list them all in one prompt. Discovery and explicit entries now share one per-load counter in both the load and the pending-trust scan. Also amend the design docs that still said project packs follow the project's configuration trust.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9b3776138
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Listing a pending project file's explicit `packs:` entries for review
resolved and opened whatever path they named before the user consented:
an absolute or `..` path, a UNC share (an SMB connection that leaks the
user's NTLM hash on Windows), an automount, or a symbolic link out of the
repository. Before consent, entries are now read only when they lie
lexically beneath the VCS root and are reached through no symbolic link;
any other entry is read, and reviewed as its own manifest, once the
declaring file is trusted. The load and the `qq trust` scan apply the same
rule, so the TUI's reviewed set still matches the re-scan.
Also cover session ("this session") trust for a pack, and document that
operator-owned layers' `packs` entries are not re-gated.
An untrusted project file's explicit entries that point at nothing never reached `load_explicit`, so they did not advance the shared MAX_PACKS counter: a 1 MiB document could still make each load and `qq trust` stat thousands of paths (and grow the probe list quadratically). Every explicit entry that touches the filesystem now spends one unit, whether or not a manifest is there.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 723bf68726
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A project file's explicit `packs` entries are read before the user consents, so any path they name is touched by merely running `qq` in a clone. 362fe67 deferred out-of-repository entries to a second prompt, but session-only trust could never finish that flow (the rescan did not carry the first grant) and a symlinked `pack.ron` leaf was still followed. Replace the deferral with a rule: a project entry must resolve lexically beneath the VCS root through no symbolic link, manifest leaf included, or the load fails with InvalidPack / SymlinkSource without opening it. Packs outside the repository belong in user configuration. Also count every inspected `.qq/packs/<id>` directory (with or without a manifest) against MAX_PACKS, and compare Windows drive paths in the canonical `\\?\` form so in-repository absolute paths are recognized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 111d254041
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Discovery recorded `.qq/packs` and each `pack.ron` before rejecting links, and recording follows a link's target, so a checkout could make startup or `qq trust` touch an automount or network target before consent. Links are now rejected first. Every entry listed under `packs/` (stray files too) spends the shared MAX_PACKS budget, and `\\server\share` paths compare in the canonical `\\?\UNC\` form like drive paths. Guides now say a project pack path may be absolute when it stays inside the repository.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb84d0ad2a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
What changes for users
Before: a repository that shipped only
.qq/packs/<id>/pack.ron(noqq.ron/.qq/config.ron) loaded its packs with no trust prompt. A pack MCPStdio(command, args)server would then start during plan compilation, so cloning a repo and runningqqin it ran the repo's command. Also, once a project's config was trusted, packs added or edited later bygit pull(including directories named by an explicit projectpacks:entry) loaded without another review.After: every project pack manifest (discovered under
.qq/packs/or named by a project file'spacks:entry) has its own trust record, keyed by the manifest's canonical path and the SHA-256 of its bytes. Until that record exists the pack is held back and the load fails withTrustRequired. The TUI prompt andqq trustlist thepack.ronwith what it declares (packs,profiles,MCP x → sh). Editing a trusted manifest asks again.Why / design
Fixes code scan finding sfind-0678141da8754670ac570b24a782a0e8. Before this change the gate was
TrustState::project_trusted. It hashed only config documents and returnedtruewhen there were none.project_trusted. A newwithhold_untrusted_packadmits aSourceKind::Projectpack only whentrust.contains(manifest_path, manifest_digest). Otherwise it adds a deduplicatedPendingTrustbuilt fromAgentPack::trust_summary(). The check uses the digest of the exact bytes that were parsed.load_for_client(discovery andapply_explicit_packs) andscan_pending_trustfollow the same rule, so the pending list the load shows is the same listgrant_reviewed_trust/ensure_reviewedre-checks. If a project file is still pending, the manifests it names explicitly go into the same review, so oneqq trustcovers both.How verified
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspace(passes)cargo test -p qq-provider …(not needed:qq-providerunchanged)crates/qq-config/src/tests.rs. Both fail onmainand pass with this change:project_packs_are_their_own_trust_subject: a pack-only repo givesTrustRequiredwith aMcpStdiodeclaration, andpending_trustlists it. Once granted, the pack and its MCP server load. Editing the manifest asks again. A pack added after the config was trusted asks again.explicit_project_pack_manifests_are_trust_gated_by_content: one review covers the declaring file and the pack it names. Changing only the referenced manifest asks again.src/runtime.rspack_profiles_…so it re-grants after editing a trusted manifest, before it assertsPackRequiresNewerProtocol.Review follow-ups (c9b3776 … eb84d0a)
Before the user trusts anything, this PR reads the manifests that a project file names, so those reads now have strict limits:
packs:entry must resolve lexically beneath the VCS root (elsecwd), with no symbolic link anywhere on the way, thepack.ronleaf included. Otherwise the load,qq trust, andqq doctorfail withInvalidPack("leaves the project") orSymlinkSourceand never open the path. That rules out absolute paths,..escapes, UNC shares (on Windows those leak NTLM), automounts, and links. Packs outside the repository belong in the user's global config. This replaces the two-step deferral in 362fe67: Codex found that session trust looped forever under it. Windows drive and UNC paths are compared in canonical\\?\form. Tests:project_pack_paths_that_leave_the_repository_are_rejected_unread,project_pack_paths_through_a_link_are_rejected_unread..qq/packsdirectory orpack.ronis rejected before it is recorded, because recording follows the link. Windows junctions count as symlinks under Rust's name-surrogate rule, so they are rejected too. Test:discovered_project_pack_links_are_rejected_before_they_are_followed.MAX_PACKS(32) is now shared by discovery and explicit entries, in both the load and the pending scan. Every entry listed counts: packs, directories without a manifest, and stray files. Tests:explicit_pack_reads_before_trust_are_bounded,placeholder_pack_directories_spend_the_load_budget.session_trust_admits_a_pack_without_recording_it.architecture.md§ Agent Packs,tools.md,permissions.md, andconfiguration.mddescribe per-manifest trust, the containment rule, and the bound. They also say thatpacksentries in global,QQ_CONFIG, or managed config belong to the operator and are not re-gated.qq-coretiming test (completed_compaction_does_not_restart_the_original_duration) that ran under host load. It passes 3/3 on rerun, and this PR does not touchqq-core.Impact
qq trust/ pending scans now read and parse project pack manifests too (at most 32 per load across discovery and explicit entries, 64 KiB each).pack.ron.docs/guide/permissions.md,docs/guide/configuration.md,docs/guide/concepts.mdnow describe per-manifest pack trust.Link to Devin session: https://app.devin.ai/sessions/ef8a24e10bb343ca8b5ac7925daedb7c
Open in Devin Desktop: https://app.devin.ai/desktop/session/ef8a24e10bb343ca8b5ac7925daedb7c?variant=devin
Requested by: @integrate-your-mind