Skip to content

fix(ai-chat): enforce git repo permissions for AI tools - #54

Closed
bherila wants to merge 1 commit into
mainfrom
codex/fix-ai-repo-tools-permission-bypass
Closed

bherila wants to merge 1 commit into
mainfrom
codex/fix-ai-repo-tools-permission-bypass

Conversation

@bherila

@bherila bherila commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Motivation

  • A sentinel provider exposed repository-exploration tools (read_repo_file, list_repo_dir, list_repo_branches, list_repo_tags) into every chat when a project had a Git connection, but tool discovery and execution were not scoped to the caller's permissions, allowing callers with ProjectsWrite but without GitRepositoriesRead to cause the server to use stored Git provider tokens and read private repo data.

Description

  • Add an auth-aware discovery hook tools_with_auth to ConversationContextProvider so providers can consider the caller's AuthContext when advertising tools (new default delegates to tools).
  • Update ConversationService to call tools_with_auth during tool collection and to dispatch repo tool calls via execute_tool_with_auth so the caller's AuthContext is propagated to providers.
  • Change RepoToolsProvider to implement tools_with_auth and execute_tool_with_auth and require Permission::GitRepositoriesRead (checked via auth.has_permission(&Permission::GitRepositoriesRead)) before advertising or executing repo tools, returning a readable denial message when missing.
  • Add a regression test ensuring forced execution without GitRepositoriesRead is denied, and update CHANGELOG.md with a security fix entry.

Testing

  • Ran cargo check --lib -p temps-ai-chat, which completed successfully.
  • Ran unit tests cargo test -p temps-ai-chat providers::repo_tools, which passed (all provider tests including the new permission denial test succeeded).

Codex Task

@github-actions

Copy link
Copy Markdown

📓 Changelog preview

This is what your commits will add to the generated CHANGELOG.md at release time (via git-cliff). Do not edit CHANGELOG.md by hand — it is generated from your Conventional Commit messages.

## [Unreleased]

### Fixed

- **ai-chat:** Enforce git repo permissions for AI tools

@bherila
bherila force-pushed the codex/fix-ai-repo-tools-permission-bypass branch from ef61f90 to 5707965 Compare August 15, 2026 07:45
@bherila

bherila commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

The functional change was carried into upstream security-hardening PR gotempsh#676 and its merged replacement gotempsh#677. Upstream gotempsh#676 explicitly lists this fork PR in its source coverage.

Fork main has now been fast-forwarded to upstream main at 7250ab59b38d3138014ade7f5d6391c856eaa4f7. Closing this obsolete fork PR as part of the upstream synchronization; its branch history is retained.

@bherila bherila closed this Oct 11, 2026
@bherila
bherila deleted the codex/fix-ai-repo-tools-permission-bypass branch October 11, 2026 19:12
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