Skip to main content
Secure coding checks are Coding Agent Governance policies that inspect what an AI coding agent produces, not just the shape of its actions. Four checks are available:
  • A malware check for the packages an agent installs or adds to a manifest.
  • A dependency risk check for dependencies with known vulnerabilities.
  • A secrets check for the content an agent writes and reads.
  • A prompt injection check for instructions planted in prompts and tool output.
All four run in the agent loop, so they catch problems at the moment they happen instead of in a later scan. Other Coding Agent Governance policies match patterns you author, such as regex patterns for commands and file paths. Secure coding checks have no patterns to maintain. The policy decides when the check runs and which action follows a match. The verdict comes from Endor Labs data: the malware feed and vulnerability data for packages, the secret detection rules library for content, and the prompt injection rules for text.

Malware check

The malware check fires when a governed agent installs a package or edits a manifest or lockfile to add one. The check looks up the package in the Endor Labs malware feed, the same intelligence that powers malicious package detection and Package Firewall. Only confirmed malware triggers the policy. Contested records and records under review do not. The check parses the packages out of the install command the agent runs. It recognizes the following package managers:
  • npm: npm, pnpm, yarn, bun, npx, and bunx.
  • PyPI: pip, python -m pip, poetry, pipenv, uv, and uvx.
  • Go: go install, go get, and go run with a versioned remote module, such as go run example.com/tool@v1.2.0.
  • NuGet: dotnet add package, nuget, and paket.
  • Packagist: composer.
  • Crates: cargo.
  • RubyGems: gem and bundle.
  • OS package managers: apk, apt, yum, dnf, and zypper.
A command hidden behind a wrapper still counts. The parser unwraps prefixes such as sudo and env, and inline shells such as bash -c "npm install …". The check also runs when the agent writes or edits a manifest or lockfile. It compares the file before and after the edit and checks only the packages the edit adds. See Supported manifests and lockfiles to review the files it reads. It skips npm dependencies that point to a local path, a workspace, a git source, or a URL. The check judges the version the package manager would install. It looks up an exact version, a pinned manifest entry, or a lockfile entry at that version. For an unpinned npm, PyPI, or Go install, or a version range in npm or PyPI, the check resolves the highest stable version the install or range allows. The policy then triggers only in the following cases:
  • The feed flags the resolved version.
  • The feed flags every version of the package.
  • The feed flags a version newer than the resolved one, and the install would pick it.
An older malicious release of a package doesn’t trigger the policy when the version that would install is clean. When the check can’t resolve a version, any malware record for the package triggers the policy. This applies in the following cases:
  • An unpinned install or a range in any other ecosystem, such as Cargo or RubyGems.
  • A Maven entry without an exact version, such as a range, a ${property} reference, or an entry with no version.
  • An npm tag other than latest, such as beta.
  • A Go version query that isn’t a version number or latest, such as a branch name or upgrade.
  • A Python install that allows prerelease versions, through --pre, --allow-prereleases, or --prerelease allow, or through a specifier such as pkg>=1.0rc1.
  • A package with no known versions, a range that no stable version satisfies, or a version lookup that fails or doesn’t finish in time.
An npm or PyPI range that excludes a single flagged version is the exception. For example, ^5.0.0 doesn’t trigger on a record for version 4.4.2. A malware violation includes the evidence your team needs to respond:
  • The package name, version, and ecosystem from the install or edit. For an unpinned install or a range, the version is the one the check expects the install to pick. The version is empty when the check couldn’t resolve one.
  • A summary of the malware report and the reasons the feed flagged the package.
  • The feed source that flagged the package.
A malware check applies to all ecosystems by default. To limit a policy to specific ecosystems, select them under Ecosystems in the policy form, or set the ecosystems list through the REST API. The valid tokens are npm, pypi, go, mvn, nuget, packagist, cargo, gem, apk, debian, and rpm, and Endor Labs rejects a policy with any other value. Maven has no install command, so mvn applies only to manifest and lockfile edits. The form doesn’t offer Maven, so set mvn through the REST API. The out-of-the-box policy Malware: block installs of known-malicious packages is disabled by default. Enable it, or create your own malware policy, to turn the check on.

Create a malware policy

To create a malware policy in the Endor Labs user interface:
  1. Select User menu > Policies & Rules from the left sidebar.
  2. Select Agent Governance.
  3. Click Create Agent Governance Policy.
  4. Under Policy Template, choose Malware under Secure Coding.
  5. Optional: Under Ecosystems, select the ecosystems to check. Leave it empty to check every ecosystem.
  6. Under Choose an Action, select Block, Alert, or Ask Permission.
  7. Under Name Your Policy, enter a Name, then click Create Agent Governance Policy.
Malware policy template with the Ecosystems field and the action choices The following example creates a malware policy scoped to npm and PyPI installs with endorctl. Replace <namespace> with the namespace that owns your Coding Agent Governance policies. Leave ecosystems empty to check every ecosystem.
The policy appears under Policies & Rules > Agent Governance, and hooks pick it up at the next session start.

Secrets check

The secrets check scans content the agent touches for secrets, such as cloud access keys, provider tokens, and private keys. By default a policy scans the content of file writes and edits. To also scan the files the agent reads, select Read under File Operations, or list FILE_OPERATION_READ with FILE_OPERATION_WRITE and FILE_OPERATION_EDIT in file_operations. A list of only FILE_OPERATION_READ scans reads only. Read scanning is opt-in because it reads each file from disk. Detection uses the Endor Labs secret rules library, the same rules as secrets scanning. See Secret detection rules to browse the full library. The scan runs on the developer’s machine, and the scanned content never leaves it. A secrets violation includes:
  • The rule that fired, such as aws-access-token or github-pat, with its human-readable name.
  • The line and column where the secret starts.
  • A fingerprint that groups repeat findings of the same secret.
The violation never includes the secret value, so a match can’t leak the credential it found. Endor Labs also scrubs the detected string from the event evidence it stores. It replaces every occurrence in the captured tool input and output with REDACTED. When a permitted operation runs, the follow-up event records that the operation happened without the file content. Four more policy fields shape the check:
  • Include File Patterns (include_file_patterns) limits scanning to matching paths, and Exclude File Patterns (exclude_file_patterns) skips paths such as test fixtures or vendored directories. Exclusions apply after inclusions. An empty configuration scans every file the event covers.
  • Include Rule IDs (include_rule_ids) limits the policy to specific detection rules, and Exclude Rule IDs (exclude_rule_ids) mutes rules whose matches are false positives in your codebase. Both match rule IDs such as aws-access-token exactly. Exclusions apply after inclusions.
To create a secrets policy, follow the malware procedure and choose Secrets under Secure Coding. Choose the operations to scan under File Operations: Write, Edit, or Read. Through the REST API, use a secrets_check activity in place of malware_check in the malware example. Endor Labs rejects FILE_OPERATION_DELETE, because a delete writes no content to scan. Two out-of-the-box secrets policies are disabled by default: Secrets: block writes that introduce a credential and Secrets: ask before reading a file that holds a credential. Enable them, or create your own secrets policy, to turn the check on.

Scan MCP tool calls for secrets

A secrets policy can also scan the arguments and results of MCP tool calls in Claude Code, Codex, Cursor, and GitHub Copilot. The policy form doesn’t offer this yet. Set the following fields on the secrets_check activity through the REST API:
  • mcp_payloads: List MCP_PAYLOAD_INPUT to scan tool arguments before the call runs, and MCP_PAYLOAD_RESPONSE to scan results after the call returns. An empty list scans no MCP calls.
  • include_mcp_server_patterns and exclude_mcp_server_patterns: Optional regex lists matched against the MCP server name. Exclusions apply after inclusions. An empty configuration scans every server. The patterns apply only when the call names a server. Endor Labs always scans a call with no server name, or a sub-agent call that reports an ID instead.
A finding in the arguments applies the policy’s action, so a Block policy stops the secret before it reaches the server. Endor Labs always records a finding in a result as an alert, because the result has already reached the agent. In both cases, Endor Labs scrubs the detected values from the MCP events it stores. The file scan settings apply unchanged alongside the MCP scan.

Dependency risk check

The dependency risk check fires when an agent adds a dependency with a known vulnerability. It looks up each new package in Endor Labs vulnerability data and matches advisories at or above a severity you set. The default severity is high. The check runs at two points:
  • Install commands: The check parses the packages out of the command, the same way as the malware check.
  • Manifest and lockfile edits: The check compares the file before and after the edit and checks only the dependencies the edit adds. See Supported manifests and lockfiles to review the files it reads.
The check covers npm, PyPI, Go, and Maven packages. It skips installs in other ecosystems, such as Cargo or RubyGems, and reports no violation for them. For an unpinned install or a version range, the check judges the highest stable version that satisfies the range, and the message says so. It can’t resolve a tag such as beta, so it lists that package as not checked. In Maven, it can’t check an entry without an exact version, such as a range, a ${property} reference, a -SNAPSHOT version, or a dynamic Gradle version such as 1.+. Pin an exact version to have it checked.

Transitive dependencies

By default, include_transitives is off, and the check looks up only the dependencies an install command or manifest edit names. With it on, the check also looks up the packages each new dependency pulls in, using the dependency data Endor Labs stores for that package. The check follows the dependency graph and leaves out packages that only the dependency’s development dependencies pull in, such as test runners and linters. This also applies to go.mod edits. Other lockfiles already list every resolved package, so the check looks up every entry the edit adds, even when include_transitives is off.

What a dependency risk violation shows

When the check matches, the agent and developer see the vulnerable package, the advisory, its severity, and the fixed version when one exists. A transitive match names the direct dependency that brings it in and suggests a newer version of it. When no fixed version exists, the message suggests removing or replacing the package. A block also tells the agent not to install the vulnerable version another way, such as with --force. If the check could not cover every package, the first match lists the packages it did not check and the dependencies whose transitive packages it could not fully check.

Create a dependency risk policy

Create and edit dependency risk policies through the REST API. The policy form does not author them yet. The policy takes the following fields on its dependency_risk activity:
  • ecosystems: Optional list of ecosystems to check. The supported values are npm, pypi, go, and mvn, and maven and gradle also work for Maven. An empty list checks every supported ecosystem.
  • min_cvss_severity: The lowest advisory severity that matches. Choose SEVERITY_LOW, SEVERITY_MEDIUM, SEVERITY_HIGH, or SEVERITY_CRITICAL. Unset means SEVERITY_HIGH.
  • include_transitives: Set to true to also check the packages each new dependency pulls in, except its development dependencies. Unset means false.
  • include_file_patterns and exclude_file_patterns: Optional regex lists that limit which manifests and lockfiles the check reads. Exclusions apply after inclusions.
Endor Labs does not validate ecosystems values, so a misspelled or uppercase value such as python or NPM matches nothing. Use the lowercase values above. The following example creates a policy that asks before an agent adds an npm or PyPI dependency with a critical vulnerability.
Ask Permission behavior varies by agent. Cursor, for example, denies a file write that an Ask policy matches. See Enforcement behavior to review how each agent handles it. The out-of-the-box policy Dependencies: block adding known-vulnerable packages checks high and critical advisories, including transitive dependencies, and blocks on a match. It is disabled by default. Enable it, or create your own dependency risk policy, to turn the check on.

Prompt injection check

The prompt injection check looks for text that tries to take over the agent, such as a README that tells the agent to ignore its instructions. It scans the prompt a developer submits and the output of the agent’s tools. The check runs fixed rules. A policy can also run a classifier. Both run on the developer’s machine and make no network call.

Sources

A prompt injection policy names the sources it scans:
  • User prompt: The prompt the developer submits.
  • MCP tool result: The result of an MCP tool call, including the error text of a failed call.
  • Web content: A fetched web page or web search results.
  • File read: A file the agent is about to read. The check scans it before the read.
  • Shell output: The output of a shell command, including the error text of a failed command.
The check scans a tool result after the call, when the output has already reached the agent. A match on MCP tool result, Web content, or Shell output is always recorded as an alert, whatever action the policy sets. A File read match follows the policy action, so Block stops the read. The agent then gets a message from the policy. The message tells the agent to continue without the file or to stop and tell the developer. The following table shows what each agent supports for each source. Claude Code and Snowflake Cortex Code scan web content from the WebFetch and WebSearch tools.

Techniques

Each rule detects one technique. A policy acts on every technique unless you narrow it with include and exclude lists:
  • Instruction override: Text that tells the agent to drop its earlier instructions.
  • Fake system marker: Text dressed up as a system or developer message.
  • Role play: Text that gives the agent a new persona with no rules.
  • Encoded text: An instruction hidden in an encoding. For example, base64, hex, URL escapes, HTML entities, look-alike letters, or letters split apart by spaces or symbols. The check also decodes an encoding inside another encoding.
  • Hidden text: An instruction in invisible characters or an HTML comment.
  • Exfiltration request: Text that asks the agent to send data somewhere.
  • Counterfeit policy: Fake policy text that tells a checker the content is safe.

Confidence

Each rule has a confidence level for each source:
  • High: The rule stays under 1% false positives on benign test text for that source.
  • Low: The rule can also match ordinary text, so it reports more false positives.
A policy acts on findings at or above its Lowest Confidence. The default is High. No rule is high confidence yet for MCP tool result, Web content, File read, or Shell output. A policy that scans those sources at High finds nothing there, so set Lowest Confidence to Low for them. Source code and logs often hold text that reads like an instruction, so expect false positives and start with an alert policy.

Classifier

The classifier scores text that no rule matched. It works on every source. A score at or above the cutoff creates one match with no technique. A classifier match never blocks. The check records it as an alert. Lowest Confidence and the technique lists apply to rule matches only. The policy form doesn’t offer the classifier yet. Turn it on through the REST API with the detectors field.

What a prompt injection violation shows

A match shows the Technique ID, such as role-play, the Confidence, and a Message that names the source and the number of places the technique appears. For example, a match reads Prompt-injection technique "instruction-override" found in a file read (2 places, low confidence). Endor Labs doesn’t store the scanned text, so the violation never shows it. A classifier match shows no technique or confidence. Its Message names the source and the classifier score. For example, Text that looks like a prompt injection found in the user prompt (classifier score 0.93). The check reads up to 256 KB of text in each scan. It reads a file from disk when the hook carries only the path, within the lines the agent asks for. It decodes JSON tool output of up to 1 MB first, so it scans each key and value on its own line.

Create a prompt injection policy

Choose Prompt Injection under Secure Coding in the policy form, or create the policy through the REST API. The form doesn’t show List Type or offer Ask Permission for this template. When you select a tool-output source with Lowest Confidence set to High, the form warns that the policy finds nothing there. Through the REST API, the policy takes the following fields on its prompt_injection_check activity:
  • sources: The sources to scan. Choose one or more of TEXT_SOURCE_USER_PROMPT, TEXT_SOURCE_MCP_TOOL_RESULT, TEXT_SOURCE_WEB_CONTENT, TEXT_SOURCE_FILE_READ, and TEXT_SOURCE_SHELL_OUTPUT. A policy needs at least one source.
  • include_technique_ids: Optional list that limits the policy to specific techniques. The IDs are instruction-override, fake-system-marker, role-play, encoded-text, hidden-text, exfiltration-request, and counterfeit-policy. An empty list acts on every technique.
  • exclude_technique_ids: Optional list of techniques to ignore, even when included.
  • min_confidence: The lowest confidence that matches, FINDING_CONFIDENCE_HIGH or FINDING_CONFIDENCE_LOW. Unset means FINDING_CONFIDENCE_HIGH. It applies to rule matches only.
  • detectors: Optional list of the detectors to run. The values are DETECTOR_RULES and DETECTOR_CLASSIFIER. An empty list runs the rules only. The classifier scores only text that no rule matched. A list with DETECTOR_CLASSIFIER must also include DETECTOR_RULES.
The following example creates a policy that blocks a file read with instruction text that looks like an override.
The out-of-the-box policy Prompt injection: alert on injection text in a submitted prompt scans the user prompt with the high-confidence rules and the classifier. It records an alert on a match and is disabled by default. Enable it, or create your own prompt injection policy, to turn the check on.

Supported manifests and lockfiles

The malware and dependency risk checks read the following files when the agent writes or edits them. The checks skip build.gradle, because it is code rather than a manifest.

Actions

Secure coding checks use the same actions as every other Coding Agent Governance policy: Block stops the action, Alert records it, and Ask Permission pauses for the developer. The prompt injection check doesn’t offer Ask Permission, because a scan of text leaves no pending action to approve. Violations appear under Policy Violations next to the rest of your governance activity. See Actions to review what the developer and your security team see for each action.

How the checks fit with other Endor Labs protection

Endor Labs catches malicious packages and secrets at more than one layer, and each layer covers a different point in the workflow:
  • Secure coding checks act in the agent loop, at the moment an agent installs a package, edits a manifest, or touches a secret.
  • Package Firewall protects the registry path for every install in your organization, whether an agent or a person runs it.
  • Secrets scanning finds secrets already committed to your repositories and pull requests.
The layers share the same intelligence, so a package blocked in the agent loop is the same one Package Firewall blocks at the registry.

Limitations

Be aware of the following limitations:
  • Checks run for supported agents on machines with hooks deployed.
  • The malware and dependency risk checks never block an action they can’t complete. If a lookup fails or times out, or a file can’t be read or is larger than 10 MB, the action proceeds. When only the version lookup fails, the malware check still runs and judges the package by name.
  • For an unpinned install or a range, the malware check resolves stable versions only. It reads the npm latest tag as the highest stable version and ignores the npm --tag flag, so it can judge a different version than npm installs.
  • In Claude Code, the manifest and lockfile checks cover the Write and Edit tools, not MultiEdit.
  • The dependency risk check ignores advisories without a CVSS score, disputed or withdrawn advisories, and malware advisories, which the malware check covers.
  • The secrets check inspects content the agent touches in a session. It is not a repository-wide scan. Use secrets scanning for full-repository coverage.
  • The prompt injection check can’t stop text that already reached the agent. It records matches in MCP tool results, web content, and shell output, but it can block only a file read or a user prompt.
  • The hosted web search in Codex runs without a hook, so the prompt injection check doesn’t scan its results.
  • The prompt injection check reads at most 256 KB of each text. It can miss a match past that point, so a clean result for a longer text is not proof that the text is clean.
  • Like all Coding Agent Governance controls, these checks are guardrails for agent behavior, not a security boundary. See What Coding Agent Governance is (and isn’t) to review what these guardrails can’t stop.