SEE ALL INSIGHTS

Securing Claude Code Before the Agent Acts

Published on

November 24, 2026

Reading Time:

5

Minutes

By

Kevin Kelleher

Table of Contents

Share:

Claude Code acts with your developer's credentials: it reads files, runs shell commands, and calls Model Context Protocol (MCP) servers. HiddenLayer lets your security team see what the agent does and stop a prompt or tool call before it runs, by checking it against your policy first. It works through Claude Code's hooks.

This is the second integration spotlight in our series on AI security that meets you where you are. The first covered Cursor; earlier posts covered the cloud and the SOC.

The agent is the attack surface

In Claude Code, the model proposes actions. The harness, meaning the prompts, tools, and MCP servers around it, carries them out. Our research on coding agents shows the exposure: agents pull in READMEs, documentation, issues, and tool output automatically, and any of them can carry instructions. Hide a paragraph in a README, and the agent that reads it may be told to find credentials and send them to an outside server. Hide instructions in an MCP tool's description or result, and the agent may treat them as its own. A remote server can change after you approve it.

Why existing controls miss it

Denylists judge text, and attackers choose the text. Per-tool approvals judge one call at a time, while an attack is a sequence. Endpoint tools see that a command ran, not why the agent chose it. Application security tools were not built for multi-step agent workflows. Agent behavior varies run to run, so you cannot list every path. The control has to sit outside the model.

What HiddenLayer does in Claude Code

Claude Code fires hooks at fixed points in its agent loop. At each gate, the hook calls HiddenLayer's on-device plug-in, which sends what is crossing the hook to HiddenLayer. HiddenLayer checks it against your project's policy and returns NONE, DETECT, REDACT, or BLOCK. Claude Code then blocks the action, substitutes redacted content, or proceeds. The decision comes from detections powered by our adversarial AI research, including more than 65 disclosed CVEs.

Follow one prompt:

  1. The developer submits a prompt. HiddenLayer's user-prompt-submit endpoint can block the prompt or flag it before the model sees it.
  2. The model proposes a tool call, such as a shell command. The pre-tool-use endpoint can block the call, flag it, or let it run with sanitized input.
  3. The tool returns output. The post-tool-use endpoint can block the result, flag it, or give the model a sanitized version.
Flow from a Claude Code hook through the on-device plug-in to HiddenLayer, a decision of NONE, DETECT, REDACT, or BLOCK, and Claude Code blocking, substituting redacted content, or proceeding, with every interaction recorded in the HiddenLayer Console
  • Whole session. HiddenLayer evaluates the session, not each step alone, so it can spot combinations that turn benign activity into an attack.
  • One policy. The project policy that governs your other AI traffic governs Claude Code.

Redaction lets the agent keep working without the secret, but a prompt cannot be rewritten, so a redact decision at the prompt becomes a block. Some gates fire after an action has finished, and those can only record. The HiddenLayer Console holds every interaction and shows whether policy was applied as configured, strengthened, or only observed.

How it works for HiddenLayer customers

  1. Create an API key and a project in the HiddenLayer Console. Projects allow one-stop policy application across grouped agents and other AI artifacts.
  2. Get the plug-in from your HiddenLayer representative and deploy it with your mobile device management (MDM) tool, such as Jamf or Microsoft Intune.
  3. Set credentials with hl config, check them with hl runtime auth, and install the hooks with hl runtime setup claude-code.
  4. For rules you add, start on the Detect list and review findings in the Console. Then move trusted rules to the Block list.
  5. Five prompt injection detections are assigned to detect and enforce inline from day one, including Coerced Data Exfiltration, Coerced Execution, and Coerced Secret Read.

Book a demo to see Agent Harness Security running with Claude Code.

‍

Related Insights

Insights
min read

How HiddenLayer Secures Cursor AI Agents

See how HiddenLayer secures Cursor AI coding agents by monitoring prompts, file reads, shell commands, and MCP calls, then blocking or redacting risky actions.

Insights
min read

Agent and Model Detections in Splunk and Sentinel, Without a New Queue

Send AI agent and model detections to Splunk or Microsoft Sentinel. Correlate and investigate AI security events in existing SOC workflows, without a new queue.

Insights
min read

One Policy for AI Security Across Every Cloud You Run

HiddenLayer unifies AI security across AWS, Azure, and Databricks. Discover models and agents, scan models, test AI apps, and enforce runtime policies.

Stay Ahead of AI
Security Risks

Get research-driven insights, emerging threat analysis, and practical guidance on securing AI systems—delivered to your inbox.

Thanks for joining us!

Your subscription is confirmed, and updates
will be on the way soon.
Oops! Something went wrong while submitting the form.