Skip to content

fix(copilot): stop returning generate_api_key plaintext on the in-band tool route - #8042

Merged
waleedlatif1 merged 1 commit into
stagingfrom
sec/copilot-genapikey-redaction
Sep 19, 2026
Merged

waleedlatif1 merged 1 commit into
stagingfrom
sec/copilot-genapikey-redaction

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Copilot tool results reach the model over two lanes, but the model-facing projection was applied on only one. The resume lane runs results through getToolCallTerminalData, which reduces generate_api_key to its status message; the in-band route (POST /api/copilot/tools/execute) returned the handler output verbatim, so the freshly minted plaintext workspace API key crossed to the model and into the turn transcript.
  • The egress projection could not cover this. Its registry is a catalog of pre-existing environment and credential secrets, built once per turn, so a key minted mid-turn is invisible to it.
  • Apply toolResultForModel at the route so both lanes return the same model-facing projection. It is an identity for every tool except generate_api_key.
  • Behavioral note: on the in-band lane the browser's only copy of the key arrived via the relayed tool result, so the sim_key chip now renders masked there. Redacting at the shared projection instead is not an option — the main lane's client carve-out reads that same projected output, so it would break the chip everywhere.

Type of Change

  • Bug fix

Testing

  • Added regression tests on the in-band route: generate_api_key returns only the status message and no key field; a non-generate_api_key result carrying a key field is untouched; a failed call passes its error through. Verified the new test fails when the fix is reverted.
  • vitest run app/api/copilot lib/copilot — 2636 passed, 3 skipped
  • tsc --noEmit clean, bun run lint clean, check:audits 47/47 passing, docs-manifest:check in sync

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…d tool route

Tool results reach the model over two lanes, but the model-facing projection was
applied on only one. The resume lane runs results through getToolCallTerminalData,
which reduces generate_api_key to its status message. The in-band route
(POST /api/copilot/tools/execute) returned the handler output verbatim, so the
freshly minted plaintext workspace API key crossed to the model and into the turn
transcript.

The egress projection cannot cover this: its registry is a catalog of pre-existing
environment and credential secrets, built once per turn, so a key minted mid-turn is
invisible to it.

Apply toolResultForModel at the route so both lanes return the same model-facing
projection. It is an identity for every other tool.
@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 19, 2026 11:46pm UTC

Request Review

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge and correctly aligns the in-band route with the existing resume-lane secret projection.

Summary

This PR closes a plaintext API-key disclosure in the Copilot in-band tool-execution lane by applying the existing model-facing result projection before returning tool output.

  • generate_api_key responses now expose only their status message to the model.
  • Other tool outputs and failed API-key calls retain their existing response behavior.
  • Regression tests cover secret removal, non-target passthrough, and error passthrough.
Diagram
sequenceDiagram
  participant Model
  participant Go as Go relay
  participant Route as In-band execute route
  participant Tool as Tool handler
  Go->>Route: Execute generate_api_key
  Route->>Tool: Run tool
  Tool-->>Route: Raw result containing plaintext key
  Route->>Route: toolResultForModel(...)
  Route-->>Go: Status message only
  Go-->>Model: Redacted tool result
Loading

Reviews (1) · Last reviewed commit: "fix(copilot): stop returning generate_ap..."

@waleedlatif1
waleedlatif1 merged commit 0d9e256 into staging Sep 19, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the sec/copilot-genapikey-redaction branch September 19, 2026 23:50

This branch was previously deployed

1 inactive deployment
Preview d7ada534 Deployed Sep 19, 2026 by vercel[bot]
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