cd /news/ai-agents/eliminating-the-ai-blast-radius-in-c… · home › topics › ai-agents › article
[ARTICLE · art-170568] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Eliminating the AI Blast Radius in CI/CD: Atomic Pre-Mutation Token Authorization for MCP

A GitLab engineer detailed a fix in MR !270865 that enforces atomic pre-mutation authorization for the company's MCP server, requiring the composite permission set [:play_job, :read_job, :read_pipeline] in find_job! before any GraphQL mutation executes. Previously, a granular PAT holding only :run_job could pass the guard, trigger a production CI/CD job, then fail on response-field reads and return an error to the AI agent—prompting a catastrophic retry loop. The change rejects partial tokens with :unauthorized while leaving the job in manual status, backed by service and request-level RSpec coverage.

by read2 min views1 publishedNov 16, 2026

What happens when an autonomous AI agent calls a CI/CD tool with a fine-grained token that has permission to trigger a production pipeline job, but lacks permission to read the resulting job object? In a naive GraphQL wrapper, the production deployment fires, the response query fails, and the AI agent thinks the call failed—setting up a catastrophic retry loop.

When exposing CI/CD state mutations to AI agents via MCP, authorization cannot be treated as a single flat check. In GitLab's MCP server, the save_pipeline_job tool (Mcp::Tools::Jobs::SavePipelineJobTool) executes a GraphQL mutation ( jobPlay or jobRetry) that both transitions a pipeline job's state and selects fields on the mutated CiJob and its parent Pipeline (such as stage metadata) to return structured confirmation to the agent. While working on Issue #639861 and authoring MR !270865 (test(mcp): add granular token authorization coverage for save_pipeline_job), I analyzed the authorization boundary for GitLab's fine-grained Personal Access Tokens (granular PATs).

A granular PAT configured with the :run_job permission expands internally to :play_job and :retry_job. If the pre-execution guard in find_job! only validates authorize_granular_token!(project, [:play_job]), a token holding :run_job alone passes the gate and invokes GitlabSchema.execute. Inside GraphQL, the mutation succeeds and enqueues the manual CI/CD job on a runner—a permanent side effect. Immediately afterward, GraphQL attempts to resolve the returned job and pipeline stage fields, which require :read_job and :read_pipeline permissions. Because the token lacks those read scopes, GraphQL redacts the return node to nil, and the MCP tool surfaces "Operation returned no job data" (isError: true) back to the agent after the job is already running.

In MR !270865, we enforced atomic pre-mutation authorization by requiring the complete composite permission set—authorize_granular_token!(project, [:play_job, :read_job, :read_pipeline])—inside find_job! before GitlabSchema.execute is ever invoked, accompanied by full service and request-level RSpec suites proving that partial granular tokens ([:run_job] without :read_job and :read_pipeline) are rejected with :unauthorized while the manual job remains untouched in manual status.

GitLab's granular Personal Access Token architecture and MCP security layer (MR !270865) enforce composite pre-flight permission verification across mutation and response-projection boundaries, ensuring AI agents never trigger silent, unobservable CI/CD pipeline executions.

When an AI tool executes a GraphQL mutation and projects fields from the mutated graph, pre-authorize the union of both mutation permissions and response-graph read permissions before executing the mutation—otherwise read redaction looks like a failed write to an autonomous agent.

── more in #ai-agents 4 stories · sorted by recency
── more on @gitlab 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/eliminating-the-ai-b…] indexed:0 read:2min 2026-11-16 · —