Application Security

Runtime Security for AI Coding Agents

Coding agents run commands, read files and make network calls on developer machines and CI runners. Preventive controls reduce the risk, but detection still matters. This article covers the telemetry to collect from coding agents, detection rules that catch misuse and compromise, and how to respond.

By EthicalHat Research · · 3 min read
Infographic: What to watch when coding agents run

Coding agents are now a standard part of software development: in developers' terminals and IDEs, in cloud workspaces and in CI pipelines. We have written about guardrails for AI-powered development and about securing agents' shell, secrets and Git access. Those preventive controls are essential. They are also imperfect: prompt injection has no complete fix, sandboxes are misconfigured, and developers sometimes run agents with more access than intended.

So security teams also need to see what coding agents do at runtime, and respond when it goes wrong.

Why coding agents need runtime monitoring

From an endpoint security perspective, a coding agent is a process tree that:

  • spawns shells and runs arbitrary commands,
  • reads and writes many files, including configuration and dotfiles,
  • makes network connections to model providers, package registries and more, and
  • operates Git, sometimes with push access.

That is exactly the behaviour endpoint detection tools are trained to be suspicious of, and exactly the behaviour a compromised or manipulated agent would use to steal secrets or cause damage. The challenge is distinguishing normal agent activity from abuse.

Telemetry to collect

SourceWhat to capture
Endpoint / EDRProcess trees rooted at agent processes, command lines, file access to sensitive paths, network connections
Agent tool logsSession ID, prompts or task, tool calls, commands proposed and approved, files changed
Git hostPushes, branch creation, force-push attempts, changes to workflow files
CI runnerJob, trigger, token permissions, egress destinations, commands run
Identity provider / cloudToken issuance and use from developer and runner environments

The key is correlation: linking an EDR alert on a laptop to the agent session, the task and the repository content that was in its context at the time.

Detections that work

Credential access from agent process trees. Reads of ~/.ssh, ~/.aws, ~/.config/gcloud, ~/.kube, browser profile directories, password manager files or wallet files by processes descended from an agent.

Unusual egress. Connections from agent processes to destinations outside the allow-list (model provider, package proxy, Git host), especially paste sites, file-sharing services, raw IP addresses or newly registered domains.

Destructive or high-risk commands. Mass deletion, git push --force, history rewriting, database drop or truncate commands, infrastructure destroy commands, or kubectl against production contexts.

Persistence and tampering. Changes to shell profiles, cron jobs, Git hooks, CI workflow files or agent configuration files by an agent session.

Discovery patterns. Rapid enumeration of the home directory, environment variables or credential stores, which is typical of secret-hunting payloads that abuse AI CLIs.

An illustrative detection in a Sigma-like format:

yaml
title: Coding Agent Accessing Cloud Credential Files
logsource:
  category: file_access
detection:
  agent_process:
    ParentImage|endswith:
      - '/claude'
      - '/codex'
      - '/gemini'
      - '/copilot-agent'
  sensitive_path:
    TargetFilename|contains:
      - '/.aws/credentials'
      - '/.config/gcloud/'
      - '/.kube/config'
      - '/.ssh/id_'
  condition: agent_process and sensitive_path
level: high

Adjust process names to the tools you have approved, and tune per environment; some legitimate workflows will need exceptions.

CI runners

On CI runners, agents typically run in ephemeral jobs. Useful signals include:

  • jobs triggered by untrusted actors that invoke agents,
  • attempts to read secrets not used by the job,
  • outbound connections outside the runner's allow-list, and
  • modifications to workflow files or build scripts within agent jobs.

Response playbook

flowchart LR
  A[Alert on agent activity] --> T[Triage<br/>session, task, repo, user]
  T -->|benign| Tune[Tune detection / exception]
  T -->|suspicious| C[Contain<br/>kill session, isolate host,<br/>revoke tokens]
  C --> I[Investigate<br/>prompt & context,<br/>files read, egress]
  I --> R[Remediate<br/>rotate secrets, remove<br/>malicious content or tool]
  R --> L[Lessons<br/>policy, sandbox, detections]
  1. Contain: stop the agent session, isolate the host or runner if needed, and revoke tokens that were accessible.
  2. Investigate: reconstruct what the agent was asked to do and what it read, including repository files, issues, dependencies and web pages, to find the source of manipulation.
  3. Scope: determine which files, secrets and systems were accessed, and whether data left the environment.
  4. Remediate: rotate secrets, remove the malicious content or compromised tool version, and fix the gap that allowed it.
  5. Learn: update sandbox policies, command policies and detections.

Making it practical

  • Start with the highest-signal detections: credential file access and unapproved egress from agent process trees.
  • Standardise agent tools so detections can target known process names and paths.
  • Log agent sessions centrally; many tools can export transcripts or structured logs.
  • Include developer endpoints and CI runners in the SOC's scope, with the same care as servers.

The bottom line

Coding agents are among the most privileged software running in an engineering organisation, and they take instructions from text. Preventive controls reduce the risk; runtime monitoring tells you when those controls fail. Watch what agents execute, read and connect to, correlate it with what they were asked to do, and have a playbook ready.

Our managed detection and response service extends to developer endpoints and CI runners, and our endpoint security team helps tune detections for AI coding agents.

EthicalHat Research

The EthicalHat research team: penetration testers, SOC analysts and engineers writing about security, software engineering and AI.

Want an expert opinion on your own systems?

Email info@ethicalhat.com or call +1-844-838-4422. Our security engineers are happy to talk it through.