← Blog

AI Security for Coding Agents: The Source-Code, Secret, and Action Boundaries the Agent Crosses

Coding agents read source code, write code changes, run shell commands, call external APIs, and commit results back to the repository. The agent crosses multiple action boundaries inside a single workflow with the developer identity at the top and machine credentials at the bottom. This piece walks through the source-code data the agent reads at request time, the secret-handling surface the agent exposes, the action boundaries the inspection layer commits decisions at, and the audit record format the security team and the regulator consume.

ByParminder Singh· Founder & CEO, DeepInspect Inc.
Platform & Architecturecoding-agentai-securityidentity-awareaudit-logsinline-enforcementdeveloper-tools
AI Security for Coding Agents: The Source-Code, Secret, and Action Boundaries the Agent Crosses

Coding agents reach the source repository, the build system, the deployment pipeline, the issue tracker, the cloud APIs, and the developer's local machine within a single autonomous workflow. The agent takes the developer's natural-language instruction, reads the relevant files into the LLM context window, drafts a code change, runs the build, runs the tests, opens a pull request, and waits for review. Each step in the workflow crosses an HTTP boundary the agent exercises with credentials supplied by the agent's runtime. The credentials at the bottom of the stack are typically machine credentials with broad scope. The credentials at the top of the stack are the developer's identity from the SSO. The post-authentication gap between the two identities is where the data exposure, the unauthorized commit, and the audit-record obligation live.

I want to walk through the source-code data the coding agent reads at request time, the secret-handling surface the agent exposes, the action boundaries the inspection layer commits decisions at, and the audit record format that satisfies the security team and the regulator.

The source-code data the coding agent reads

The agent reads code into the LLM context window at multiple steps in the workflow. The initial step pulls the relevant files based on the developer's instruction or based on the agent's planning step. A coding agent for a Python service might pull the service's main module, the relevant test files, and any configuration files the change touches. The agent reads the files through filesystem access on the developer's machine or through an HTTP retrieval against the repository's API.

The data inside the source code carries several regulated categories the policy has to handle. Source code itself is intellectual property the deployment treats as sensitive. Hard-coded secrets in old files (API keys, tokens, credentials) reach the LLM context window if the agent retrieves the containing file. Comments that reference customer data, PII, PHI, MNPI, or other regulated identifiers reach the LLM along with the code. License-sensitive third-party code reaches the LLM and the model provider's terms determine whether the inclusion violates the license.

The model the agent calls returns code suggestions, refactor proposals, or full file changes. The response reaches the agent's runtime and the agent applies the change against the local filesystem or against the repository. The response can also include the original code (or sensitive content from the prompt) verbatim, which the agent's runtime may write to logs or to a debug surface inside the developer's environment.

The secret-handling surface

Coding agents handle three categories of secrets inside the workflow. The first is the LLM API key the agent uses to call the upstream model. The key has to remain inside the agent's runtime and outside the prompt the model sees. A misconfigured agent that logs the prompt or that includes the runtime environment in the context exposes the key to the model and to the model provider's data retention.

The second is the repository and platform credentials the agent uses to commit changes, open pull requests, and trigger CI runs. The credentials are typically machine identities (a GitHub App, a deploy key, a service account) with scoped permissions. The agent's runtime supplies the credentials at each downstream call. The post-authentication gap shows up when the audit record at the platform side carries the machine identity, not the developer's identity.

The third is the secrets the source code references at runtime (environment variables, config-managed secrets, cloud IAM credentials). The agent may read configuration files that reference the secrets by name. The agent's planning step may surface the secret names in its reasoning. A change the agent drafts may inadvertently log secret values or include them in committed files.

The defense covers the LLM API call surface (the inspection layer reads the prompt and detects hard-coded secrets before forwarding), the platform call surface (the inspection layer records the developer identity alongside the machine credential), and the runtime-secret surface (the agent's prompt-time classifier detects secret references in retrieved files and the policy either redacts or blocks the inclusion).

The action boundaries the inspection layer commits decisions at

Coding agents cross at least four action boundaries inside a single workflow.

The first is the LLM API call. The agent sends a prompt to the upstream model. The inspection layer reads the prompt (including the retrieved code), classifies the content, evaluates identity-bound policy, and commits the per-decision audit record before the response forwards. The policy at this boundary covers source-code classification (sensitive files, license-controlled files), secret detection in the retrieved code, and PII or PHI in comments and strings.

The second is the repository write boundary. The agent commits the code change to a branch, opens a pull request, or pushes to a CI-triggering branch. The inspection layer at the repository's API boundary records the developer identity (the natural person on whose behalf the agent acts), the machine credential the agent used, the route (which repository, which branch), and the decision outcome. The policy at this boundary covers branch-protection compliance, required-reviewer rules, and any additional gates the deployment runs (license-check, secret-scan).

The third is the build and test boundary. The agent triggers a CI run. The CI calls back to the agent's runtime and the agent's runtime may receive the build artifacts or the test failures. If the artifacts reach the LLM context window for the agent's debugging step, the inspection layer at the LLM boundary reads them and applies the policy.

The fourth is the deployment boundary. An agent authorized to deploy reaches the cloud control plane (Kubernetes API, cloud provider APIs) and applies changes. The inspection layer at the cloud-API boundary records the developer identity, the machine credential, the route, and the decision. The policy at this boundary covers production-environment access, blast-radius limits, and the role-based scope the developer authorized for the agent's session.

The audit record the security team and the regulator consume

The record at each action boundary carries the seven fields the inspection layer commits: identity (the natural person and the agent), route (which boundary in the workflow), data classification (sensitive source code, secrets, license-controlled content, PII or PHI in comments), policy version, decision outcome (pass, block, or modify with the rule identifier), the upstream service identity and version (the LLM, the repository, the CI, the cloud API), and integrity metadata.

The records for a single agent workflow share a correlation identifier so the reviewer reads the four-or-more records as a single workflow. The reviewer reads "developer X asked the agent to change service Y; the agent retrieved files A, B, C; the agent called the LLM with the prompt containing the files (no secrets detected); the LLM returned a change; the agent committed the change to branch B1; the change passed the CI run; the deployment did not auto-apply because the policy required human approval for production." The reviewer reconstructs the workflow from the single record series.

The format satisfies the EU AI Act Article 12, the NIST AI agent identity and authorization Pillar 2 and Pillar 3, the DORA Article 19 operational record-keeping, the SOC 2 Type II audit trail criterion, and the ISO 42001 control evidence requirement.

What NIST and EU AI Act expect for autonomous coding agents

NIST AI agent identity and authorization framework codifies three pillars. Pillar 1 is agent identity (the agent's runtime announces what it is). Pillar 2 is delegated authority (the agent acts under the developer's authority, scoped to a specific session). Pillar 3 is action lineage (the structured record of who authorized what, under which policy, at what moment). Coding agents exercise Pillar 2 and Pillar 3 across every action boundary in the workflow. The inspection layer at each boundary produces the action lineage records.

EU AI Act Article 12 expects records of input data, identity of natural persons involved, and the period of use. A coding agent that operates inside a deployment classified as high-risk (for example, a deployment used in the operation of critical infrastructure or in a regulated industry's product) produces decisions inside the scope. The audit record series the inspection layer commits provides the records.

The August 2, 2026 high-risk system requirement reaches deployments that operate in classified domains. Coding agents inside financial services, healthcare technology, and critical-infrastructure platforms fall inside the classification in proportion to the agent's authorized scope and the systems the agent reaches.

The architectural pattern that produces the records

The pattern is the inspection layer at each HTTP boundary the coding agent crosses, with shared identity propagation from the developer's SSO session through the agent's runtime to each upstream the agent calls. The inspection layer reads the request at the boundary, classifies the content, evaluates identity-bound policy, applies pass, block, or modify, and commits the per-decision audit record before the response forwards.

The deployment instruments the agent's runtime to propagate the developer identity in each request the agent makes. The propagation pattern attaches the developer identity as a request header, in a signed JWT, or through a service-mesh identity-propagation mechanism. The inspection layer's policy reads the developer identity and the machine identity together and evaluates the policy against both.

The pattern composes with defense-in-depth layers inside the coding agent (sandboxed execution, output filtering, scope-limited credentials). The inspection layer at the request boundary produces the audit record series the regulator and the security team consume. The defense-in-depth layers cover the cases the inspection layer cannot see (the local filesystem operations, the in-memory state of the agent's planning step).

DeepInspect

This is exactly what DeepInspect does for coding agents. DeepInspect sits inline between the coding agent's runtime and any HTTP upstream the agent calls (LLM endpoint, repository API, CI API, cloud control plane, internal service APIs). The inspection layer reads the request at each boundary, classifies the content (sensitive source code, hard-coded secrets, license-controlled content, PII or PHI in comments), evaluates identity-bound policy against the developer identity and the machine credential, applies pass, block, or modify, and commits the per-decision audit record to durable, append-only storage with a cryptographic integrity signature before the response forwards.

The records share a correlation identifier across the action boundaries so a single workflow produces a coherent series the reviewer reads in chronological order. The series satisfies the NIST AI agent identity and authorization Pillar 2 and Pillar 3, EU AI Act Article 12, DORA Article 19, ISO 42001, and SOC 2 Type II audit trail expectations. End-to-end inspection-layer overhead measures under 50 ms in production.

If you are running a coding agent in production and the security team or the audit reviewer is asking for the records of what the agent did under whose authority, book a demo today.

Frequently asked questions

Does the inspection layer interfere with the coding agent's autonomy?

The inspection layer's pass decision forwards the request unchanged with under 50 ms of overhead. The agent's autonomy is preserved for requests the policy allows. The layer's block or modify decisions surface to the agent's runtime as structured errors or as modified inputs the agent acts on. The deployment configures the policy so the routine actions the agent takes pass cleanly and the unusual actions (production deployments, broad-scope reads, secret-laden prompts) require additional evidence or human review. The autonomy is preserved on the actions the policy authorizes.

How does the inspection layer detect secrets in the source code the agent reads?

The inspection layer reads the prompt the agent sends to the model. The prompt includes the retrieved code. Secret-detection classifiers (entropy-based detection, known-pattern detection for API keys and tokens) run on the content. The detection result composes the data classification at decision time. The policy can block the request, modify the prompt (redact the secret span), or pass with the detection recorded in the audit record. The deployment also runs static analysis inside the agent's pipeline as a defense-in-depth layer, but the inspection layer covers the case where the secret reaches the model boundary regardless of the upstream pipeline's coverage.

How does the inspection layer cover the agent's local filesystem operations?

Local filesystem operations do not cross an HTTP boundary the inspection layer reads. The inspection layer covers the HTTP boundaries the agent crosses (LLM, repository API, CI API, cloud APIs). The deployment runs defense-in-depth layers inside the agent's runtime for filesystem operations (sandboxed execution, scope-limited filesystem mounts). The inspection layer's records cover the actions that cross HTTP boundaries, which is where the regulatory record-keeping obligation sits.

What audit records does the inspection layer produce for CI-triggered agent actions?

The CI run is a downstream effect of the agent's commit. The CI run's logs live in the CI system. The inspection layer's records cover the agent's commit (the request to the repository's API) and the agent's subsequent reads of the CI artifacts (the requests to the CI's API or the LLM call that includes the CI output). The two record series compose: the CI's native logs cover the build mechanics, the inspection layer's records cover the agent's request-time decisions and the identity context at each boundary.

How does the inspection layer handle agents that operate across multiple repositories?

The agent's session carries the developer identity. The inspection layer records the developer identity at each request boundary regardless of which repository the agent targets. The audit record series carries the route (which repository, which branch) and the policy version at each decision. The reviewer reads the series across repositories in chronological order with shared identity context. The policy can be scoped per repository or per organization, and the records show which policy version evaluated eac