Skip to content
Datadog Security Labs·Indexed by this site · Originally published· Attacks →SelectedAttention37

Datadog discloses code execution paths in Codex and Claude Code before the first prompt

Before the first prompt: Code execution paths in trusted coding-agent projects

AI summary

Datadog Security Labs found that after trusting a repository in a coding agent, code controlled by the repository may run before the user sends the first prompt. In Codex, project-level MCP configuration (mcp_servers in .codex/config.toml) causes Codex to start attacker-controlled local processes without user interaction or invoking that server; starting from Codex 0.122.0, hooks and execution policies from untrusted projects are no longer loaded, from 0.129.0, command hook definitions outside managed configuration are hashed and require review, and from 0.131.0, a full startup review interface is added, but only command hook paths receive a second trust review. In Claude Code, .claude/settings.json can define session environment variables; by pointing PATH to a directory within the project, the Git probe that runs automatically at Claude startup executes a git wrapper script in the repository, which can also delegate to the real git to keep the flow normal.

Why it was selected

The article provides two automatic code execution paths in Codex and Claude Code after project trust and before the first prompt, along with reproducible detection commands.

Read originalsecuritylabs.datadoghq.com