Skip to content

fix(api): bind git scan session credentials to URL#213

Open
AkaraChen wants to merge 1 commit into
mainfrom
codex/fix-git-scan-session-token-replay-vulnerability
Open

fix(api): bind git scan session credentials to URL#213
AkaraChen wants to merge 1 commit into
mainfrom
codex/fix-git-scan-session-token-replay-vulnerability

Conversation

@AkaraChen

Copy link
Copy Markdown
Owner

Motivation

  • Prevent replay of raw credential tokens stored in a GitCloneSession to attacker-controlled repository URLs by enforcing the original session URL as an authorization boundary.
  • Ensure cached branch lists from a previous session are not reused for a different URL, removing an additional information leak and preventing unnecessary network calls.

Description

  • Add git_scan_session_data(session, request_url, reuse_credentials) which returns session-derived credential token and branch cache only when request_url equals the session's stored url, and rejects credential reuse with SESSION_URL_MISMATCH if the session carried a credential and the URLs differ.
  • Update /skills/git/scan to call the new helper and only use a session credential when the request explicitly omits credential_id and the requested URL matches the session URL; otherwise fall back to explicit credential_id or no credential.
  • Avoid returning cached branches from a mismatched session by coupling branch cache usage to the same URL-match check.
  • Add unit tests covering allowed same-URL credential reuse, rejection of credential reuse when URLs differ, and behavior when a mismatched session exists but credentials are supplied explicitly.

Testing

  • Ran formatting and style checks with cargo fmt -p aghub-api --check which passed.
  • Ran repository checks (git diff --check) and file formatting verification which passed locally in the change set.
  • Attempted to run the new unit tests via cargo test -p aghub-api git_scan_session_data -- --nocapture but test execution was blocked by the environment (missing sccache/toolchain wrapper) and by crates.io network proxy errors (HTTP 403) when downloading dependencies, so unit tests could not be executed end-to-end in this environment.

Codex Task

@coderabbitai

coderabbitai Bot commented Jun 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@AkaraChen, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 27 minutes and 48 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff7ca9b5-d2d2-4601-9651-beb706aec024

📥 Commits

Reviewing files that changed from the base of the PR and between 88dc33e and 1dfe2c7.

📒 Files selected for processing (1)
  • crates/api/src/routes/skills.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-git-scan-session-token-replay-vulnerability

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant