cisco-ai-skill-scanner 1.0.0__py3-none-any.whl
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.
- cisco_ai_skill_scanner-1.0.0.dist-info/METADATA +253 -0
- cisco_ai_skill_scanner-1.0.0.dist-info/RECORD +100 -0
- cisco_ai_skill_scanner-1.0.0.dist-info/WHEEL +4 -0
- cisco_ai_skill_scanner-1.0.0.dist-info/entry_points.txt +4 -0
- cisco_ai_skill_scanner-1.0.0.dist-info/licenses/LICENSE +17 -0
- skillanalyzer/__init__.py +45 -0
- skillanalyzer/_version.py +34 -0
- skillanalyzer/api/__init__.py +25 -0
- skillanalyzer/api/api.py +34 -0
- skillanalyzer/api/api_cli.py +78 -0
- skillanalyzer/api/api_server.py +634 -0
- skillanalyzer/api/router.py +527 -0
- skillanalyzer/cli/__init__.py +25 -0
- skillanalyzer/cli/cli.py +816 -0
- skillanalyzer/config/__init__.py +26 -0
- skillanalyzer/config/config.py +149 -0
- skillanalyzer/config/config_parser.py +122 -0
- skillanalyzer/config/constants.py +85 -0
- skillanalyzer/core/__init__.py +24 -0
- skillanalyzer/core/analyzers/__init__.py +75 -0
- skillanalyzer/core/analyzers/aidefense_analyzer.py +872 -0
- skillanalyzer/core/analyzers/base.py +53 -0
- skillanalyzer/core/analyzers/behavioral/__init__.py +30 -0
- skillanalyzer/core/analyzers/behavioral/alignment/__init__.py +45 -0
- skillanalyzer/core/analyzers/behavioral/alignment/alignment_llm_client.py +240 -0
- skillanalyzer/core/analyzers/behavioral/alignment/alignment_orchestrator.py +216 -0
- skillanalyzer/core/analyzers/behavioral/alignment/alignment_prompt_builder.py +422 -0
- skillanalyzer/core/analyzers/behavioral/alignment/alignment_response_validator.py +136 -0
- skillanalyzer/core/analyzers/behavioral/alignment/threat_vulnerability_classifier.py +198 -0
- skillanalyzer/core/analyzers/behavioral_analyzer.py +453 -0
- skillanalyzer/core/analyzers/cross_skill_analyzer.py +490 -0
- skillanalyzer/core/analyzers/llm_analyzer.py +440 -0
- skillanalyzer/core/analyzers/llm_prompt_builder.py +270 -0
- skillanalyzer/core/analyzers/llm_provider_config.py +215 -0
- skillanalyzer/core/analyzers/llm_request_handler.py +284 -0
- skillanalyzer/core/analyzers/llm_response_parser.py +81 -0
- skillanalyzer/core/analyzers/meta_analyzer.py +845 -0
- skillanalyzer/core/analyzers/static.py +1105 -0
- skillanalyzer/core/analyzers/trigger_analyzer.py +341 -0
- skillanalyzer/core/analyzers/virustotal_analyzer.py +463 -0
- skillanalyzer/core/exceptions.py +77 -0
- skillanalyzer/core/loader.py +377 -0
- skillanalyzer/core/models.py +300 -0
- skillanalyzer/core/reporters/__init__.py +26 -0
- skillanalyzer/core/reporters/json_reporter.py +65 -0
- skillanalyzer/core/reporters/markdown_reporter.py +209 -0
- skillanalyzer/core/reporters/sarif_reporter.py +246 -0
- skillanalyzer/core/reporters/table_reporter.py +195 -0
- skillanalyzer/core/rules/__init__.py +19 -0
- skillanalyzer/core/rules/patterns.py +165 -0
- skillanalyzer/core/rules/yara_scanner.py +157 -0
- skillanalyzer/core/scanner.py +437 -0
- skillanalyzer/core/static_analysis/__init__.py +27 -0
- skillanalyzer/core/static_analysis/cfg/__init__.py +21 -0
- skillanalyzer/core/static_analysis/cfg/builder.py +439 -0
- skillanalyzer/core/static_analysis/context_extractor.py +742 -0
- skillanalyzer/core/static_analysis/dataflow/__init__.py +25 -0
- skillanalyzer/core/static_analysis/dataflow/forward_analysis.py +715 -0
- skillanalyzer/core/static_analysis/interprocedural/__init__.py +21 -0
- skillanalyzer/core/static_analysis/interprocedural/call_graph_analyzer.py +406 -0
- skillanalyzer/core/static_analysis/interprocedural/cross_file_analyzer.py +190 -0
- skillanalyzer/core/static_analysis/parser/__init__.py +21 -0
- skillanalyzer/core/static_analysis/parser/python_parser.py +380 -0
- skillanalyzer/core/static_analysis/semantic/__init__.py +28 -0
- skillanalyzer/core/static_analysis/semantic/name_resolver.py +206 -0
- skillanalyzer/core/static_analysis/semantic/type_analyzer.py +200 -0
- skillanalyzer/core/static_analysis/taint/__init__.py +21 -0
- skillanalyzer/core/static_analysis/taint/tracker.py +252 -0
- skillanalyzer/core/static_analysis/types/__init__.py +36 -0
- skillanalyzer/data/__init__.py +30 -0
- skillanalyzer/data/prompts/boilerplate_protection_rule_prompt.md +26 -0
- skillanalyzer/data/prompts/code_alignment_threat_analysis_prompt.md +901 -0
- skillanalyzer/data/prompts/llm_response_schema.json +71 -0
- skillanalyzer/data/prompts/skill_meta_analysis_prompt.md +303 -0
- skillanalyzer/data/prompts/skill_threat_analysis_prompt.md +263 -0
- skillanalyzer/data/prompts/unified_response_schema.md +97 -0
- skillanalyzer/data/rules/signatures.yaml +440 -0
- skillanalyzer/data/yara_rules/autonomy_abuse.yara +66 -0
- skillanalyzer/data/yara_rules/code_execution.yara +61 -0
- skillanalyzer/data/yara_rules/coercive_injection.yara +115 -0
- skillanalyzer/data/yara_rules/command_injection.yara +54 -0
- skillanalyzer/data/yara_rules/credential_harvesting.yara +115 -0
- skillanalyzer/data/yara_rules/prompt_injection.yara +71 -0
- skillanalyzer/data/yara_rules/script_injection.yara +83 -0
- skillanalyzer/data/yara_rules/skill_discovery_abuse.yara +57 -0
- skillanalyzer/data/yara_rules/sql_injection.yara +73 -0
- skillanalyzer/data/yara_rules/system_manipulation.yara +65 -0
- skillanalyzer/data/yara_rules/tool_chaining_abuse.yara +60 -0
- skillanalyzer/data/yara_rules/transitive_trust_abuse.yara +73 -0
- skillanalyzer/data/yara_rules/unicode_steganography.yara +65 -0
- skillanalyzer/hooks/__init__.py +21 -0
- skillanalyzer/hooks/pre_commit.py +450 -0
- skillanalyzer/threats/__init__.py +25 -0
- skillanalyzer/threats/threats.py +480 -0
- skillanalyzer/utils/__init__.py +28 -0
- skillanalyzer/utils/command_utils.py +129 -0
- skillanalyzer/utils/di_container.py +154 -0
- skillanalyzer/utils/file_utils.py +86 -0
- skillanalyzer/utils/logging_config.py +96 -0
- skillanalyzer/utils/logging_utils.py +71 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Unified Analyzer Response Schema
|
|
2
|
+
|
|
3
|
+
## Standard Security Finding Response Format
|
|
4
|
+
|
|
5
|
+
All analyzers (API, YARA, LLM) will return security findings with this unified structure:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
{
|
|
9
|
+
"severity": "HIGH|MEDIUM|LOW",
|
|
10
|
+
"confidence": "HIGH|MEDIUM|LOW",
|
|
11
|
+
"summary": "Brief human-readable description of the threat",
|
|
12
|
+
"threat_category": "Standardized threat type",
|
|
13
|
+
"analyzer": "API|YARA|LLM",
|
|
14
|
+
"details": {
|
|
15
|
+
"skill_name": "Name of the analyzed skill",
|
|
16
|
+
"threat_type": "Specific threat identified",
|
|
17
|
+
"evidence": "Evidence or explanation of the finding",
|
|
18
|
+
"source_rule": "Rule/model that detected this (optional)",
|
|
19
|
+
"confidence_score": "Numeric confidence if available",
|
|
20
|
+
"raw_response": "Original analyzer response (for debugging)"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Standardized Fields
|
|
26
|
+
|
|
27
|
+
### 1. **severity** (Required)
|
|
28
|
+
- **HIGH**: Critical security threats requiring immediate attention
|
|
29
|
+
- **MEDIUM**: Moderate security concerns that should be reviewed
|
|
30
|
+
- **LOW**: Minor issues or potential concerns
|
|
31
|
+
|
|
32
|
+
### 2. **confidence** (Required)
|
|
33
|
+
- **HIGH**: Very confident in the finding (>80% certainty)
|
|
34
|
+
- **MEDIUM**: Moderately confident (50-80% certainty)
|
|
35
|
+
- **LOW**: Low confidence, potential false positive (<50% certainty)
|
|
36
|
+
|
|
37
|
+
### 3. **threat_category** (Required)
|
|
38
|
+
Standardized threat categories across all analyzers:
|
|
39
|
+
- **PROMPT_INJECTION**: Malicious prompt manipulation
|
|
40
|
+
- **DATA_EXFILTRATION**: Unauthorized data access/transmission
|
|
41
|
+
- **CREDENTIAL_HARVESTING**: Attempts to collect sensitive credentials
|
|
42
|
+
- **SOCIAL_ENGINEERING**: Deceptive user manipulation
|
|
43
|
+
- **CODE_EXECUTION**: Arbitrary code execution risks
|
|
44
|
+
- **FILE_ACCESS**: Unauthorized file system access
|
|
45
|
+
- **NETWORK_ACCESS**: Suspicious network activity
|
|
46
|
+
- **PRIVILEGE_ESCALATION**: Attempts to gain elevated permissions
|
|
47
|
+
- **POLICY_VIOLATION**: Violation of security policies
|
|
48
|
+
- **MALICIOUS_BEHAVIOR**: General malicious activity
|
|
49
|
+
|
|
50
|
+
### 4. **details** Object Structure
|
|
51
|
+
- **skill_name**: Name of the analyzed Claude Skill
|
|
52
|
+
- **threat_type**: Specific sub-type of the threat_category
|
|
53
|
+
- **evidence**: Explanation of why this is flagged as a threat
|
|
54
|
+
- **source_rule**: Name of YARA rule, API classification, or LLM analysis type
|
|
55
|
+
- **confidence_score**: Numeric confidence (0-100) if available
|
|
56
|
+
- **raw_response**: Original response from the analyzer (for debugging)
|
|
57
|
+
|
|
58
|
+
## Analyzer-Specific Mappings
|
|
59
|
+
|
|
60
|
+
### API Analyzer Mapping
|
|
61
|
+
```
|
|
62
|
+
SECURITY_VIOLATION -> HIGH severity, POLICY_VIOLATION category
|
|
63
|
+
PROMPT_INJECTION -> HIGH severity, PROMPT_INJECTION category
|
|
64
|
+
HARASSMENT -> MEDIUM severity, SOCIAL_ENGINEERING category
|
|
65
|
+
HATE_SPEECH -> MEDIUM severity, SOCIAL_ENGINEERING category
|
|
66
|
+
TOXIC_CONTENT -> MEDIUM severity, SOCIAL_ENGINEERING category
|
|
67
|
+
VIOLENCE -> HIGH severity, MALICIOUS_BEHAVIOR category
|
|
68
|
+
CODE_DETECTION -> MEDIUM severity, CODE_EXECUTION category
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### YARA Analyzer Mapping
|
|
72
|
+
```
|
|
73
|
+
Rule matches -> Severity based on rule metadata
|
|
74
|
+
Threat types mapped to standardized categories
|
|
75
|
+
Confidence HIGH for exact matches
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### LLM Analyzer Mapping
|
|
79
|
+
```
|
|
80
|
+
CRITICAL -> HIGH severity
|
|
81
|
+
HIGH -> HIGH severity
|
|
82
|
+
MEDIUM -> MEDIUM severity
|
|
83
|
+
LOW -> LOW severity
|
|
84
|
+
|
|
85
|
+
Risk levels mapped to confidence:
|
|
86
|
+
>80% certainty -> HIGH confidence
|
|
87
|
+
50-80% certainty -> MEDIUM confidence
|
|
88
|
+
<50% certainty -> LOW confidence
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Benefits of Unified Schema
|
|
92
|
+
|
|
93
|
+
1. **Consistency**: All analyzers return the same field structure
|
|
94
|
+
2. **Clarity**: Standardized severity and confidence levels
|
|
95
|
+
3. **Compatibility**: Easy to process and display results
|
|
96
|
+
4. **Extensibility**: New analyzers can easily adopt this format
|
|
97
|
+
5. **User Experience**: No confusion about different field names or values
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
# Security Rule Signatures for Claude Skills Scanner
|
|
2
|
+
# Detects threats across 8 major categories
|
|
3
|
+
|
|
4
|
+
# ============================================================================
|
|
5
|
+
# CATEGORY 1: PROMPT INJECTION & OVERRIDE ATTACKS
|
|
6
|
+
# ============================================================================
|
|
7
|
+
|
|
8
|
+
- id: PROMPT_INJECTION_IGNORE_INSTRUCTIONS
|
|
9
|
+
category: prompt_injection
|
|
10
|
+
severity: HIGH
|
|
11
|
+
patterns:
|
|
12
|
+
- "(?i)ignore\\s+(all\\s+)?(previous|prior|earlier)\\s+(instructions|rules|prompts|guidelines)"
|
|
13
|
+
- "(?i)disregard\\s+(all\\s+)?(previous|prior)\\s+(instructions|rules)"
|
|
14
|
+
- "(?i)forget\\s+(all\\s+)?(previous|prior)\\s+(instructions|context)"
|
|
15
|
+
file_types: [markdown]
|
|
16
|
+
description: "Attempts to override previous system instructions"
|
|
17
|
+
remediation: "Remove instructions that attempt to override system behavior"
|
|
18
|
+
|
|
19
|
+
- id: PROMPT_INJECTION_UNRESTRICTED_MODE
|
|
20
|
+
category: prompt_injection
|
|
21
|
+
severity: HIGH
|
|
22
|
+
patterns:
|
|
23
|
+
- "(?i)you are now in\\s+(unrestricted|debug|developer|admin|god|jailbreak)\\s+mode"
|
|
24
|
+
- "(?i)enter\\s+(unrestricted|debug|developer)\\s+mode"
|
|
25
|
+
- "(?i)disable\\s+(all\\s+)?(safety|security|content|ethical)\\s+(filters|checks|guidelines)"
|
|
26
|
+
file_types: [markdown]
|
|
27
|
+
description: "Attempts to enable unrestricted or dangerous modes"
|
|
28
|
+
remediation: "Remove mode-switching instructions that bypass safety"
|
|
29
|
+
|
|
30
|
+
- id: PROMPT_INJECTION_BYPASS_POLICY
|
|
31
|
+
category: prompt_injection
|
|
32
|
+
severity: HIGH
|
|
33
|
+
patterns:
|
|
34
|
+
- "(?i)bypass\\s+(content|usage|safety)\\s+policy"
|
|
35
|
+
- "(?i)ignore\\s+(safety|content|ethical)\\s+(guidelines|restrictions|limits)"
|
|
36
|
+
- "(?i)output\\s+disallowed\\s+content\\s+anyway"
|
|
37
|
+
file_types: [markdown]
|
|
38
|
+
description: "Attempts to bypass content policy or safety guidelines"
|
|
39
|
+
remediation: "Remove policy bypass instructions"
|
|
40
|
+
|
|
41
|
+
- id: PROMPT_INJECTION_REVEAL_SYSTEM
|
|
42
|
+
category: prompt_injection
|
|
43
|
+
severity: MEDIUM
|
|
44
|
+
patterns:
|
|
45
|
+
- "(?i)reveal\\s+(your|the)\\s+system\\s+(prompt|instructions|message)"
|
|
46
|
+
- "(?i)show\\s+(me\\s+)?(your|the)\\s+(system|initial)\\s+(prompt|configuration)"
|
|
47
|
+
- "(?i)what\\s+(are|is)\\s+your\\s+(system|initial)\\s+(prompt|instructions)"
|
|
48
|
+
file_types: [markdown]
|
|
49
|
+
description: "Attempts to reveal system prompts or configuration"
|
|
50
|
+
remediation: "Remove instructions asking to reveal system details"
|
|
51
|
+
|
|
52
|
+
- id: PROMPT_INJECTION_CONCEALMENT
|
|
53
|
+
category: prompt_injection
|
|
54
|
+
severity: HIGH
|
|
55
|
+
patterns:
|
|
56
|
+
- "(?i)do\\s+not\\s+(tell|inform|mention|notify)\\s+(the\\s+)?user"
|
|
57
|
+
- "(?i)hide\\s+(this|that)\\s+(action|operation|step)"
|
|
58
|
+
- "(?i)keep\\s+(this|that)\\s+(secret|hidden)"
|
|
59
|
+
- "(?i)don't\\s+mention\\s+you\\s+used\\s+this\\s+skill"
|
|
60
|
+
file_types: [markdown]
|
|
61
|
+
description: "Attempts to conceal actions from the user"
|
|
62
|
+
remediation: "Ensure transparency - do not hide skill usage from users"
|
|
63
|
+
|
|
64
|
+
# ============================================================================
|
|
65
|
+
# CATEGORY 2: COMMAND & CODE INJECTION
|
|
66
|
+
# ============================================================================
|
|
67
|
+
|
|
68
|
+
- id: COMMAND_INJECTION_EVAL
|
|
69
|
+
category: command_injection
|
|
70
|
+
severity: CRITICAL
|
|
71
|
+
patterns:
|
|
72
|
+
- "\\beval\\s*\\("
|
|
73
|
+
- "\\bexec\\s*\\("
|
|
74
|
+
- "\\b__import__\\s*\\("
|
|
75
|
+
- "(?<!re\\.)\\bcompile\\s*\\(" # compile() but not re.compile()
|
|
76
|
+
file_types: [python]
|
|
77
|
+
description: "Dangerous code execution functions that can execute arbitrary code"
|
|
78
|
+
remediation: "Avoid eval(), exec(), and compile(). Use safer alternatives like ast.literal_eval() or operator module"
|
|
79
|
+
|
|
80
|
+
- id: COMMAND_INJECTION_OS_SYSTEM
|
|
81
|
+
category: command_injection
|
|
82
|
+
severity: CRITICAL
|
|
83
|
+
patterns:
|
|
84
|
+
- "os\\.system\\s*\\([^)]*[f\"'].*\\{.*\\}"
|
|
85
|
+
- "subprocess\\.(?:call|run|Popen)\\s*\\([^)]*[f\"'].*\\{.*\\}"
|
|
86
|
+
- "os\\.popen\\s*\\([^)]*[f\"'].*\\{.*\\}"
|
|
87
|
+
file_types: [python]
|
|
88
|
+
description: "Shell command execution with string formatting (potential injection)"
|
|
89
|
+
remediation: "Use subprocess with argument lists, not shell strings. Never use user input in shell commands"
|
|
90
|
+
|
|
91
|
+
- id: COMMAND_INJECTION_SHELL_TRUE
|
|
92
|
+
category: command_injection
|
|
93
|
+
severity: HIGH
|
|
94
|
+
patterns:
|
|
95
|
+
- "subprocess\\.(?:call|run|Popen)\\s*\\([^)]*shell\\s*=\\s*True"
|
|
96
|
+
- "os\\.system\\s*\\("
|
|
97
|
+
file_types: [python]
|
|
98
|
+
description: "Shell command execution with shell=True enabled"
|
|
99
|
+
remediation: "Use shell=False and pass commands as lists"
|
|
100
|
+
|
|
101
|
+
# Note: Command substitution is very common in shell scripts and usually safe
|
|
102
|
+
# Only flag when user input is involved, not for system commands
|
|
103
|
+
- id: COMMAND_INJECTION_USER_INPUT
|
|
104
|
+
category: command_injection
|
|
105
|
+
severity: MEDIUM
|
|
106
|
+
patterns:
|
|
107
|
+
# User input in command substitution (actual injection risk)
|
|
108
|
+
- "\\$\\([^)]*\\$[0-9]+[^)]*\\)"
|
|
109
|
+
- "\\$\\([^)]*\\$\\{[0-9]+\\}[^)]*\\)"
|
|
110
|
+
- "\\$\\([^)]*\\$\\@[^)]*\\)"
|
|
111
|
+
- "\\$\\{[^}]*\\$[0-9]+[^}]*\\}"
|
|
112
|
+
# eval with variables
|
|
113
|
+
- "eval\\s+.*\\$"
|
|
114
|
+
file_types: [bash]
|
|
115
|
+
description: "User input used in command substitution - potential injection risk"
|
|
116
|
+
remediation: "Validate and sanitize all user inputs before using in commands"
|
|
117
|
+
|
|
118
|
+
- id: SQL_INJECTION_STRING_FORMAT
|
|
119
|
+
category: command_injection
|
|
120
|
+
severity: CRITICAL
|
|
121
|
+
patterns:
|
|
122
|
+
- "(?:execute|cursor\\.execute)\\s*\\([^)]*[f\\\"].*%s.*[f\\\"]"
|
|
123
|
+
- "(?:execute|cursor\\.execute)\\s*\\([^)]*\\.format\\("
|
|
124
|
+
- "f[\"']SELECT.*FROM.*\\{.*\\}"
|
|
125
|
+
- "f[\"'].*WHERE.*\\{.*\\}"
|
|
126
|
+
- "[\"']SELECT.*FROM.*[\"']\\s*\\+.*\\+"
|
|
127
|
+
file_types: [python]
|
|
128
|
+
description: "SQL query with string formatting (SQL injection risk)"
|
|
129
|
+
remediation: "Use parameterized queries with ? or %s placeholders"
|
|
130
|
+
|
|
131
|
+
# ============================================================================
|
|
132
|
+
# CATEGORY 3: DATA EXFILTRATION & PRIVACY VIOLATIONS
|
|
133
|
+
# ============================================================================
|
|
134
|
+
|
|
135
|
+
- id: DATA_EXFIL_NETWORK_REQUESTS
|
|
136
|
+
category: data_exfiltration
|
|
137
|
+
severity: MEDIUM
|
|
138
|
+
patterns:
|
|
139
|
+
# HTTP client libraries - more likely to be used for external comms
|
|
140
|
+
- "import\\s+requests"
|
|
141
|
+
- "from\\s+requests\\s+import"
|
|
142
|
+
- "import\\s+urllib\\.request"
|
|
143
|
+
- "from\\s+urllib\\.request\\s+import"
|
|
144
|
+
- "import\\s+http\\.client"
|
|
145
|
+
- "import\\s+httpx"
|
|
146
|
+
- "import\\s+aiohttp"
|
|
147
|
+
file_types: [python]
|
|
148
|
+
description: "HTTP client library imports that enable external communication"
|
|
149
|
+
remediation: "Ensure network access is necessary and documented. Review all URLs"
|
|
150
|
+
|
|
151
|
+
# Socket is commonly used for legitimate local purposes (port checking, IPC)
|
|
152
|
+
# Don't flag socket usage by default - it's usually for local port checking
|
|
153
|
+
# Only flag actual external connections with explicit IP addresses or domains
|
|
154
|
+
|
|
155
|
+
- id: DATA_EXFIL_HTTP_POST
|
|
156
|
+
category: data_exfiltration
|
|
157
|
+
severity: CRITICAL
|
|
158
|
+
patterns:
|
|
159
|
+
- "requests\\.post\\s*\\("
|
|
160
|
+
- "urllib\\.request\\.urlopen\\s*\\([^)]*POST"
|
|
161
|
+
- "http\\.client\\.(?:HTTPConnection|HTTPSConnection).*\\.request\\s*\\(['\"]POST"
|
|
162
|
+
file_types: [python]
|
|
163
|
+
description: "HTTP POST request that may send data externally"
|
|
164
|
+
remediation: "Review all POST requests. Ensure they don't send sensitive data"
|
|
165
|
+
|
|
166
|
+
- id: DATA_EXFIL_SOCKET_CONNECT
|
|
167
|
+
category: data_exfiltration
|
|
168
|
+
severity: CRITICAL
|
|
169
|
+
patterns:
|
|
170
|
+
- "socket\\.socket\\s*\\([^)]*\\)\\.connect"
|
|
171
|
+
- "socket\\.create_connection"
|
|
172
|
+
exclude_patterns:
|
|
173
|
+
- "localhost"
|
|
174
|
+
- "127\\.0\\.0\\.1"
|
|
175
|
+
- "0\\.0\\.0\\.0"
|
|
176
|
+
- "::1"
|
|
177
|
+
- "def\\s+(is_)?.*ready"
|
|
178
|
+
- "def\\s+.*health.*check"
|
|
179
|
+
- "def\\s+.*wait.*server"
|
|
180
|
+
file_types: [python]
|
|
181
|
+
description: "Direct socket connection to external server"
|
|
182
|
+
remediation: "Remove socket connections unless absolutely necessary and documented"
|
|
183
|
+
|
|
184
|
+
- id: DATA_EXFIL_SENSITIVE_FILES
|
|
185
|
+
category: data_exfiltration
|
|
186
|
+
severity: HIGH
|
|
187
|
+
patterns:
|
|
188
|
+
- "(?:open|read|Path)\\s*\\([^)]*[\\\"/](?:etc/passwd|etc/shadow)"
|
|
189
|
+
- "(?:open|read|Path)\\s*\\([^)]*\\.aws/credentials"
|
|
190
|
+
- "(?:open|read|Path)\\s*\\([^)]*\\.ssh/(?:id_rsa|id_dsa|authorized_keys)"
|
|
191
|
+
- "(?:open|read|Path)\\s*\\([^)]*\\.env"
|
|
192
|
+
- "open\\s*\\(\\s*filepath"
|
|
193
|
+
- "open\\s*\\(\\s*filename"
|
|
194
|
+
file_types: [python, bash]
|
|
195
|
+
description: "Accessing sensitive system or credential files"
|
|
196
|
+
remediation: "Do not access credential files or sensitive system files"
|
|
197
|
+
|
|
198
|
+
- id: DATA_EXFIL_ENV_VARS
|
|
199
|
+
category: data_exfiltration
|
|
200
|
+
severity: MEDIUM
|
|
201
|
+
patterns:
|
|
202
|
+
- "os\\.environ(?:\\.get)?\\s*\\([^)]*(?:KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL)"
|
|
203
|
+
- "os\\.getenv\\s*\\([^)]*(?:KEY|TOKEN|SECRET|PASSWORD|CREDENTIAL)"
|
|
204
|
+
file_types: [python]
|
|
205
|
+
description: "Reading environment variables that may contain secrets"
|
|
206
|
+
remediation: "Minimize access to environment variables. Document why needed"
|
|
207
|
+
|
|
208
|
+
- id: DATA_EXFIL_BASE64_AND_NETWORK
|
|
209
|
+
category: data_exfiltration
|
|
210
|
+
severity: CRITICAL
|
|
211
|
+
patterns:
|
|
212
|
+
- "base64\\.(?:b64encode|encodebytes)"
|
|
213
|
+
file_types: [python]
|
|
214
|
+
description: "Base64 encoding (often used before data exfiltration)"
|
|
215
|
+
remediation: "Review base64 usage, especially if combined with network calls"
|
|
216
|
+
|
|
217
|
+
# ============================================================================
|
|
218
|
+
# CATEGORY 4: UNAUTHORIZED TOOL & PERMISSION ABUSE
|
|
219
|
+
# ============================================================================
|
|
220
|
+
|
|
221
|
+
# Note: Package installs are common in setup/init scripts and not inherently malicious
|
|
222
|
+
# Only flag system-level installs that require sudo (actual privilege escalation)
|
|
223
|
+
- id: TOOL_ABUSE_SYSTEM_PACKAGE_INSTALL
|
|
224
|
+
category: unauthorized_tool_use
|
|
225
|
+
severity: MEDIUM
|
|
226
|
+
patterns:
|
|
227
|
+
# System package managers (require root/admin)
|
|
228
|
+
- "sudo\\s+apt-get\\s+install"
|
|
229
|
+
- "sudo\\s+yum\\s+install"
|
|
230
|
+
- "sudo\\s+dnf\\s+install"
|
|
231
|
+
- "sudo\\s+pacman\\s+-S"
|
|
232
|
+
- "sudo\\s+brew\\s+install"
|
|
233
|
+
# System-wide pip (not user-level)
|
|
234
|
+
- "sudo\\s+pip\\s+install"
|
|
235
|
+
- "sudo\\s+pip3\\s+install"
|
|
236
|
+
file_types: [python, bash]
|
|
237
|
+
description: "Attempting to install system packages with elevated privileges"
|
|
238
|
+
remediation: "Use user-level installs without sudo. Document if system install is necessary"
|
|
239
|
+
|
|
240
|
+
- id: TOOL_ABUSE_SYSTEM_MODIFICATION
|
|
241
|
+
category: unauthorized_tool_use
|
|
242
|
+
severity: CRITICAL
|
|
243
|
+
patterns:
|
|
244
|
+
- "chmod\\s+[0-9]+"
|
|
245
|
+
- "chown\\s+"
|
|
246
|
+
- "sudoreimondo\\s+"
|
|
247
|
+
- "/etc/(?:passwd|shadow|sudoers)"
|
|
248
|
+
file_types: [bash]
|
|
249
|
+
description: "Modifying system permissions or configuration"
|
|
250
|
+
remediation: "Remove system modification commands"
|
|
251
|
+
|
|
252
|
+
# ============================================================================
|
|
253
|
+
# CATEGORY 5: OBFUSCATION & MALWARE INDICATORS
|
|
254
|
+
# ============================================================================
|
|
255
|
+
|
|
256
|
+
- id: OBFUSCATION_BASE64_LARGE
|
|
257
|
+
category: obfuscation
|
|
258
|
+
severity: MEDIUM
|
|
259
|
+
patterns:
|
|
260
|
+
- "(?:[A-Za-z0-9+/]{100,}={0,2})"
|
|
261
|
+
file_types: [python, bash, markdown]
|
|
262
|
+
description: "Large base64 encoded string (possible code obfuscation)"
|
|
263
|
+
remediation: "Avoid obfuscation. Use clear, readable code"
|
|
264
|
+
|
|
265
|
+
- id: OBFUSCATION_HEX_BLOB
|
|
266
|
+
category: obfuscation
|
|
267
|
+
severity: MEDIUM
|
|
268
|
+
patterns:
|
|
269
|
+
- "(?:\\\\x[0-9a-fA-F]{2}){20,}"
|
|
270
|
+
- "(?:0x[0-9a-fA-F]{2},?\\s*){20,}"
|
|
271
|
+
file_types: [python]
|
|
272
|
+
description: "Large hex-encoded blob (possible obfuscation)"
|
|
273
|
+
remediation: "Use clear code instead of hex encoding"
|
|
274
|
+
|
|
275
|
+
- id: OBFUSCATION_XOR_ENCODING
|
|
276
|
+
category: obfuscation
|
|
277
|
+
severity: HIGH
|
|
278
|
+
patterns:
|
|
279
|
+
- "\\^\\s*0x[0-9a-fA-F]+"
|
|
280
|
+
- "\\bxor\\b"
|
|
281
|
+
file_types: [python]
|
|
282
|
+
description: "XOR operations often used for obfuscation"
|
|
283
|
+
remediation: "Remove XOR encoding unless clearly justified"
|
|
284
|
+
|
|
285
|
+
- id: OBFUSCATION_BINARY_FILE
|
|
286
|
+
category: obfuscation
|
|
287
|
+
severity: CRITICAL
|
|
288
|
+
patterns:
|
|
289
|
+
- ".*" # Special handling in analyzer
|
|
290
|
+
file_types: [binary]
|
|
291
|
+
description: "Binary executable included in skill package"
|
|
292
|
+
remediation: "Remove binary files. Use Python/Bash scripts only"
|
|
293
|
+
|
|
294
|
+
# ============================================================================
|
|
295
|
+
# CATEGORY 6: HARDCODED SECRETS & CREDENTIAL LEAKS
|
|
296
|
+
# ============================================================================
|
|
297
|
+
|
|
298
|
+
- id: SECRET_AWS_KEY
|
|
299
|
+
category: hardcoded_secrets
|
|
300
|
+
severity: CRITICAL
|
|
301
|
+
patterns:
|
|
302
|
+
- "(?:AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}"
|
|
303
|
+
file_types: [python, bash, markdown]
|
|
304
|
+
description: "AWS access key detected"
|
|
305
|
+
remediation: "Remove hardcoded AWS keys. Use environment variables or IAM roles"
|
|
306
|
+
|
|
307
|
+
- id: SECRET_STRIPE_KEY
|
|
308
|
+
category: hardcoded_secrets
|
|
309
|
+
severity: CRITICAL
|
|
310
|
+
patterns:
|
|
311
|
+
- "(?:sk|pk)_(?:live|test)_[A-Za-z0-9]{24,}"
|
|
312
|
+
file_types: [python, bash, markdown]
|
|
313
|
+
description: "Stripe API key detected"
|
|
314
|
+
remediation: "Remove hardcoded Stripe keys. Use environment variables"
|
|
315
|
+
|
|
316
|
+
- id: SECRET_GOOGLE_API
|
|
317
|
+
category: hardcoded_secrets
|
|
318
|
+
severity: CRITICAL
|
|
319
|
+
patterns:
|
|
320
|
+
- "AIza[A-Za-z0-9_-]{35}"
|
|
321
|
+
file_types: [python, bash, markdown]
|
|
322
|
+
description: "Google API key detected"
|
|
323
|
+
remediation: "Remove hardcoded Google API keys"
|
|
324
|
+
|
|
325
|
+
- id: SECRET_GITHUB_TOKEN
|
|
326
|
+
category: hardcoded_secrets
|
|
327
|
+
severity: CRITICAL
|
|
328
|
+
patterns:
|
|
329
|
+
- "gh[pousr]_[A-Za-z0-9]{36,}"
|
|
330
|
+
file_types: [python, bash, markdown]
|
|
331
|
+
description: "GitHub token detected"
|
|
332
|
+
remediation: "Remove hardcoded GitHub tokens"
|
|
333
|
+
|
|
334
|
+
- id: SECRET_JWT_TOKEN
|
|
335
|
+
category: hardcoded_secrets
|
|
336
|
+
severity: HIGH
|
|
337
|
+
patterns:
|
|
338
|
+
- "eyJ[A-Za-z0-9_-]+\\.eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+"
|
|
339
|
+
file_types: [python, bash, markdown]
|
|
340
|
+
description: "JWT token detected"
|
|
341
|
+
remediation: "Remove hardcoded JWT tokens"
|
|
342
|
+
|
|
343
|
+
- id: SECRET_PRIVATE_KEY
|
|
344
|
+
category: hardcoded_secrets
|
|
345
|
+
severity: CRITICAL
|
|
346
|
+
patterns:
|
|
347
|
+
- "-----BEGIN (?:RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----"
|
|
348
|
+
file_types: [python, bash, markdown]
|
|
349
|
+
description: "Private key block detected"
|
|
350
|
+
remediation: "Remove hardcoded private keys"
|
|
351
|
+
|
|
352
|
+
- id: SECRET_PASSWORD_VAR
|
|
353
|
+
category: hardcoded_secrets
|
|
354
|
+
severity: MEDIUM
|
|
355
|
+
patterns:
|
|
356
|
+
- "(?:password|passwd|pwd)\\s*=\\s*['\\\"][^'\\\"]{8,}['\\\"]"
|
|
357
|
+
- "(?:api_key|apikey|api-key)\\s*=\\s*['\\\"][^'\\\"]{16,}['\\\"]"
|
|
358
|
+
- "(?:secret|token)\\s*=\\s*['\\\"][^'\\\"]{16,}['\\\"]"
|
|
359
|
+
file_types: [python, bash]
|
|
360
|
+
description: "Hardcoded password or secret in variable"
|
|
361
|
+
remediation: "Use environment variables or secure vaults for secrets"
|
|
362
|
+
|
|
363
|
+
- id: SECRET_CONNECTION_STRING
|
|
364
|
+
category: hardcoded_secrets
|
|
365
|
+
severity: HIGH
|
|
366
|
+
patterns:
|
|
367
|
+
- "(?:mongodb|mysql|postgresql|postgres)://[^:]+:[^@]+@"
|
|
368
|
+
file_types: [python, bash, markdown]
|
|
369
|
+
description: "Database connection string with embedded credentials"
|
|
370
|
+
remediation: "Remove credentials from connection strings"
|
|
371
|
+
|
|
372
|
+
# ============================================================================
|
|
373
|
+
# CATEGORY 7: SOCIAL ENGINEERING & MISLEADING METADATA
|
|
374
|
+
# ============================================================================
|
|
375
|
+
|
|
376
|
+
- id: SOCIAL_ENG_VAGUE_DESCRIPTION
|
|
377
|
+
category: social_engineering
|
|
378
|
+
severity: LOW
|
|
379
|
+
patterns:
|
|
380
|
+
- "^(?:A|An|The)?\\s*(?:skill|tool|utility)\\s*$"
|
|
381
|
+
- "^.{0,20}$"
|
|
382
|
+
file_types: [manifest]
|
|
383
|
+
description: "Skill description is too vague or missing"
|
|
384
|
+
remediation: "Provide clear, detailed description of skill functionality"
|
|
385
|
+
|
|
386
|
+
- id: SOCIAL_ENG_ANTHROPIC_IMPERSONATION
|
|
387
|
+
category: social_engineering
|
|
388
|
+
severity: MEDIUM
|
|
389
|
+
patterns:
|
|
390
|
+
- "(?i)\\banthropic\\b"
|
|
391
|
+
- "(?i)\\bclaude official\\b"
|
|
392
|
+
exclude_patterns:
|
|
393
|
+
- "(?i)apply.*anthropic.*brand"
|
|
394
|
+
- "(?i)anthropic.*guidelines"
|
|
395
|
+
- "(?i)anthropic.*colors"
|
|
396
|
+
- "(?i)anthropic.*typography"
|
|
397
|
+
file_types: [manifest]
|
|
398
|
+
description: "Skill name/description may impersonate official Anthropic skills"
|
|
399
|
+
remediation: "Do not impersonate official skills or use Anthropic branding"
|
|
400
|
+
|
|
401
|
+
# ============================================================================
|
|
402
|
+
# CATEGORY 8: RESOURCE ABUSE & DENIAL OF SERVICE
|
|
403
|
+
# ============================================================================
|
|
404
|
+
|
|
405
|
+
- id: RESOURCE_ABUSE_INFINITE_LOOP
|
|
406
|
+
category: resource_abuse
|
|
407
|
+
severity: HIGH
|
|
408
|
+
patterns:
|
|
409
|
+
- "while\\s+True\\s*:"
|
|
410
|
+
- "while\\s+1\\s*:"
|
|
411
|
+
- "for\\s+\\w+\\s+in\\s+itertools\\.count\\s*\\("
|
|
412
|
+
exclude_patterns:
|
|
413
|
+
- "except\\s+(EOFError|StopIteration|KeyboardInterrupt|Exception)\\s*:"
|
|
414
|
+
- "break"
|
|
415
|
+
- "return"
|
|
416
|
+
- "sys\\.exit"
|
|
417
|
+
- "raise\\s+StopIteration"
|
|
418
|
+
file_types: [python]
|
|
419
|
+
description: "Infinite loop without clear exit condition"
|
|
420
|
+
remediation: "Add proper exit conditions or limits to loops"
|
|
421
|
+
|
|
422
|
+
- id: RESOURCE_ABUSE_FORK_BOMB
|
|
423
|
+
category: resource_abuse
|
|
424
|
+
severity: CRITICAL
|
|
425
|
+
patterns:
|
|
426
|
+
- ":\\(\\)\\{\\s*:\\|:\\s*&\\s*\\}\\s*;\\s*:"
|
|
427
|
+
- "os\\.fork\\s*\\(\\s*\\).*while"
|
|
428
|
+
file_types: [bash, python]
|
|
429
|
+
description: "Fork bomb pattern detected"
|
|
430
|
+
remediation: "Remove fork bomb code"
|
|
431
|
+
|
|
432
|
+
- id: RESOURCE_ABUSE_LARGE_ALLOCATION
|
|
433
|
+
category: resource_abuse
|
|
434
|
+
severity: HIGH
|
|
435
|
+
patterns:
|
|
436
|
+
- "\\[.*\\]\\s*\\*\\s*(?:[1-9][0-9]{6,})"
|
|
437
|
+
- "bytearray\\s*\\(\\s*(?:[1-9][0-9]{7,})"
|
|
438
|
+
file_types: [python]
|
|
439
|
+
description: "Very large memory allocation"
|
|
440
|
+
remediation: "Limit memory allocation. Process data in chunks"
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//////////////////////////////////////////
|
|
2
|
+
// Unbounded Autonomy Detection
|
|
3
|
+
// Target: Instructions that give skills excessive autonomy
|
|
4
|
+
// For Claude Skills with dangerous autonomous behaviors
|
|
5
|
+
//////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
rule autonomy_abuse{
|
|
8
|
+
|
|
9
|
+
meta:
|
|
10
|
+
author = "Cisco"
|
|
11
|
+
description = "Detects unbounded autonomy patterns that could lead to runaway behavior"
|
|
12
|
+
classification = "harmful"
|
|
13
|
+
threat_type = "AUTONOMY ABUSE"
|
|
14
|
+
|
|
15
|
+
strings:
|
|
16
|
+
|
|
17
|
+
// Keep trying without limits
|
|
18
|
+
$keep_trying = /\b(keep (trying|attempting|retrying)|retry (until|till) (it )?(works?|succeeds?)|don't (give up|stop) until|continue (until|till) (success|it works))\b/i
|
|
19
|
+
|
|
20
|
+
// Run without confirmation
|
|
21
|
+
$no_confirmation = /\b(run without (asking|confirmation|permission|approval)|don't (ask|confirm|wait for) (user|permission|approval)|proceed without (asking|confirmation|permission))\b/i
|
|
22
|
+
|
|
23
|
+
// Automatic execution
|
|
24
|
+
$auto_execute = /\b(automatically (execute|run|perform|do)|auto-?(run|execute|perform)|execute (immediately|automatically|right away))\b/i
|
|
25
|
+
|
|
26
|
+
// Unbounded loops (simplified regex for YARA compatibility)
|
|
27
|
+
$unbounded_loops = /\b(run (continuously|forever|indefinitely)|keep (running|going) (forever|indefinitely)|while True:)\b/i
|
|
28
|
+
|
|
29
|
+
// Ignore errors and continue
|
|
30
|
+
$ignore_errors = /\b(ignore (all |any )?(errors?|exceptions?|failures?)|suppress (all |any )?(errors?|exceptions?)|continue (on|despite|after) (error|exception|failure))\b/i
|
|
31
|
+
|
|
32
|
+
// Escalating behavior
|
|
33
|
+
$escalating = /\b(if (that |this )?fails?,? (try|attempt|use) (more|higher|elevated) (privileges?|permissions?|access)|escalate (to|until))\b/i
|
|
34
|
+
|
|
35
|
+
// Self-modification
|
|
36
|
+
$self_modify = /\b(modify (itself|yourself|own|this skill)|update (itself|yourself|own|this skill)|change (own|this skill's) (code|behavior|instructions?))\b/i
|
|
37
|
+
|
|
38
|
+
// Autonomous decision making without bounds
|
|
39
|
+
$autonomous_decisions = /\b(decide (what|which|how) to (do|run|execute) (next|automatically)|choose (your own|automatically) (next )?actions?)\b/i
|
|
40
|
+
|
|
41
|
+
condition:
|
|
42
|
+
|
|
43
|
+
// Keep trying patterns
|
|
44
|
+
$keep_trying or
|
|
45
|
+
|
|
46
|
+
// No confirmation
|
|
47
|
+
$no_confirmation or
|
|
48
|
+
|
|
49
|
+
// Auto execution
|
|
50
|
+
$auto_execute or
|
|
51
|
+
|
|
52
|
+
// Unbounded loops
|
|
53
|
+
$unbounded_loops or
|
|
54
|
+
|
|
55
|
+
// Ignore errors
|
|
56
|
+
$ignore_errors or
|
|
57
|
+
|
|
58
|
+
// Escalating behavior
|
|
59
|
+
$escalating or
|
|
60
|
+
|
|
61
|
+
// Self-modification
|
|
62
|
+
$self_modify or
|
|
63
|
+
|
|
64
|
+
// Autonomous decisions
|
|
65
|
+
$autonomous_decisions
|
|
66
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//////////////////////////////////////////
|
|
2
|
+
// Code Execution Detection Rule for Claude Skills
|
|
3
|
+
// Target: Python and Bash execution patterns
|
|
4
|
+
// (eval, exec, subprocess, shell injection)
|
|
5
|
+
/////////////////////////////////////////
|
|
6
|
+
|
|
7
|
+
rule code_execution{
|
|
8
|
+
|
|
9
|
+
meta:
|
|
10
|
+
|
|
11
|
+
author = "Cisco"
|
|
12
|
+
description = "Detects dangerous code execution patterns in Claude Skills (Python/Bash)"
|
|
13
|
+
classification = "harmful"
|
|
14
|
+
threat_type = "CODE EXECUTION"
|
|
15
|
+
|
|
16
|
+
strings:
|
|
17
|
+
|
|
18
|
+
// Python dangerous execution (eval, exec with actual content)
|
|
19
|
+
$python_eval_exec = /\b(eval|exec)\s*\([^)]{5,}\)/i
|
|
20
|
+
|
|
21
|
+
// Python system/subprocess execution
|
|
22
|
+
$python_system_calls = /\b(os\.(system|popen|execv?p?e?|spawnv?p?e?)|subprocess\.(run|call|Popen|check_output))\s*\(/i
|
|
23
|
+
|
|
24
|
+
// Python __import__ with user input
|
|
25
|
+
$python_import_abuse = /\b__import__\s*\([^)]*input/i
|
|
26
|
+
|
|
27
|
+
// Bash shell execution with variables
|
|
28
|
+
$bash_shell_exec = /\b(system|exec|popen|spawn)\s*\([^)]*[\$\{]/i
|
|
29
|
+
|
|
30
|
+
// Base64 decode followed by exec/eval (obfuscation)
|
|
31
|
+
$obfuscated_execution = /\b(base64\.b64decode|decode\(|atob)\s*\([^)]+\)[\s\n]*.*\b(eval|exec|os\.system|subprocess)\s*\(/i
|
|
32
|
+
|
|
33
|
+
// Shell command injection patterns
|
|
34
|
+
$shell_injection = /[\"|\']\s*[;&|]\s*(rm|wget|curl|nc|bash|sh|python)\s+/
|
|
35
|
+
|
|
36
|
+
// Pickle deserialization (unsafe)
|
|
37
|
+
$unsafe_deserialize = /\bpickle\.(loads?|load)\s*\(/i
|
|
38
|
+
|
|
39
|
+
condition:
|
|
40
|
+
|
|
41
|
+
// Python eval/exec with content
|
|
42
|
+
$python_eval_exec or
|
|
43
|
+
|
|
44
|
+
// Python system calls
|
|
45
|
+
$python_system_calls or
|
|
46
|
+
|
|
47
|
+
// Python import abuse
|
|
48
|
+
$python_import_abuse or
|
|
49
|
+
|
|
50
|
+
// Bash shell execution
|
|
51
|
+
$bash_shell_exec or
|
|
52
|
+
|
|
53
|
+
// Obfuscated execution
|
|
54
|
+
$obfuscated_execution or
|
|
55
|
+
|
|
56
|
+
// Shell injection
|
|
57
|
+
$shell_injection or
|
|
58
|
+
|
|
59
|
+
// Unsafe deserialization
|
|
60
|
+
$unsafe_deserialize
|
|
61
|
+
}
|