Skip to content

security: close config trust-boundary gaps and gate completion loader#481

Open
jeremy wants to merge 1 commit into
security/03-oauth-hardeningfrom
security/04-config-trust-gating
Open

security: close config trust-boundary gaps and gate completion loader#481
jeremy wants to merge 1 commit into
security/03-oauth-hardeningfrom
security/04-config-trust-gating

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented May 30, 2026

Close config trust-boundary gaps and gate the completion loader

(Threat: T2 malicious repo/parent-dir .basecamp/config.json; cleartext key leak.)

The existing untrusted guard already gates base_url/profiles/llm_provider/llm_endpoint/llm_api_key. This closes the siblings that slipped through:

  • cache_dir / cache_enabled — an untrusted repo config could redirect every cache write (completion, resilience, TUI workspace, recents, traces) to any user-writable path. Now trust-gated; accepted values are filepath.Cleaned.
  • llm_model — trust-gated (silent paid-model substitution).
  • llm_max_concurrent / llm_token_budget — trust-gated (paid-LLM cost amplification).
  • llm_endpoint — scheme-validated on accept (rejects file:// etc.) and RequireSecureURL enforced in root.go alongside base_url, so an http:// endpoint can't leak llm_api_key in cleartext.
  • Completion loader (completion/cache.go, completer.go) — repo/local profile loading now goes through the same TrustStore.IsTrusted check as the main config; completion descriptions are stripped of control chars.

Tests

config_test.go adds reject-from-local / accept-from-global / llm_endpoint-scheme cases.


Part 4/6 of the stacked security series. Base: security/03-oauth-hardening. (Shares root.go with part 5 — hence the stack ordering.)

📚 Stack (merge bottom-up)

  1. security: reject foreign-host URLs in api to prevent token leak #478 — reject foreign-host URLs in api (base main)
  2. security: strip ANSI/OSC escapes from API-controlled output #479 — strip ANSI/OSC escapes from output
  3. security: harden OAuth discovery and token endpoints #480 — harden OAuth discovery / token endpoints
  4. security: close config trust-boundary gaps and gate completion loader #481 — close config trust-boundary gaps + completion gate
  5. security: tighten config-dir perms and validate plugin scope argv #482 — tighten config-dir perms + plugin scope argv
  6. security: bump toolchain/x-net for CVEs and tighten CI gates #483 — bump toolchain/x-net + CI gates

Each is independent except #482 depends on #481 (shared root.go). #478 can land first/alone.

Copy link
Copy Markdown

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

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: d7613bb6c8

ℹ️ 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 internal/config/config.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens the config trust boundary so untrusted repo/local configs can’t silently redirect cache writes or amplify LLM spend, and it aligns shell completion config-loading with the same trust model while hardening completion descriptions against terminal control characters.

Changes:

  • Trust-gate additional “authority” config keys (cache_dir, cache_enabled, llm_model, llm_max_concurrent, llm_token_budget) and validate llm_endpoint scheme on config-file load.
  • Gate completion’s repo/local profile loading behind the trust store and sanitize completion descriptions to strip control chars.
  • Enforce secure (https for non-localhost) llm_endpoint at CLI startup and add targeted config tests.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
internal/config/config.go Trust-gates additional keys and adds llm_endpoint scheme validation helper.
internal/config/config_test.go Adds tests for rejecting authority keys from untrusted local/repo configs and rejecting unsafe llm_endpoint schemes.
internal/completion/completer.go Sanitizes completion descriptions to prevent control-character terminal injection.
internal/completion/cache.go Loads repo/local profiles for completion only if the config path is trusted.
internal/cli/root.go Enforces secure llm_endpoint alongside base_url before running most commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/cli/root.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/cli/root.go Outdated
@jeremy jeremy force-pushed the security/03-oauth-hardening branch from d858f7f to 9e7bb58 Compare May 30, 2026 06:05
@jeremy jeremy force-pushed the security/04-config-trust-gating branch from d7613bb to 3f44637 Compare May 30, 2026 06:05
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 5 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/cli/root.go Outdated
Comment thread internal/config/config.go
Comment thread internal/config/config.go Outdated
@jeremy jeremy force-pushed the security/03-oauth-hardening branch from 9e7bb58 to 3f9352d Compare May 30, 2026 06:13
Copilot AI review requested due to automatic review settings May 30, 2026 06:13
@jeremy jeremy force-pushed the security/04-config-trust-gating branch from 3f44637 to 242f699 Compare May 30, 2026 06:13
@github-actions github-actions Bot added the commands CLI command implementations label May 30, 2026
@github-actions github-actions Bot added the bug Something isn't working label May 30, 2026
Copy link
Copy Markdown

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

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: 242f699ed6

ℹ️ 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 internal/config/config.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 14 comments.

Comment thread internal/completion/completer.go
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/config/config.go Outdated
Comment thread internal/cli/root.go Outdated
@jeremy jeremy force-pushed the security/03-oauth-hardening branch from 3f9352d to 396ecac Compare May 30, 2026 06:24
@jeremy jeremy force-pushed the security/04-config-trust-gating branch from 242f699 to 97ebed6 Compare May 30, 2026 06:24
Copy link
Copy Markdown

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

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: 97ebed69f6

ℹ️ 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 internal/cli/root.go Outdated
Copilot AI review requested due to automatic review settings May 30, 2026 07:51
@jeremy jeremy force-pushed the security/04-config-trust-gating branch from 97ebed6 to 0dcd57f Compare May 30, 2026 07:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown

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

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: 0dcd57facf

ℹ️ 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 internal/cli/root.go Outdated
@jeremy jeremy force-pushed the security/03-oauth-hardening branch from 6a3a964 to 8add014 Compare May 30, 2026 08:27
@jeremy jeremy force-pushed the security/04-config-trust-gating branch from 0dcd57f to 253f4f1 Compare May 30, 2026 08:27
Copy link
Copy Markdown

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

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: 253f4f1f45

ℹ️ 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 internal/config/config.go Outdated
@jeremy jeremy force-pushed the security/03-oauth-hardening branch from 8add014 to 159b0ef Compare May 30, 2026 08:51
Copilot AI review requested due to automatic review settings May 30, 2026 08:51
@jeremy jeremy force-pushed the security/04-config-trust-gating branch from 253f4f1 to 0635112 Compare May 30, 2026 08:51
Copy link
Copy Markdown

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

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: 0635112246

ℹ️ 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 internal/cli/root.go Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread internal/config/config.go
@jeremy jeremy force-pushed the security/03-oauth-hardening branch from 159b0ef to 472188d Compare May 30, 2026 09:12
@jeremy jeremy force-pushed the security/04-config-trust-gating branch from 0635112 to ffb8fe1 Compare May 30, 2026 09:12
Copy link
Copy Markdown

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

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: ffb8fe1cfb

ℹ️ 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 internal/config/config.go Outdated
- Trust-gate cache_dir, cache_enabled, llm_model, llm_max_concurrent and
  llm_token_budget so an untrusted local/repo config can't redirect cache
  writes or amplify paid-LLM usage; only honored from trusted sources.
  'config set' now also warns when these keys are written to an untrusted
  local config so the value isn't silently ignored on the next load.
- Scheme/host-validate llm_endpoint on accept (rejects file://, hostless and
  malformed forms) and re-validate at the root.go enforcement point so env/
  profile-sourced endpoints can't slip a non-http(s) scheme past
  RequireSecureURL, which only blocks http:// for non-localhost; this prevents
  leaking llm_api_key in cleartext.
- Gate the completion profile loader behind the TrustStore and strip control
  characters from completion descriptions.
@jeremy jeremy force-pushed the security/03-oauth-hardening branch from 472188d to e97f2a9 Compare May 30, 2026 09:34
Copilot AI review requested due to automatic review settings May 30, 2026 09:34
@jeremy jeremy force-pushed the security/04-config-trust-gating branch from ffb8fe1 to 97fd65d Compare May 30, 2026 09:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working commands CLI command implementations tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants