Skip to content

fix(ai-chat): enforce provider-specific permissions for seeded context - #59

Closed
bherila wants to merge 1 commit into
mainfrom
codex/propose-fix-for-ai-chat-security-vulnerability
Closed

bherila wants to merge 1 commit into
mainfrom
codex/propose-fix-for-ai-chat-security-vulnerability

Conversation

@bherila

@bherila bherila commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent AI chat routes (create/read/send) from being used to exfiltrate sensitive provider data (deployment logs, alert rules) when callers only hold broad ProjectsRead/ProjectsWrite permissions.
  • Ensure provider-specific permission boundaries (e.g. deployments:read, otel:read) are enforced before seeding or replaying hidden system context to the AI backend.

Description

  • Add fn required_permission(&self) -> Option<Permission> to the ConversationContextProvider trait so providers can declare a domain-specific read permission.
  • Require Permission::DeploymentsRead for the DeploymentChatProvider and Permission::OtelRead for the AlertChatProvider so their seeded context cannot be accessed without the matching permission.
  • Implement ConversationService::authorize_context(...) to centrally enforce a provider's required_permission and its existing authorize hook before seeding or replaying context.
  • Call authorize_context from the HTTP handlers that create a conversation, fetch conversation history, and send a message so sensitive seeds are checked before being persisted, shown, or sent to the AI backend.
  • Add small unit tests in the service test module exercising the new authorization behavior and update the StubProvider test helper to cover required_permission.
  • Add an ## [Unreleased] CHANGELOG.md entry documenting the security fix.

Testing

  • Ran cargo check --lib -p temps-ai-chat which completed successfully.
  • Ran cargo test --lib -p temps-ai-chat and all tests in the crate passed (75 passed; 0 failed).
  • Verified git diff --check reported no whitespace or diff errors.

Codex Task

@bherila
bherila force-pushed the codex/propose-fix-for-ai-chat-security-vulnerability branch from 9abc9a6 to 069c386 Compare August 15, 2026 07:45
@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 context seed permissions

@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/propose-fix-for-ai-chat-security-vulnerability 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