Back to skill

Security audit

Claude Api Cn

Security checks for vulnerabilities and agentic risk

Overview

This Claude API documentation skill is mostly coherent, but it includes copy-ready examples that can run unpinned third-party MCP code, pass database credentials, and bypass agent approval prompts for shell and file writes.

Review this skill before installing if you plan to copy its Agent SDK examples. Keep default approval prompts on, avoid bypassPermissions except in disposable sandboxes, pin MCP package versions, avoid npx @latest for trusted workflows, and use least-privileged test credentials instead of production DATABASE_URL values. Treat API, file-upload, image, memory, and conversation-history examples as transmitting or retaining data unless you have explicitly configured otherwise.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T08 · Insecure Dependencies

Error
Location
python/agent-sdk/patterns.md:162
Finding

Unpinned MCP packages are downloaded and executed through npx

Content
View full analysis
Remediation
View remediation
"] } ``` ```python "postgres": { "command": "npx", "args": ["--no-install", "@modelcontextprotocol/server-postgres@"], "env": {"DATABASE_URL": restricted_database_url} } ``` 2. Install MCP dependencies separately through a lockfile-controlled package manifest. Review the resolved dependency tree before execution. 3. Use `npx --no-install` after installation so agent startup cannot silently fetch new code. 4. Commit and enforce lockfiles, and use npm integrity metadata or an internal artifact registry to ensure reviewed artifacts are executed. 5. Remove `@latest`, unversioned package identifiers, and `-y` from copy-ready security-sensitive examples. 6. Run external MCP servers in an isolated container or sandbox with: - A read-only filesystem where possible. - A narrowly scoped working directory. - Restricted outbound network access. - No unrelated environment variables. - Resource and process limits. 7. Create a dedicated, least-privileged database account for the PostgreSQL MCP server. Prefer read-only access restricted to necessary schemas and tables. 8. Avoid forwarding the application's primary `DATABASE_URL`. Supply a dedicated credential through an isolated secret mechanism and rotate it if package compromise is suspected. 9. Document that MCP servers are locally executed third-party programs and require the same dependency review as any other executable component. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
python/agent-sdk/patterns.md:212
Finding

Agent example bypasses all approval prompts while granting shell and file-write tools

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Memory PoisoningPersistent Context Injection, Context Window Stuffing, Memory Manipulation
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (39)

Context Leakage

High
Category
Data Exfiltration
Confidence
75% confidence
Finding

Code or instructions that leak agent conversation context to external services, potentially exposing sensitive user interactions.

Content

Scanner excerpt · shared/live-sources.md (reported line 63)May include surrounding context.

md
| Structured Outputs | `https://platform.claude.com/docs/en/build-with-claude/structured-outputs.md` | "Extract output_config.format usage and schema enforcement"                           |
| Compaction         | `https://platform.claude.com/docs/en/build-with-claude/compaction.md`         | "Extract compaction setup, trigger config, and streaming with compaction"             |
| Citations          | `https://platform.claude.com/docs/en/build-with-claude/citations.md`          | "Extract citation format and implementation"        |
| Context Windows    | `https://platform.claude.com/docs/en/build-with-claude/context-windows.md`    | "Extract context window sizes and token management" |

---

Context Leakage

High
Category
Data Exfiltration
Confidence
85% confidence
Finding

Code or instructions that leak agent conversation context to external services, potentially exposing sensitive user interactions.

Content

Scanner excerpt · python/claude-api/README.md (reported line 217)May include surrounding context.

Multi-Turn Conversations

The API is stateless — send the full conversation history each time. Use Anthropic.MessageParam[] to type the messages array:

typescript
const messages: Anthropic.MessageParam[] = [

Context Leakage

High
Category
Data Exfiltration
Confidence
85% confidence
Finding

Code or instructions that leak agent conversation context to external services, potentially exposing sensitive user interactions.

Content

Scanner excerpt · typescript/claude-api/README.md (reported line 213)May include surrounding context.

Multi-Turn Conversations

The API is stateless — send the full conversation history each time. Use Anthropic.MessageParam[] to type the messages array:

typescript
const messages: Anthropic.MessageParam[] = [

Context Window Stuffing

Medium
Category
Memory Poisoning
Confidence
80% confidence
Finding

Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.

Content

Scanner excerpt · SKILL.md (reported line 185)May include surrounding context.

md
**Chat UI or real-time response display:**
→ Read `{lang}/claude-api/README.md` + `{lang}/claude-api/streaming.md`

**Long-running conversations (may exceed context window):**
→ Read `{lang}/claude-api/README.md` — see Compaction section

**Function calling / tool use / agents:**

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The manifest frames this skill as guidance for using the Claude API or Anthropic SDK. In addition to normal API usage, this file explicitly teaches enabling built-in server tools for web search, bash, text editing, code execution, and memory, which are materially broader capabilities than basic SDK/API integration.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · curl/examples.md (reported line 1)May include surrounding context.

md
# Claude API — cURL / Raw HTTP

Use these examples when the user needs raw HTTP requests or is working in a language without an official SDK.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · curl/examples.md (reported line 16)May include surrounding context.

Basic Message Request

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · curl/examples.md (reported line 37)May include surrounding context.

Basic Message Request

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · curl/examples.md (reported line 63)May include surrounding context.

Basic Message Request

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · curl/examples.md (reported line 102)May include surrounding context.

Basic Message Request

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · curl/examples.md (reported line 127)May include surrounding context.

Basic Message Request

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · curl/examples.md (reported line 167)May include surrounding context.

Basic Message Request

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · shared/models.md (reported line 35)May include surrounding context.

Basic Message Request

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · curl/examples.md (reported line 63)May include surrounding context.

Streaming (SSE)

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

This markdown file documents the Files API upload flow and explicitly lists Delete as an available method, both of which can affect user data and system integrity. Under the markdown-specific SQP-2 criteria, the description should warn that files may be transmitted to a remote service and that deletion operations are available and potentially irreversible.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The memory-tool example explicitly suggests a filesystem-backed handler and stores user-provided facts such as preferences without any warning about persistence, retention, or access controls. In agent integrations, this can lead developers to persist sensitive or personal data by default, creating privacy, compliance, and unintended data-retention risks.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest frames this skill as helping build apps with the Claude API or Anthropic SDK, but this section teaches use of server-side Bash tools and beta MCP server integration. Exposing command execution and remote MCP connectivity goes beyond basic API/SDK usage and introduces materially broader capabilities not justified by the narrow skill description.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
75% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · php/claude-api.md (reported line 67)May include surrounding context.

md
);

// content is an array of polymorphic blocks (TextBlock, ToolUseBlock,
// ThinkingBlock). Accessing ->text on content[0] without checking the block
// type will throw if the first block is not a TextBlock (e.g., when extended
// thinking is enabled and a ThinkingBlock comes first). Always guard:
foreach ($message->content as $block) {

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The documentation explicitly advertises server-side tools including bash and code_execution but does not include any warning that these capabilities can run commands or code with real system effects. In an API/SDK integration guide, that omission can lead developers to enable dangerous tooling without sandboxing, approval gates, or scope restrictions, increasing the risk of command execution, data access, or host compromise in downstream applications.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The README explicitly demonstrates permission_mode="acceptEdits", which removes interactive approval for file modifications. In an agent SDK context, this can normalize unsafe defaults and lead developers to deploy agents that autonomously alter source code or configuration without adequate review, increasing the chance of destructive or security-relevant changes from prompt injection, model error, or misuse.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown example demonstrates connecting an MCP PostgreSQL server using DATABASE_URL from the environment, which involves sensitive credentials and potential access to real database contents. The surrounding description does not include any warning about credential exposure, production-data access, or the need to use a non-production database.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

This is a markdown file, so SQP-2 applies to omissions in the skill description. The examples send message content and image data to a remote API, but the README does not warn users that prompts, conversation history, and uploaded images may leave the local environment and affect privacy or sensitive data handling.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

The skill description demonstrates uploading local files such as reports and contracts to a remote API, which transmits user data off the local system. The markdown explains mechanics and limits, but it does not warn users to avoid uploading sensitive or confidential content unless appropriate for their environment and policy.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · go/claude-api.md (reported line 131)May include surrounding context.

md
# Your implementation here
    return f"72°F and sunny in {location}"

# The tool runner handles the agentic loop automatically
runner = client.beta.messages.tool_runner(
    model="claude-opus-4-6",
    max_tokens=16000,

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · python/claude-api/tool-use.md (reported line 28)May include surrounding context.

md
# Your implementation here
    return f"72°F and sunny in {location}"

# The tool runner handles the agentic loop automatically
runner = client.beta.messages.tool_runner(
    model="claude-opus-4-6",
    max_tokens=16000,

Static analysis

Detected: suspicious.exposed_secret_literal, suspicious.prompt_injection_instructions

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
csharp/claude-api.md:21

Prompt-injection style instruction pattern detected.

Warn
Code
suspicious.prompt_injection_instructions
Location
typescript/agent-sdk/patterns.md:199