Skip to content

fix(config): trust each project pack manifest by its exact content - #245

Merged
lg2m merged 7 commits into
mainfrom
devin/1791166038-project-pack-trust
Oct 8, 2026
Merged

lg2m merged 7 commits into
mainfrom
devin/1791166038-project-pack-trust

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What changes for users

Before: a repository that shipped only .qq/packs/<id>/pack.ron (no qq.ron / .qq/config.ron) loaded its packs with no trust prompt. A pack MCP Stdio(command, args) server would then start during plan compilation, so cloning a repo and running qq in it ran the repo's command. Also, once a project's config was trusted, packs added or edited later by git pull (including directories named by an explicit project packs: entry) loaded without another review.

After: every project pack manifest (discovered under .qq/packs/ or named by a project file's packs: 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 with TrustRequired. The TUI prompt and qq trust list the pack.ron with 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 returned true when there were none.

  • Removed project_trusted. A new withhold_untrusted_pack admits a SourceKind::Project pack only when trust.contains(manifest_path, manifest_digest). Otherwise it adds a deduplicated PendingTrust built from AgentPack::trust_summary(). The check uses the digest of the exact bytes that were parsed.
  • load_for_client (discovery and apply_explicit_packs) and scan_pending_trust follow the same rule, so the pending list the load shows is the same list grant_reviewed_trust / ensure_reviewed re-checks. If a project file is still pending, the manifests it names explicitly go into the same review, so one qq trust covers both.
  • Packs from global, explicit-file, inline, MDM and managed layers are unchanged, since the operator owns those.
  • I did not add a separate runtime check. All packs are admitted in the loader, so that is where this one fix applies.

How verified

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace (passes)
  • cargo test -p qq-provider … (not needed: qq-provider unchanged)
  • New tests in crates/qq-config/src/tests.rs. Both fail on main and pass with this change:
    • project_packs_are_their_own_trust_subject: a pack-only repo gives TrustRequired with a McpStdio declaration, and pending_trust lists 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.
  • Updated src/runtime.rs pack_profiles_… so it re-grants after editing a trusted manifest, before it asserts PackRequiresNewerProtocol.

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:

  • Project pack paths must stay in the repository (111d254). A project packs: entry must resolve lexically beneath the VCS root (else cwd), with no symbolic link anywhere on the way, the pack.ron leaf included. Otherwise the load, qq trust, and qq doctor fail with InvalidPack ("leaves the project") or SymlinkSource and 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.
  • Discovery doesn't follow links (eb84d0a). A linked .qq/packs directory or pack.ron is 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.
  • A bound on how much is read. 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 covered: session_trust_admits_a_pack_without_recording_it.
  • Docs: architecture.md § Agent Packs, tools.md, permissions.md, and configuration.md describe per-manifest trust, the containment rule, and the bound. They also say that packs entries in global, QQ_CONFIG, or managed config belong to the operator and are not re-gated.
  • Compatibility: a repository whose own config named a pack outside itself now fails to load. This needs an Upgrading note in the release.
  • Verification: fmt and clippy are clean, qq-config passes 117/117, and the workspace passes 2036/1. The one failure is a qq-core timing 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 touch qq-core.

Impact

  • Performance: 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).
  • Compatibility: PROTOCOL / descriptor / store schema unchanged. Users who already trusted a project that has packs will be asked once to trust each pack.ron.
  • Docs: docs/guide/permissions.md, docs/guide/configuration.md, docs/guide/concepts.md now 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

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>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@lg2m
lg2m marked this pull request as draft October 5, 2026 03:18
@lg2m
lg2m marked this pull request as ready for review October 8, 2026 06:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-08T09:35:42.820857Z eb84d0a New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/qq-config/src/loader.rs Resolved
Comment thread crates/qq-config/src/loader.rs Resolved
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/qq-config/src/loader.rs Resolved
lg2m added 2 commits October 8, 2026 01:15
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/qq-config/src/loader.rs Resolved
Comment thread crates/qq-config/src/loader.rs Resolved
Comment thread crates/qq-config/src/loader.rs Resolved
Comment thread crates/qq-config/src/loader.rs Resolved
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/qq-config/src/loader.rs Resolved
Comment thread crates/qq-config/src/pack.rs Resolved
Comment thread crates/qq-config/src/loader.rs Resolved
Comment thread docs/guide/permissions.md Resolved
Comment thread crates/qq-config/src/loader.rs Resolved
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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread crates/qq-config/src/loader.rs Resolved
@lg2m
lg2m merged commit e99a155 into main Oct 8, 2026
6 checks passed
@lg2m
lg2m deleted the devin/1791166038-project-pack-trust branch October 8, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants