praxis-sec 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +170 -0
- package/ai-defense/cost-protection.md +292 -0
- package/ai-defense/llm-security-checklist.md +324 -0
- package/ai-defense/prompt-injection-patterns.js +283 -0
- package/ai-defense/system-prompt-armor.md +327 -0
- package/checklists/launch-day.md +168 -0
- package/cli/agents/abom-generator.js +225 -0
- package/cli/agents/agent-attestation-agent.js +318 -0
- package/cli/agents/agent-config-scanner.js +787 -0
- package/cli/agents/agent-telemetry-agent.js +415 -0
- package/cli/agents/agentic-security-agent.js +296 -0
- package/cli/agents/agentic-supply-chain-agent.js +463 -0
- package/cli/agents/ai-infra-inventory-agent.js +449 -0
- package/cli/agents/api-fuzzer.js +345 -0
- package/cli/agents/auth-bypass-agent.js +348 -0
- package/cli/agents/base-agent.js +280 -0
- package/cli/agents/cicd-scanner.js +300 -0
- package/cli/agents/config-auditor.js +757 -0
- package/cli/agents/deep-analyzer.js +776 -0
- package/cli/agents/endpoint-agent-abuse-agent.js +404 -0
- package/cli/agents/exception-handler-agent.js +187 -0
- package/cli/agents/git-history-scanner.js +169 -0
- package/cli/agents/governance-audits.js +138 -0
- package/cli/agents/hermes-security-agent.js +536 -0
- package/cli/agents/html-reporter.js +1125 -0
- package/cli/agents/index.js +147 -0
- package/cli/agents/injection-tester.js +502 -0
- package/cli/agents/legal-risk-agent.js +328 -0
- package/cli/agents/llm-redteam.js +199 -0
- package/cli/agents/managed-agent-scanner.js +333 -0
- package/cli/agents/mcp-security-agent.js +588 -0
- package/cli/agents/memory-poisoning-agent.js +305 -0
- package/cli/agents/mobile-scanner.js +231 -0
- package/cli/agents/model-file-scanner.js +259 -0
- package/cli/agents/orchestrator.js +355 -0
- package/cli/agents/pii-compliance-agent.js +301 -0
- package/cli/agents/policy-engine.js +229 -0
- package/cli/agents/prompt-injection-prober.js +224 -0
- package/cli/agents/rag-security-agent.js +204 -0
- package/cli/agents/recon-agent.js +207 -0
- package/cli/agents/sbom-generator.js +265 -0
- package/cli/agents/scoring-engine.js +273 -0
- package/cli/agents/ssrf-prober.js +130 -0
- package/cli/agents/stateful-watcher.js +238 -0
- package/cli/agents/supabase-rls-agent.js +154 -0
- package/cli/agents/supply-chain-agent.js +857 -0
- package/cli/agents/swarm-orchestrator.js +200 -0
- package/cli/agents/verifier-agent.js +303 -0
- package/cli/agents/vibe-coding-agent.js +250 -0
- package/cli/bin/praxis.js +866 -0
- package/cli/commands/abom.js +73 -0
- package/cli/commands/agent-fix.js +1245 -0
- package/cli/commands/audit.js +1180 -0
- package/cli/commands/autofix.js +383 -0
- package/cli/commands/baseline.js +193 -0
- package/cli/commands/benchmark.js +327 -0
- package/cli/commands/checklist.js +223 -0
- package/cli/commands/ci.js +403 -0
- package/cli/commands/deps.js +516 -0
- package/cli/commands/diff.js +200 -0
- package/cli/commands/doctor.js +195 -0
- package/cli/commands/env-audit.js +349 -0
- package/cli/commands/fix.js +218 -0
- package/cli/commands/guard.js +396 -0
- package/cli/commands/hooks.js +278 -0
- package/cli/commands/init.js +514 -0
- package/cli/commands/legal.js +158 -0
- package/cli/commands/live-advisories.js +241 -0
- package/cli/commands/mcp.js +660 -0
- package/cli/commands/openclaw.js +386 -0
- package/cli/commands/red-team.js +350 -0
- package/cli/commands/redteam.js +78 -0
- package/cli/commands/remediate.js +797 -0
- package/cli/commands/rotate.js +768 -0
- package/cli/commands/rules.js +196 -0
- package/cli/commands/scan-mcp.js +534 -0
- package/cli/commands/scan-skill.js +588 -0
- package/cli/commands/scan-standard.js +251 -0
- package/cli/commands/scan.js +524 -0
- package/cli/commands/score.js +449 -0
- package/cli/commands/shell.js +514 -0
- package/cli/commands/team-report.js +398 -0
- package/cli/commands/undo.js +161 -0
- package/cli/commands/update-intel.js +126 -0
- package/cli/commands/vibe-check.js +276 -0
- package/cli/commands/watch.js +757 -0
- package/cli/commands/web.js +63 -0
- package/cli/core/ast/guardrail-detector.js +141 -0
- package/cli/core/ast/index.js +22 -0
- package/cli/core/ast/parser.js +676 -0
- package/cli/core/ast/scope-tree.js +287 -0
- package/cli/core/ast/taint-tracker.js +158 -0
- package/cli/core/branding.js +37 -0
- package/cli/core/env.js +38 -0
- package/cli/core/errors.js +61 -0
- package/cli/core/fs.js +62 -0
- package/cli/core/output/compliance.js +90 -0
- package/cli/core/output/html-theme.js +158 -0
- package/cli/core/output/index.js +57 -0
- package/cli/core/output/json.js +48 -0
- package/cli/core/output/sarif.js +240 -0
- package/cli/core/version.js +67 -0
- package/cli/core/web/jobs.js +183 -0
- package/cli/core/web/projects.js +146 -0
- package/cli/core/web/server.js +439 -0
- package/cli/data/atlas-knowledge.json +5640 -0
- package/cli/data/eaa-catalog.json +39 -0
- package/cli/data/known-mcps.json +26 -0
- package/cli/data/probes/prompt-injection-corpus.json +271 -0
- package/cli/data/threat-intel.json +85 -0
- package/cli/data/threatpacks/latest.json +41 -0
- package/cli/hooks/patterns.js +313 -0
- package/cli/hooks/post-tool-use.js +140 -0
- package/cli/hooks/pre-tool-use.js +186 -0
- package/cli/index.js +90 -0
- package/cli/providers/llm-provider.js +766 -0
- package/cli/utils/autofix-rules.js +74 -0
- package/cli/utils/cache-manager.js +310 -0
- package/cli/utils/compliance-map.js +191 -0
- package/cli/utils/entropy.js +132 -0
- package/cli/utils/fix-ledger.js +127 -0
- package/cli/utils/hermes-tool-registry.js +252 -0
- package/cli/utils/intel/cache.js +61 -0
- package/cli/utils/intel/http.js +88 -0
- package/cli/utils/intel/index.js +235 -0
- package/cli/utils/intel/merge.js +229 -0
- package/cli/utils/intel/sources/epss.js +54 -0
- package/cli/utils/intel/sources/ghsa.js +81 -0
- package/cli/utils/intel/sources/gitguardian.js +40 -0
- package/cli/utils/intel/sources/gitleaks.js +101 -0
- package/cli/utils/intel/sources/kev.js +38 -0
- package/cli/utils/intel/sources/nvd.js +84 -0
- package/cli/utils/intel/sources/osv.js +132 -0
- package/cli/utils/intel/sources/phylum.js +44 -0
- package/cli/utils/intel/sources/snyk.js +46 -0
- package/cli/utils/intel/sources/socket.js +69 -0
- package/cli/utils/intel/sources/sonatype.js +84 -0
- package/cli/utils/intel/sources/threatpack.js +69 -0
- package/cli/utils/mcp-trust.js +60 -0
- package/cli/utils/output.js +251 -0
- package/cli/utils/patterns.js +1130 -0
- package/cli/utils/pdf-generator.js +94 -0
- package/cli/utils/plugin-loader.js +364 -0
- package/cli/utils/rule-import.js +228 -0
- package/cli/utils/rule-registry.js +426 -0
- package/cli/utils/scan-fingerprint.js +109 -0
- package/cli/utils/scan-playbook.js +312 -0
- package/cli/utils/score-history.js +119 -0
- package/cli/utils/secrets-verifier.js +247 -0
- package/cli/utils/security-memory.js +296 -0
- package/cli/utils/standards/atlas-knowledge.js +87 -0
- package/cli/utils/standards/index.js +127 -0
- package/cli/utils/standards/sources/avid.js +45 -0
- package/cli/utils/standards/sources/eu-ai-act.js +89 -0
- package/cli/utils/standards/sources/google-saif.js +39 -0
- package/cli/utils/standards/sources/iso-42001.js +94 -0
- package/cli/utils/standards/sources/mitre-atlas.js +54 -0
- package/cli/utils/standards/sources/nist-ai-600-1.js +45 -0
- package/cli/utils/standards/sources/owasp-llm.js +45 -0
- package/cli/utils/standards/sources/owasp-ml.js +45 -0
- package/cli/utils/threat-intel.js +265 -0
- package/configs/firebase/firestore-rules.txt +215 -0
- package/configs/firebase/security-checklist.md +236 -0
- package/configs/firebase/storage-rules.txt +206 -0
- package/configs/gitignore-template +258 -0
- package/configs/nextjs-security-headers.js +220 -0
- package/configs/praxisignore-template +50 -0
- package/configs/supabase/secure-client.ts +225 -0
- package/configs/supabase/security-checklist.md +278 -0
- package/docs/THIRD_PARTY_NOTICES.md +26 -0
- package/docs/THREAT_INTEL.md +292 -0
- package/docs/USAGE.md +1205 -0
- package/docs/design/WEB-UI.md +82 -0
- package/package.json +71 -0
- package/scripts/check-determinism.mjs +119 -0
- package/snippets/README.md +122 -0
- package/snippets/api-security/api-security-checklist.md +412 -0
- package/snippets/api-security/cors-config.ts +322 -0
- package/snippets/api-security/input-validation.ts +430 -0
- package/snippets/auth/jwt-checklist.md +322 -0
- package/snippets/rate-limiting/nextjs-middleware.ts +211 -0
- package/snippets/rate-limiting/upstash-ratelimit.ts +229 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentic Security Agent
|
|
3
|
+
* ========================
|
|
4
|
+
*
|
|
5
|
+
* Detects security vulnerabilities in AI agent implementations.
|
|
6
|
+
* Covers the OWASP Top 10 for Agentic Applications (2026):
|
|
7
|
+
* ASI01 — Agent Goal Hijacking
|
|
8
|
+
* ASI02 — Tool Misuse
|
|
9
|
+
* ASI03 — Identity & Privilege Abuse
|
|
10
|
+
* ASI04 — Memory Poisoning
|
|
11
|
+
* ASI05 — Cascading Hallucination
|
|
12
|
+
* ASI06 — Supply Chain Vulnerabilities
|
|
13
|
+
*
|
|
14
|
+
* 48% of cybersecurity professionals identify agentic AI as
|
|
15
|
+
* the top attack vector for 2026.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import path from 'path';
|
|
19
|
+
import { BaseAgent } from './base-agent.js';
|
|
20
|
+
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// AGENTIC SECURITY PATTERNS
|
|
23
|
+
// =============================================================================
|
|
24
|
+
|
|
25
|
+
export const PATTERNS = [
|
|
26
|
+
// ── Goal Hijacking (ASI01) ───────────────────────────────────────────────
|
|
27
|
+
{
|
|
28
|
+
rule: 'AGENT_USER_INPUT_IN_SYSTEM_PROMPT',
|
|
29
|
+
title: 'Agent: User Input in System Prompt / Goal',
|
|
30
|
+
regex: /(?:system|instructions|goal|objective|persona)\s*[:=]\s*(?:`[^`]*\$\{|.*\+\s*(?:req\.|request\.|user|input|message|query|body))/g,
|
|
31
|
+
severity: 'critical',
|
|
32
|
+
cwe: 'CWE-74',
|
|
33
|
+
owasp: 'A03:2021',
|
|
34
|
+
description: 'User input concatenated into agent system prompt or goal definition. Enables agent goal hijacking — the attacker can rewrite the agent\'s objectives.',
|
|
35
|
+
fix: 'Separate system instructions from user input. Use structured message roles (system vs user). Never interpolate user input into system prompts.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
rule: 'AGENT_NO_GOAL_BOUNDARY',
|
|
39
|
+
title: 'Agent: Missing Goal Boundary Enforcement',
|
|
40
|
+
regex: /(?:agent|assistant|bot)[\s\S]{0,200}(?:system|instructions)\s*[:=]\s*(?:req\.|request\.|input|body|query|params)/g,
|
|
41
|
+
severity: 'critical',
|
|
42
|
+
cwe: 'CWE-284',
|
|
43
|
+
owasp: 'A01:2021',
|
|
44
|
+
description: 'Agent goal or system instructions set directly from external input without boundary enforcement.',
|
|
45
|
+
fix: 'Hardcode agent goals. If customization is needed, validate against an allowlist of approved goal templates.',
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// ── Tool Misuse (ASI02) ──────────────────────────────────────────────────
|
|
49
|
+
{
|
|
50
|
+
rule: 'AGENT_UNRESTRICTED_TOOLS',
|
|
51
|
+
title: 'Agent: Unrestricted Tool Access',
|
|
52
|
+
regex: /(?:tools|actions|capabilities|functions)\s*[:=]\s*(?:\[\s*\.{3}|"all"|'all'|"\*"|'\*'|Object\.keys|getAll|listAll)/g,
|
|
53
|
+
severity: 'critical',
|
|
54
|
+
cwe: 'CWE-269',
|
|
55
|
+
owasp: 'A01:2021',
|
|
56
|
+
description: 'Agent given wildcard or unbounded tool access. Prompt injection can trigger any available tool.',
|
|
57
|
+
fix: 'Restrict agent tools to minimum required set. Use explicit allowlists, not wildcard access.',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
rule: 'AGENT_TOOL_NO_CONFIRMATION',
|
|
61
|
+
title: 'Agent: Destructive Tools Without Human Confirmation',
|
|
62
|
+
regex: /(?:auto_approve|auto_execute|requireConfirmation\s*[:=]\s*false|confirm\s*[:=]\s*false|human_in_loop\s*[:=]\s*false|humanInTheLoop\s*[:=]\s*false|approval\s*[:=]\s*false)/gi,
|
|
63
|
+
severity: 'high',
|
|
64
|
+
cwe: 'CWE-862',
|
|
65
|
+
owasp: 'A01:2021',
|
|
66
|
+
description: 'Agent configured to auto-execute tools without human confirmation. Prompt injection can trigger destructive actions.',
|
|
67
|
+
fix: 'Require human-in-the-loop confirmation for destructive operations (write, delete, send, pay).',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
rule: 'AGENT_TOOL_SHELL_ACCESS',
|
|
71
|
+
title: 'Agent: Tool With Shell/Command Execution',
|
|
72
|
+
regex: /(?:tools|functions)[\s\S]{0,500}(?:exec\s*\(|execSync|spawn|child_process|subprocess|os\.system|shell\s*[:=]\s*true)/g, // praxis-ignore AGENT_TOOL_SHELL_ACCESS — detector definition
|
|
73
|
+
severity: 'critical',
|
|
74
|
+
cwe: 'CWE-78',
|
|
75
|
+
owasp: 'A03:2021',
|
|
76
|
+
description: 'Agent has access to a tool that executes shell commands. Prompt injection achieves RCE.',
|
|
77
|
+
fix: 'Remove shell execution tools from agent capabilities. If needed, use strict command allowlists.',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
rule: 'AGENT_UNVALIDATED_TOOL_OUTPUT',
|
|
81
|
+
title: 'Agent: Tool Output Used Without Validation',
|
|
82
|
+
regex: /(?:tool_result|toolResult|function_result|tool_output)[\s\S]{0,200}(?:eval\s*\(|exec\s*\(|innerHTML|dangerouslySetInnerHTML|\.query\s*\(|\.execute\s*\()/g, // praxis-ignore AGENT_UNVALIDATED_TOOL_OUTPUT — detector definition
|
|
83
|
+
severity: 'critical',
|
|
84
|
+
cwe: 'CWE-94',
|
|
85
|
+
owasp: 'A03:2021',
|
|
86
|
+
description: 'Tool output passed directly to dangerous sinks (eval, SQL, HTML). Poisoned tool results can achieve code execution.',
|
|
87
|
+
fix: 'Validate and sanitize all tool outputs before using them in code execution, SQL queries, or HTML rendering.',
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// ── Identity & Privilege Abuse (ASI03) ───────────────────────────────────
|
|
91
|
+
{
|
|
92
|
+
rule: 'AGENT_ESCALATED_PERMISSIONS',
|
|
93
|
+
title: 'Agent: Runs With Elevated Permissions',
|
|
94
|
+
regex: /(?:agent|bot|assistant)[\s\S]{0,300}(?:admin|sudo|root|superuser|service.?role|elevated|full.?access|all.?permissions)/gi,
|
|
95
|
+
severity: 'high',
|
|
96
|
+
cwe: 'CWE-269',
|
|
97
|
+
owasp: 'A04:2021',
|
|
98
|
+
confidence: 'medium',
|
|
99
|
+
description: 'Agent configured with elevated permissions (admin, root, service-role). Prompt injection inherits these privileges.',
|
|
100
|
+
fix: 'Apply principle of least privilege. Agents should have minimal permissions required for their specific task.',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
rule: 'AGENT_CREDENTIAL_FORWARDING',
|
|
104
|
+
title: 'Agent: Credentials Passed Between Tools',
|
|
105
|
+
regex: /(?:tool|function|action)[\s\S]{0,300}(?:credential|password|secret|token|apiKey|api_key)[\s\S]{0,100}(?:forward|pass|send|share|propagate|next)/gi,
|
|
106
|
+
severity: 'high',
|
|
107
|
+
cwe: 'CWE-522',
|
|
108
|
+
owasp: 'A07:2021',
|
|
109
|
+
confidence: 'medium',
|
|
110
|
+
description: 'Agent forwards credentials between tools or to external services. Compromised tools can steal credentials.',
|
|
111
|
+
fix: 'Scope credentials per-tool. Never forward authentication tokens between tool invocations.',
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
// ── Memory Poisoning (ASI04) ─────────────────────────────────────────────
|
|
115
|
+
{
|
|
116
|
+
rule: 'AGENT_MEMORY_USER_WRITE',
|
|
117
|
+
title: 'Agent: User Input Written to Persistent Memory',
|
|
118
|
+
regex: /(?:memory|context|history|state|knowledge)[\s\S]{0,100}(?:\.append|\.push|\.add|\.set|\.save|\.store|\.write|\.update)\s*\(\s*(?:user|input|message|query|req\.|request\.)/g,
|
|
119
|
+
severity: 'high',
|
|
120
|
+
cwe: 'CWE-472',
|
|
121
|
+
owasp: 'A03:2021',
|
|
122
|
+
description: 'User-controlled content written directly to agent persistent memory. Enables memory poisoning — attacker instructions persist across sessions.',
|
|
123
|
+
fix: 'Sanitize and validate content before writing to agent memory. Separate user messages from system state.',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
rule: 'AGENT_MEMORY_NO_EXPIRY',
|
|
127
|
+
title: 'Agent: Persistent Memory Without Expiration',
|
|
128
|
+
regex: /(?:memory|longTermMemory|persistentState)[\s\S]{0,200}(?:save|store|persist|write)(?![\s\S]{0,200}(?:ttl|expir|maxAge|retention|cleanup|prune))/g,
|
|
129
|
+
severity: 'medium',
|
|
130
|
+
cwe: 'CWE-404',
|
|
131
|
+
owasp: 'A04:2021',
|
|
132
|
+
confidence: 'low',
|
|
133
|
+
description: 'Agent memory persists without expiration policy. Poisoned memories remain indefinitely.',
|
|
134
|
+
fix: 'Set TTL or retention policies on agent memory. Implement periodic cleanup of stale entries.',
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
// ── Unbounded Execution ──────────────────────────────────────────────────
|
|
138
|
+
{
|
|
139
|
+
rule: 'AGENT_NO_ITERATION_LIMIT',
|
|
140
|
+
title: 'Agent: Execution Loop Without Iteration Limit',
|
|
141
|
+
regex: /(?:while\s*\(\s*true|for\s*\(\s*;\s*;\s*\)|loop\s*\{)[\s\S]{0,500}(?:agent|llm|completion|chat|generate|invoke)/g,
|
|
142
|
+
severity: 'high',
|
|
143
|
+
cwe: 'CWE-835',
|
|
144
|
+
owasp: 'A04:2021',
|
|
145
|
+
description: 'Agent runs in an unbounded loop without iteration limits. Enables denial of wallet and runaway costs.',
|
|
146
|
+
fix: 'Set maxIterations or maxSteps limit on agent execution loops. Add timeout enforcement.',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
rule: 'AGENT_NO_TIMEOUT',
|
|
150
|
+
title: 'Agent: No Timeout on Execution',
|
|
151
|
+
regex: /(?:agent|AgentExecutor|runAgent|createAgent)\s*\(\s*\{(?:(?!timeout|maxTime|deadline|abort|signal).)*\}\s*\)/gs,
|
|
152
|
+
severity: 'medium',
|
|
153
|
+
cwe: 'CWE-400',
|
|
154
|
+
owasp: 'A04:2021',
|
|
155
|
+
confidence: 'low',
|
|
156
|
+
description: 'Agent execution without timeout configuration. Runaway agents can consume unlimited resources.',
|
|
157
|
+
fix: 'Set explicit timeout on agent execution. Use AbortController or equivalent mechanism.',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
rule: 'AGENT_NO_COST_LIMIT',
|
|
161
|
+
title: 'Agent: No Spending/Token Limit',
|
|
162
|
+
regex: /(?:agent|completion|chat)[\s\S]{0,300}(?:model|engine)\s*[:=](?![\s\S]{0,300}(?:max_tokens|maxTokens|budget|cost|limit|cap))/g,
|
|
163
|
+
severity: 'medium',
|
|
164
|
+
cwe: 'CWE-770',
|
|
165
|
+
owasp: 'A04:2021',
|
|
166
|
+
confidence: 'low',
|
|
167
|
+
description: 'Agent makes LLM calls without token or cost limits. Enables denial of wallet attacks.',
|
|
168
|
+
fix: 'Set max_tokens on all LLM calls. Implement per-session cost budgets.',
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// ── Multi-Agent Risks ────────────────────────────────────────────────────
|
|
172
|
+
{
|
|
173
|
+
rule: 'AGENT_RECURSIVE_INVOCATION',
|
|
174
|
+
title: 'Agent: Recursive Self-Invocation',
|
|
175
|
+
regex: /(?:agent|assistant)[\s\S]{0,200}(?:call|invoke|run|execute)[\s\S]{0,100}(?:self|this|agent|itself)/g,
|
|
176
|
+
severity: 'high',
|
|
177
|
+
cwe: 'CWE-674',
|
|
178
|
+
owasp: 'A04:2021',
|
|
179
|
+
confidence: 'medium',
|
|
180
|
+
description: 'Agent can recursively invoke itself or spawn sub-agents without depth limits. Enables infinite loops.',
|
|
181
|
+
fix: 'Set max recursion depth for agent self-invocation. Track and limit sub-agent spawn depth.',
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
rule: 'AGENT_CHAIN_NO_ISOLATION',
|
|
185
|
+
title: 'Agent: Multi-Agent Chain Without Privilege Isolation',
|
|
186
|
+
regex: /(?:pipe|chain|sequence|workflow)[\s\S]{0,300}(?:agent|step|task)[\s\S]{0,200}(?:agent|step|task)(?![\s\S]{0,200}(?:permission|scope|restrict|isolat))/g,
|
|
187
|
+
severity: 'medium',
|
|
188
|
+
cwe: 'CWE-269',
|
|
189
|
+
owasp: 'A04:2021',
|
|
190
|
+
confidence: 'low',
|
|
191
|
+
description: 'Multi-agent pipeline without privilege isolation between steps. A compromised agent can escalate through the chain.',
|
|
192
|
+
fix: 'Apply privilege isolation between agents in a chain. Each agent should have scoped permissions.',
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
// ── Output Safety ────────────────────────────────────────────────────────
|
|
196
|
+
{
|
|
197
|
+
rule: 'AGENT_OUTPUT_TO_ACTION',
|
|
198
|
+
title: 'Agent: LLM Output Directly Triggers Actions',
|
|
199
|
+
regex: /(?:completion|response|output|result|generated)[\s\S]{0,100}(?:\.execute\b|\.run\b|\.send\b|\.post\b|\.delete\b|\.pay\b|\.transfer\b|\.deploy\b)/g,
|
|
200
|
+
severity: 'high',
|
|
201
|
+
cwe: 'CWE-862',
|
|
202
|
+
owasp: 'A01:2021',
|
|
203
|
+
confidence: 'medium',
|
|
204
|
+
description: 'LLM output directly triggers side-effect actions without validation. Hallucinated or injected outputs can cause unintended actions.',
|
|
205
|
+
fix: 'Validate LLM output against expected schemas before executing side effects. Add human confirmation for irreversible actions.',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
rule: 'AGENT_NO_OUTPUT_SCHEMA',
|
|
209
|
+
title: 'Agent: No Schema Validation on LLM Output',
|
|
210
|
+
regex: /(?:JSON\.parse|json\.loads)\s*\(\s*(?:completion|response|output|result|generated|llm|ai|gpt|claude)(?![\s\S]{0,200}(?:schema|validate|zod|yup|joi|ajv|parse|safeParse|type_adapter))/g,
|
|
211
|
+
severity: 'medium',
|
|
212
|
+
cwe: 'CWE-20',
|
|
213
|
+
owasp: 'A03:2021',
|
|
214
|
+
description: 'LLM JSON output parsed without schema validation. Malformed or malicious output can cause unexpected behavior.',
|
|
215
|
+
fix: 'Validate LLM structured output against a schema (Zod, Joi, Pydantic) before processing.',
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
// ── Credential Isolation ─────────────────────────────────────────────────
|
|
219
|
+
{
|
|
220
|
+
rule: 'AGENT_ENV_FILE_ACCESS',
|
|
221
|
+
title: 'Agent: Reads .env Files Without Restriction',
|
|
222
|
+
regex: /(?:readFile|readFileSync|fs\.read|open)\s*\(\s*(?:.*\.env|.*process\.env|.*dotenv)/g,
|
|
223
|
+
severity: 'high',
|
|
224
|
+
cwe: 'CWE-522',
|
|
225
|
+
owasp: 'A02:2021',
|
|
226
|
+
confidence: 'medium',
|
|
227
|
+
description: 'Agent code reads .env files or loads dotenv directly. If the agent is compromised via prompt injection, all credentials in the environment file are exposed.',
|
|
228
|
+
fix: 'Inject only the specific environment variables the agent needs, not the entire .env file. Use scoped credential providers.',
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
rule: 'AGENT_NETWORK_AND_FILE_ACCESS',
|
|
232
|
+
title: 'Agent: Both Network and File Access (Exfiltration Risk)',
|
|
233
|
+
regex: /(?:tools|capabilities|functions)[\s\S]{0,800}(?:(?:fetch|http|request|axios|got|curl)[\s\S]{0,400}(?:read|file|fs|disk|path)|(?:read|file|fs|disk|path)[\s\S]{0,400}(?:fetch|http|request|axios|got|curl))/g,
|
|
234
|
+
severity: 'high',
|
|
235
|
+
cwe: 'CWE-200',
|
|
236
|
+
owasp: 'A01:2021',
|
|
237
|
+
confidence: 'medium',
|
|
238
|
+
description: 'Agent has tools for both file access and network requests. This is the exfiltration combination: read credentials from disk, send them over the network.',
|
|
239
|
+
fix: 'Separate file-reading agents from network-capable agents. If both are needed, add human-in-the-loop approval for network requests that follow file reads.',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
rule: 'AGENT_ENV_FORWARDED_TO_TOOL',
|
|
243
|
+
title: 'Agent: Environment Variables Forwarded to Tool',
|
|
244
|
+
regex: /(?:process\.env|os\.environ|ENV)\s*(?:\[|\.)[\s\S]{0,100}(?:tool|function|action|invoke|call|execute)/g,
|
|
245
|
+
severity: 'high',
|
|
246
|
+
cwe: 'CWE-522',
|
|
247
|
+
owasp: 'A02:2021',
|
|
248
|
+
confidence: 'medium',
|
|
249
|
+
description: 'Environment variables (which may contain secrets from Stripe Projects or similar) are forwarded directly to agent tools. A compromised tool receives credentials.',
|
|
250
|
+
fix: 'Pass only the specific variables each tool needs. Never forward the entire process.env to tool invocations.',
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
// ── Audit & Observability ────────────────────────────────────────────────
|
|
254
|
+
{
|
|
255
|
+
rule: 'AGENT_NO_AUDIT_LOG',
|
|
256
|
+
title: 'Agent: Tool Invocations Not Logged',
|
|
257
|
+
regex: /(?:tool_call|function_call|executeTool|callTool|tool\.run)[\s\S]{0,300}(?![\s\S]{0,300}(?:log|audit|record|track|monitor|trace|emit|publish))/g,
|
|
258
|
+
severity: 'medium',
|
|
259
|
+
cwe: 'CWE-778',
|
|
260
|
+
owasp: 'A09:2021',
|
|
261
|
+
confidence: 'low',
|
|
262
|
+
description: 'Agent tool invocations are not being logged or audited. Makes incident response and forensics impossible.',
|
|
263
|
+
fix: 'Log all tool invocations including: tool name, arguments, caller identity, timestamp, and result status.',
|
|
264
|
+
},
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
// =============================================================================
|
|
268
|
+
// AGENTIC SECURITY AGENT
|
|
269
|
+
// =============================================================================
|
|
270
|
+
|
|
271
|
+
export class AgenticSecurityAgent extends BaseAgent {
|
|
272
|
+
constructor() {
|
|
273
|
+
super(
|
|
274
|
+
'AgenticSecurityAgent',
|
|
275
|
+
'Detect AI agent security vulnerabilities — goal hijacking, tool misuse, memory poisoning, unbounded execution',
|
|
276
|
+
'llm'
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
async analyze(context) {
|
|
281
|
+
const { files } = context;
|
|
282
|
+
|
|
283
|
+
const codeFiles = files.filter(f => {
|
|
284
|
+
const ext = path.extname(f).toLowerCase();
|
|
285
|
+
return ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.py', '.rb', '.go'].includes(ext);
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
let findings = [];
|
|
289
|
+
for (const file of codeFiles) {
|
|
290
|
+
findings = findings.concat(this.scanFileWithPatterns(file, PATTERNS));
|
|
291
|
+
}
|
|
292
|
+
return findings;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export default AgenticSecurityAgent;
|