Skip to content

security(config): don't send API key to base_url from project .cora.yaml - #563

Merged
ajianaz merged 1 commit into
developfrom
security/untrusted-project-base-url
Oct 7, 2026
Merged

ajianaz merged 1 commit into
developfrom
security/untrusted-project-base-url

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

What

Stops a repo-controlled .cora.yaml from redirecting the LLM API key (Bearer token) to an attacker host, plus related hardening.

Why

A discovered project .cora.yaml could set provider.base_url; chat_completion then POSTs Authorization: Bearer <key> there. In cora-review.yml (pull_request_target + PR-head checkout + CORA_API_KEY) any PR author could exfiltrate the secret. Validation also allowed http://, ws://, unix:, and API error bodies were echoed unbounded.

How

  • provider.base_url from a discovered .cora.yaml is dropped with a warning unless CORA_TRUST_PROJECT_CONFIG=1. CLI --base-url, CORA_BASE_URL, global config, and explicit --config are unaffected. A project value equal to the already-resolved one is kept silently.
  • New check_base_url: https:// required; http:// only for localhost/127.0.0.1/[::1] (userinfo tricks like http://localhost@evil rejected). Used by Config::validate and re-checked on the final URL in build_llm_config (covers env/preset URLs). Breaking: ws:///unix:/remote http:// now error clearly.
  • CoraError::LlmStatus.body now goes through preview_raw (512 bytes) in both the blocking and streaming paths.
  • cora-review.yml: new first step fails if the CORA_BASE_URL secret is empty. Since env CORA_BASE_URL overrides project config, the key can no longer be redirected by a PR's .cora.yaml, even with the older action binary.
  • Docs: docs/usage.md.

Testing

  • cargo test --features tree-sitter passes
  • cargo fmt --all -- --check passes
  • cargo clippy --all-targets --features tree-sitter -- -D warnings passes
  • cargo build --release --features tree-sitter passes (not run; dev check/test build fine)
  • Manual smoke-test (unit-tested only)

New tests: project-only base_url ignored when untrusted; used when trusted; equal value kept; http non-loopback/userinfo/ws/unix rejected, loopback + https accepted; LlmStatus body capped.

Not done (deliberate)

  • Workflow still checks out the PR head (the action needs it for the diff and I can't verify its internals); permissions left unchanged (security-events: write may be needed for SARIF). Fully fixing means checking out base and fetching the head diff, which should be coordinated with cora-review-action.
  • No global-config opt-in; env var only.
  • Provider switch via project config to another known preset is not restricted.

Related Issues

Security hardening (no public issue).

Checklist

  • Branch name follows convention (security/)
  • Branch is from develop
  • Commit messages follow Conventional Commits
  • No secrets or credentials committed
  • One logical change per PR

🤖 Generated with Claude Code

- ignore provider.base_url from a discovered .cora.yaml unless CORA_TRUST_PROJECT_CONFIG=1
- require https base_url (http only for loopback)
- cap LLM error bodies echoed in LlmStatus via preview_raw
- cora-review workflow: require pinned CORA_BASE_URL secret

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: ajianaz <[email protected]>
@ajianaz
ajianaz merged commit 33df675 into develop Oct 7, 2026
14 checks passed
ajianaz added a commit that referenced this pull request Oct 8, 2026
)

Covers security hardening (#563, #572, #573), fixes (#553, #561, #562,
#564, #565, #574-#576), and the ignore-pattern semantic changes from
#577 that can alter which files existing configs exclude.

Signed-off-by: ajianaz <[email protected]>
Co-authored-by: ajianaz <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
@ajianaz
ajianaz deleted the security/untrusted-project-base-url branch October 16, 2026 00:44
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.

1 participant