Est.

Detecting Shadow AI in Source Code Repositories and CI Pipelines

Scan manifests, secrets, and pipelines to see AI your network tools miss.

· 9 min read
Cover illustration for “Detecting Shadow AI in Source Code Repositories and CI Pipelines”
Enterprise AI Governance · December 1, 2026 · 9 min read · 2,072 words

Shadow AI detection in source code repositories and CI pipelines requires scanning dependency manifests, secrets, pipeline configuration, OAuth grants, and unreviewed MCP server configurations, then correlating those findings with network activity. Network controls alone cannot show which code or agent caused an AI interaction. An inventory of each layer, linked to agent identities that can be held accountable and policy that is enforced, lets teams govern the supply chain they can now see.

Why source code and CI pipelines are the entry point that network controls miss

Network DLP and CASB tools watch outbound traffic, but they cannot establish which repository a prompt came from, what source code left with it, or what AI-generated code returned under a human author’s name. The pipeline has the context those controls lack. IBM found that only 37% of breached organizations had policies to manage AI or detect shadow AI. The gap is therefore not simply a missing traffic alert, but missing oversight of how software gets built.

That gap becomes more dangerous when AI moves from advice to action. CI systems have source-control tokens, registry credentials, cloud keys, and signing keys. An agent using those credentials becomes a privileged operator, while Kubernetes cannot distinguish an attacker’s harmful action from the same action by over-privileged automation. Permission is not a character reference. Canale & Soulis (2026) describe a further compounding risk, showing through a model that shadow IT grows exponentially when agent-created scripts, automations, and MCP servers reproduce faster than the organization retires them.

The six stages of the CI/CD path where shadow AI hides, and what each one exposes

Diagram: The Six-Stage CI/CD Path Where Shadow AI Hides. Visualizes: Show a linear six-stage pipeline flow where each stage passes a distinct risk to the next.

The CNCF threat model maps six stages, each of which passes a different risk to the next. On the developer laptop, unapproved assistants, local model plugins, and MCP connections can expose source code, secrets, and architecture details. Source control then introduces bots that review pull requests, summarize repositories, or generate commits with excessive permissions and unclear ownership. Attribution can break at this first shared boundary. When AI-written changes arrive under human names, they weaken the assumptions that code review and incident response depend on.

The CI pipeline adds agents that use build secrets and cloud credentials to read logs or fix builds. The artifact registry introduces another risk when AI-assisted image or dependency selection brings in vulnerable, malicious, or untraceable components. At the CD platform, agents that approve or modify releases can bypass change controls. Kubernetes runtime access completes the path, where over-privileged ServiceAccounts permit destructive actions or lateral movement. A convenience at one stage becomes authority at the next.

Prompt injection connects these otherwise different surfaces. Agents read issue descriptions, READMEs, dependency changelogs, and build logs, any of which can contain untrusted instructions that steer them toward disclosure or unsafe actions. Cycode identifies AI-generated code as the top blindspot for AppSec teams. The exposure includes both outgoing prompts and incoming, unreviewed output.

Scanning dependency manifests and repository contents for AI SDK and model imports

Static repository scanning offers broad coverage with a low barrier to entry because it starts with code the team already owns. Dependency manifests are useful, but package names are only the beginning. Scans should also look for model API calls, prompt templates, orchestration logic, embedding calls, RAG configurations, MCP configurations, and AI-enabled automation scripts. The target is an integration fingerprint. An unreviewed .cursor/rules file is also a governance gap because it changes how an otherwise approved assistant generates code.

Coverage must span different ways of assembling AI functionality. These include direct provider API calls, frameworks such as LangChain, LlamaIndex, and Semantic Kernel, and self-hosted deployments configured through Ollama, vLLM, or LocalAI. Checkmarx AI Inventory, launched June 2026, is designed to identify models, agents, MCP servers, AI libraries, and SDKs in application repositories and generate an AI Bill of Materials. That AI-BOM gives compliance and audit programs a concrete inventory artifact.

The boundary is still the set of repositories scanned. Laptop scripts, Jupyter notebooks, and pipelines that call models directly may fall outside it, so finding nothing does not prove that no AI is in use.

Finding hardcoded API keys and model credentials before they reach shared surfaces

Hardcoded model credentials are among the most acute findings that repository scanning can produce. A developer can open a personal provider account, expense the API costs, and commit its key. Every clone, fork, and CI run that follows spreads the exposed key. The CNCF model recommends moving secret discovery from post-push checks to pre-commit scanning through a git hook, using a tool such as gitleaks.

Known key patterns are necessary but insufficient. Many providers use generic bearer tokens that evade regex rules designed for recognizable formats. Contextual detection improves coverage by considering variable names such as OPENAI_KEY and nearby endpoint URLs. A matching network flow strengthens the finding further, connecting a credential in code to an otherwise untracked provider interaction.

Attribution needs a separate control from secret hygiene. The same threat model highlights Gitsign, part of Sigstore, which signs commits by replacing long-lived GPG keys with short-lived, identity-based certificates. This makes the identity behind a change auditable, including when that identity belongs to an agent.

Auditing CI environment variables and pipeline configuration files for model credentials

The application repository and the machinery that builds it are distinct detection surfaces, even when their files live together. Pipeline configuration can install an AI SDK, call a model endpoint, or invoke an unreviewed third-party Action without adding an AI dependency to the application. Those instructions deserve their own scanning pass. An AI component introduced there inherits the permissions available to the pipeline runner, making a developer preference part of the software supply chain.

The practical inspection targets are SDK installation steps, model endpoint calls, provider-shaped environment variable names, and AI vendor Actions that have not been reviewed. The CI secrets store is a separate audit target. It may have model keys that were added weeks or months earlier and that pre-commit scanning never saw. Scanning that store for provider credential patterns reaches access that application code analysis cannot.

Agents that analyze logs, generate fixes, or open pull requests are particularly likely to have long-lived, over-scoped tokens provisioned for an immediate problem. The immediate problem may be gone, but the token still has a job. Policy-as-code controls on pipeline definitions provide the structural response to these automated supply-chain changes.

Tracing OAuth grants and permissions given to AI-connected pipeline bots and GitHub Apps

OAuth grants can outlast both the tool that requested them and the developer who approved them. An AI code-review bot or pull-request summarizer may ask for repository read/write permissions when it is installed, then keep its grant indefinitely after people stop using it. Installation is brief. Delegated access can be durable. This makes access records a detection layer in their own right.

An audit should check installed GitHub Apps and their permission scopes, OAuth tokens given to AI-enabled third-party services, bot accounts with commit or webhook permissions, and CI agent service accounts whose scope has never been reviewed. These records expose the privilege transfer described by Canale & Soulis. They also make it harder to attribute changes at source control, where a human name or generic bot account may reveal nothing about the model, prompt, or tool version behind a change.

Once a grant is found, the response is straightforward. Grants that are no longer used should be revoked, those still in use should be narrowed, and people should review AI Apps before giving them write access to production repositories. Teams must first find those grants, though, because an abandoned integration will not ask for its own access review.

Detecting MCP server configurations that have never been formally reviewed

MCP server configurations extend this access problem beyond centrally installed integrations. Developers can connect servers directly through Claude Desktop, Claude Code, Cursor, Codex, and other clients, bypassing an organization-managed gateway. Local configuration becomes an access decision without a central review. These servers may connect to production databases, internal APIs, or Kubernetes clusters, sometimes with embedded credentials.

Developer-environment scanning should therefore cover .mcp.json, claude_desktop_config.json, .cursor/mcp.json, .vscode/mcp.json, and other client configurations that name MCP endpoints. CI runners need the same attention. A build that initializes an MCP client has a live connection to the systems that server reaches for the duration of the job. Cloudflare Gateway illustrates one network-layer approach by identifying MCP requests through protocol-level heuristics, but its shadow MCP coverage applies to managed network paths.

The June 18, 2026 Enterprise-Managed Authorization stable MCP extension moves authorization toward enterprise identity providers as the authoritative provisioner of server access. Its audit trail covers only token issuance. The managed path is the decisive boundary here. EMA does not govern unknown servers configured outside that path, so specification maturity cannot substitute for configuration discovery.

Why behavior-only detection cannot reliably separate an agent from a legitimate automation

Canale & Soulis found that process-and-connection rules flagged every legitimate behavioral twin in their evaluation while still missing agents using local models or driving browsers. Agent Detector instead anchored behavior to remote-service identity and correlated it with configuration, installation, and execution history. It detected every agent in the majority of runs while flagging no behavioral twins. The result supports identity correlation within the evaluation’s limits. An agent and an ordinary automation can have the same outward shape.

For enterprise teams, this explains why artifact scanning and network analysis complement each other. An SDK import or configured endpoint paired with corresponding network traffic produces a high-confidence finding. Conversely, traffic to an AI endpoint with no matching code in scanned repositories indicates an untracked integration. Shared content-delivery networks and relays make behavior alone an unreliable basis for attribution.

Timing creates another limit on runtime detection. The researchers found that attribution behind a shared CDN depended on a DNS cache window of one to five minutes, while an intermittent agent appeared in roughly one scan in three. Continuous scanning improves on point-in-time audits. Build-duration agents are intermittent by design, however, making configuration-file scanning a better fit than runtime monitoring alone.

Giving every AI agent a persistent, attributable identity so its pipeline actions are traceable

Once discovery identifies an agent, governance begins with its identity. Shared service accounts and broad runner identities make it hard to tell which actor made a commit, invoked a tool, or called an API. Their permissions also determine the potential blast radius. A persistent agent identity provides continuity across actions even when the credentials used to authenticate it are short-lived.

The recommended foundation is cryptographic workload identity, replacing shared API keys with SPIFFE/SPIRE-issued SVIDs or federated identity tokens. For multi-step calls on a user’s behalf, OAuth 2.0 Token Exchange (RFC 8693) with the act claim preserves the delegation chain. Credentials should be short-lived and task-scoped.

Microsoft Entra Agent ID, generally available as of April 2026, gives agents first-class directory identity objects and extends Conditional Access, Identity Protection, and audit logging to them. Conditional Access and Identity Protection for agents require a Microsoft Agent 365 licence. The broader control model does not depend on that product. The CNCF model calls for every agent to have a human owner, an identifiable workload registration, least-privilege permissions, and monitoring of its actual behavior.

Making shadow AI discoverable and governable through an official MCP registry and policy enforcement

The AI-BOM becomes useful for ongoing governance when discoveries feed continuous inventory updates beyond an audit report. Repository findings, exposed secrets, CI configurations, OAuth grants, and MCP endpoints collectively populate the inventory. An official registry of approved MCP servers then gives teams a governed route to allowed tools. Servers outside that registry call for remediation as well as an entry in the inventory. Discovery establishes what exists. Approval establishes what may operate.

Approval alone cannot govern every subsequent action. Runtime policy must cover every prompt and tool call through allowlists, DLP rules on inputs and outputs, and step limits and circuit breakers for runaway sessions. In Kubernetes, OPA/Gatekeeper applies policy-as-code to cluster resources, while the approved-agent registry establishes which identities may act. Identity and action controls answer different questions.

MCP’s May 2026 release candidate and July 2026 final release changed what implementations must do to handle stateless sessions, Enterprise-Managed Authorization, Client ID Metadata Documents replacing Dynamic Client Registration, and server-to-client change notifications. Organizations that built their own MCP governance in early 2026 are therefore looking at platforms from outside providers. The lasting requirement is not a particular implementation, but a control loop that keeps discovery, ownership, authorization, and enforcement aligned as the delivery pipeline changes.

Sources

  1. Shadow AI in CI/CD: Threat-modeling the path from developer laptop to Kubernetes
  2. Detecting Shadow AI: Unsanctioned LLM Agents on Enterprise Endpoints: A Taxonomy, an Open Detector and a Controlled Evaluation

More in Enterprise AI Governance