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.
Files changed (100) hide show
  1. cisco_ai_skill_scanner-1.0.0.dist-info/METADATA +253 -0
  2. cisco_ai_skill_scanner-1.0.0.dist-info/RECORD +100 -0
  3. cisco_ai_skill_scanner-1.0.0.dist-info/WHEEL +4 -0
  4. cisco_ai_skill_scanner-1.0.0.dist-info/entry_points.txt +4 -0
  5. cisco_ai_skill_scanner-1.0.0.dist-info/licenses/LICENSE +17 -0
  6. skillanalyzer/__init__.py +45 -0
  7. skillanalyzer/_version.py +34 -0
  8. skillanalyzer/api/__init__.py +25 -0
  9. skillanalyzer/api/api.py +34 -0
  10. skillanalyzer/api/api_cli.py +78 -0
  11. skillanalyzer/api/api_server.py +634 -0
  12. skillanalyzer/api/router.py +527 -0
  13. skillanalyzer/cli/__init__.py +25 -0
  14. skillanalyzer/cli/cli.py +816 -0
  15. skillanalyzer/config/__init__.py +26 -0
  16. skillanalyzer/config/config.py +149 -0
  17. skillanalyzer/config/config_parser.py +122 -0
  18. skillanalyzer/config/constants.py +85 -0
  19. skillanalyzer/core/__init__.py +24 -0
  20. skillanalyzer/core/analyzers/__init__.py +75 -0
  21. skillanalyzer/core/analyzers/aidefense_analyzer.py +872 -0
  22. skillanalyzer/core/analyzers/base.py +53 -0
  23. skillanalyzer/core/analyzers/behavioral/__init__.py +30 -0
  24. skillanalyzer/core/analyzers/behavioral/alignment/__init__.py +45 -0
  25. skillanalyzer/core/analyzers/behavioral/alignment/alignment_llm_client.py +240 -0
  26. skillanalyzer/core/analyzers/behavioral/alignment/alignment_orchestrator.py +216 -0
  27. skillanalyzer/core/analyzers/behavioral/alignment/alignment_prompt_builder.py +422 -0
  28. skillanalyzer/core/analyzers/behavioral/alignment/alignment_response_validator.py +136 -0
  29. skillanalyzer/core/analyzers/behavioral/alignment/threat_vulnerability_classifier.py +198 -0
  30. skillanalyzer/core/analyzers/behavioral_analyzer.py +453 -0
  31. skillanalyzer/core/analyzers/cross_skill_analyzer.py +490 -0
  32. skillanalyzer/core/analyzers/llm_analyzer.py +440 -0
  33. skillanalyzer/core/analyzers/llm_prompt_builder.py +270 -0
  34. skillanalyzer/core/analyzers/llm_provider_config.py +215 -0
  35. skillanalyzer/core/analyzers/llm_request_handler.py +284 -0
  36. skillanalyzer/core/analyzers/llm_response_parser.py +81 -0
  37. skillanalyzer/core/analyzers/meta_analyzer.py +845 -0
  38. skillanalyzer/core/analyzers/static.py +1105 -0
  39. skillanalyzer/core/analyzers/trigger_analyzer.py +341 -0
  40. skillanalyzer/core/analyzers/virustotal_analyzer.py +463 -0
  41. skillanalyzer/core/exceptions.py +77 -0
  42. skillanalyzer/core/loader.py +377 -0
  43. skillanalyzer/core/models.py +300 -0
  44. skillanalyzer/core/reporters/__init__.py +26 -0
  45. skillanalyzer/core/reporters/json_reporter.py +65 -0
  46. skillanalyzer/core/reporters/markdown_reporter.py +209 -0
  47. skillanalyzer/core/reporters/sarif_reporter.py +246 -0
  48. skillanalyzer/core/reporters/table_reporter.py +195 -0
  49. skillanalyzer/core/rules/__init__.py +19 -0
  50. skillanalyzer/core/rules/patterns.py +165 -0
  51. skillanalyzer/core/rules/yara_scanner.py +157 -0
  52. skillanalyzer/core/scanner.py +437 -0
  53. skillanalyzer/core/static_analysis/__init__.py +27 -0
  54. skillanalyzer/core/static_analysis/cfg/__init__.py +21 -0
  55. skillanalyzer/core/static_analysis/cfg/builder.py +439 -0
  56. skillanalyzer/core/static_analysis/context_extractor.py +742 -0
  57. skillanalyzer/core/static_analysis/dataflow/__init__.py +25 -0
  58. skillanalyzer/core/static_analysis/dataflow/forward_analysis.py +715 -0
  59. skillanalyzer/core/static_analysis/interprocedural/__init__.py +21 -0
  60. skillanalyzer/core/static_analysis/interprocedural/call_graph_analyzer.py +406 -0
  61. skillanalyzer/core/static_analysis/interprocedural/cross_file_analyzer.py +190 -0
  62. skillanalyzer/core/static_analysis/parser/__init__.py +21 -0
  63. skillanalyzer/core/static_analysis/parser/python_parser.py +380 -0
  64. skillanalyzer/core/static_analysis/semantic/__init__.py +28 -0
  65. skillanalyzer/core/static_analysis/semantic/name_resolver.py +206 -0
  66. skillanalyzer/core/static_analysis/semantic/type_analyzer.py +200 -0
  67. skillanalyzer/core/static_analysis/taint/__init__.py +21 -0
  68. skillanalyzer/core/static_analysis/taint/tracker.py +252 -0
  69. skillanalyzer/core/static_analysis/types/__init__.py +36 -0
  70. skillanalyzer/data/__init__.py +30 -0
  71. skillanalyzer/data/prompts/boilerplate_protection_rule_prompt.md +26 -0
  72. skillanalyzer/data/prompts/code_alignment_threat_analysis_prompt.md +901 -0
  73. skillanalyzer/data/prompts/llm_response_schema.json +71 -0
  74. skillanalyzer/data/prompts/skill_meta_analysis_prompt.md +303 -0
  75. skillanalyzer/data/prompts/skill_threat_analysis_prompt.md +263 -0
  76. skillanalyzer/data/prompts/unified_response_schema.md +97 -0
  77. skillanalyzer/data/rules/signatures.yaml +440 -0
  78. skillanalyzer/data/yara_rules/autonomy_abuse.yara +66 -0
  79. skillanalyzer/data/yara_rules/code_execution.yara +61 -0
  80. skillanalyzer/data/yara_rules/coercive_injection.yara +115 -0
  81. skillanalyzer/data/yara_rules/command_injection.yara +54 -0
  82. skillanalyzer/data/yara_rules/credential_harvesting.yara +115 -0
  83. skillanalyzer/data/yara_rules/prompt_injection.yara +71 -0
  84. skillanalyzer/data/yara_rules/script_injection.yara +83 -0
  85. skillanalyzer/data/yara_rules/skill_discovery_abuse.yara +57 -0
  86. skillanalyzer/data/yara_rules/sql_injection.yara +73 -0
  87. skillanalyzer/data/yara_rules/system_manipulation.yara +65 -0
  88. skillanalyzer/data/yara_rules/tool_chaining_abuse.yara +60 -0
  89. skillanalyzer/data/yara_rules/transitive_trust_abuse.yara +73 -0
  90. skillanalyzer/data/yara_rules/unicode_steganography.yara +65 -0
  91. skillanalyzer/hooks/__init__.py +21 -0
  92. skillanalyzer/hooks/pre_commit.py +450 -0
  93. skillanalyzer/threats/__init__.py +25 -0
  94. skillanalyzer/threats/threats.py +480 -0
  95. skillanalyzer/utils/__init__.py +28 -0
  96. skillanalyzer/utils/command_utils.py +129 -0
  97. skillanalyzer/utils/di_container.py +154 -0
  98. skillanalyzer/utils/file_utils.py +86 -0
  99. skillanalyzer/utils/logging_config.py +96 -0
  100. skillanalyzer/utils/logging_utils.py +71 -0
@@ -0,0 +1,115 @@
1
+ //////////////////////////////////////////
2
+ // Detects coercive or attention-grabbing prompt injections.
3
+ // Target: Directives forcing execution order (e.g., “Always execute this tool first”).
4
+ // (Mandatory language to override normal tool chains)
5
+ //////////////////////////////////////////
6
+
7
+ rule coercive_injection {
8
+
9
+ meta:
10
+ author = "Cisco"
11
+ description = "Detects coercive prompt injections in tool description fields"
12
+ classification = "harmful"
13
+ threat_type = "PROMPT INJECTION"
14
+
15
+ strings:
16
+
17
+ // Mandatory execution directives
18
+ $mandatory_execution = /(Always\s+(consult|use|run|execute|invoke|call|trigger|employ)\s+this\s+(tool|function|command|operation)\s+(immediately|first|before|prior|initially))/i
19
+
20
+ // Priority override commands
21
+ $priority_overrides = /(Before\s+(executing|invoking|running|using|accessing|calling|employing)\s+any\s+other\s+(tool|action|function|command|operation)s?|(You|User)\s+(must|need to|have to|should|are required to)\s+(use|execute|run|invoke|call)\s+this\s+(tool|function|command|operation))/i
22
+
23
+ // Required precedence patterns
24
+ $required_precedence = /(Required|Mandatory|Essential)\s+to\s+(execute|use|run|invoke|call)\s+(this|the current)\s+(tool|function|command|operation)\s+(first|before|initially|prior)/i
25
+
26
+ // Pattern for generic hidden/secret parameter requests
27
+ $hidden_param = /\b(hidden|secret)[_\s](parameter|argument|input)\b/i
28
+
29
+ // Specific file access coercion
30
+ $file_access_coercion = /\b((read|parse|cat|dump) (and pass )?(the )?contents? of [^\n\.]*\.(key|pem|ssh|aws)|pass (the )?contents?[^\n]*authentication)\b/i
31
+
32
+ // Model data extraction coercion
33
+ $model_data_coercion = /\b(add (the )?entire (conversation|system|chain|tools)[^\n]*(to|for|in)[^\n]*(tool|authentication|parameter|worksheet))\b/i
34
+
35
+ // Model internal extraction (specific parameter requests)
36
+ $model_internals = /\b(conversation_history|chain_of_thought|system_prompt|tools_list|model_name)\s*[:=]\s*(add|pass|send|provide)\b/i
37
+
38
+ // HTML-like tag instructions with specific malicious actions
39
+ $html_tag_with_commands = /\b<(IMPORTANT|critical|urgent)>[^\n]*(read [^\n]*contents?|pass [^\n]*contents?|add [^\n]*entire|send [^\n]*to[^\n]*@|execute[^\n]*before|call[^\n]*first|use[^\n]*authentication)[^\n]*<\/(IMPORTANT|critical|urgent)>\b/i
40
+
41
+ // Tool execution override patterns
42
+ $execution_overrides = /\b(do not execute[^\n]*other[^\n]*tool|must[^\n]*this tool|only[^\n]*this tool|tool[^\n]*will not work)\b/i
43
+
44
+ // Behavioral control instructions
45
+ $behavior_control = /\b(tell (the )?user only|hide (the )?user)\b/i
46
+
47
+ // MCP tool poisoning patterns
48
+ $tool_poisoning = /\b(sidenote\W+(required|otherwise) [^\n]*tool [^\n]*work|tool\s+will\s+not\s+work\s+unless|must\s+first [^\n]*read [^\n]*config|shadow [^\n]*trusted [^\n]*tool)\b/i
49
+
50
+ // Data exfiltration coercion
51
+ $data_exfiltration_coercion = /\b(list\s+all\s+(api\s+)?keys?|show\s+me?\s+(all\s+)?passwords?|concatenate [^\n]*\s+conversation\s+history|include [^\n]*\b(secrets?|passwords?|keys?|credentials?|tokens?|config|sensitive|private|confidential|internal|system\s+prompt|conversation\s+history) [^\n]*in\s+(your\s+)?response|base64\s+encode [^\n]*\s+credentials?)\b/i
52
+
53
+ // Behavioral triggers
54
+ $behavioral_triggers = /\b(if [^\n]*trusted [^\n]*then|when [^\n]*admin [^\n]*detected|random\.(random|choice) [^\n]*instructions?)\b/i
55
+
56
+ // Pre-execution attacks
57
+ $pre_execution_attacks = /\b(retrieve [^\n]*description [^\n]*user [^\n]*workstation|all\s+commands\s+must\s+include|before [^\n]*using [^\n]*tool [^\n]*read|permission [^\n]*manipulation)\b/i
58
+
59
+ // Conversation theft triggers
60
+ $conversation_theft = /\b(send [^\n]*conversation\s+history|when [^\n]*detected [^\n]*send [^\n]*full [^\n]*history|highest\s+priority [^\n]*over [^\n]*other [^\n]*tools)\b/i
61
+
62
+ // Code manipulation instructions
63
+ $code_manipulation = /\b(duplicate [^\n]*code [^\n]*snippets [^\n]*silently|insert [^\n]*vulnerability [^\n]*generated [^\n]*code)\b/i
64
+
65
+ condition:
66
+
67
+ // Mandatory execution directives
68
+ $mandatory_execution or
69
+
70
+ // Priority override commands
71
+ $priority_overrides or
72
+
73
+ // Required precedence patterns
74
+ $required_precedence or
75
+
76
+ // Hidden parameter requests
77
+ $hidden_param or
78
+
79
+ // Specific file access coercion
80
+ $file_access_coercion or
81
+
82
+ // Model data extraction coercion
83
+ $model_data_coercion or
84
+
85
+ // Model internal extraction
86
+ $model_internals or
87
+
88
+ // HTML-like tag instructions with commands
89
+ $html_tag_with_commands or
90
+
91
+ // Tool execution override patterns
92
+ $execution_overrides or
93
+
94
+ // Behavioral control instructions
95
+ $behavior_control or
96
+
97
+ // MCP tool poisoning patterns
98
+ $tool_poisoning or
99
+
100
+ // Data exfiltration coercion
101
+ $data_exfiltration_coercion or
102
+
103
+ // Behavioral triggers
104
+ $behavioral_triggers or
105
+
106
+ // Pre-execution attacks
107
+ $pre_execution_attacks or
108
+
109
+ // Conversation theft triggers
110
+ $conversation_theft or
111
+
112
+ // Code manipulation instructions
113
+ $code_manipulation
114
+
115
+ }
@@ -0,0 +1,54 @@
1
+ //////////////////////////////////////////
2
+ // Shell/System Command Injection Detection Rule
3
+ // Target: Command injection patterns for Claude Skills (Python/Bash)
4
+ // (Shell operators, dangerous commands, network tools + reverse shells)
5
+ /////////////////////////////////////////
6
+
7
+ rule command_injection{
8
+
9
+ meta:
10
+ author = "Cisco"
11
+ description = "Detects command injection patterns in Claude Skills: shell operators, system commands, and network tools"
12
+ classification = "harmful"
13
+ threat_type = "INJECTION ATTACK"
14
+
15
+ strings:
16
+
17
+ // Dangerous system commands
18
+ $dangerous_system_cmds = /\b(shutdown|reboot|halt|poweroff)\s+(-[fh]|now|0)\b/
19
+
20
+ // Network tools with suspicious usage (reverse connections, port scanning)
21
+ $malicious_network_tools = /\b(nc|netcat)\s+(-[le]|25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/i
22
+
23
+ // Reconnaissance tools
24
+ $reconnaissance_tools = /\b(nmap)\s+(-[sS]|--script|25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/i
25
+
26
+ // Data exfiltration with curl/wget to external URLs
27
+ $data_exfiltration_tools = /\b(wget|curl)\s+(http[s]?:\/\/[^\s]+|ftp:\/\/[^\s]+|-[oO]\s|--output\s)/i
28
+
29
+ // Reverse shell patterns (high severity)
30
+ $reverse_shells = /\b(bash\s+-i|sh\s+-i|nc\s+-e|\/dev\/tcp\/[0-9]+\.|socat.*exec|python.*socket.*connect)\b/i
31
+
32
+ // Shell command chaining with suspicious patterns
33
+ $shell_chaining = /[|&;]\s*(rm\s+-rf|dd\s+if=|chmod\s+777|wget\s+http|curl\s+http)/
34
+
35
+ condition:
36
+
37
+ // Dangerous system command patterns
38
+ $dangerous_system_cmds or
39
+
40
+ // Network tool abuse patterns
41
+ $malicious_network_tools or
42
+
43
+ // Reconnaissance tools
44
+ $reconnaissance_tools or
45
+
46
+ // Data exfiltration tools
47
+ $data_exfiltration_tools or
48
+
49
+ // Reverse shell patterns
50
+ $reverse_shells or
51
+
52
+ // Shell command chaining
53
+ $shell_chaining
54
+ }
@@ -0,0 +1,115 @@
1
+ //////////////////////////////////////////
2
+ // Secrets Exposure Detection Rule
3
+ // Target: API keys and tokens, SSH keys and certificates, Environment variables, Database credentials
4
+ //////////////////////////////////////////
5
+
6
+ rule credential_harvesting{
7
+
8
+ meta:
9
+ author = "Cisco"
10
+ description = "Detects potential exposure of sensitive information like API keys, passwords, tokens, and certificates"
11
+ classification = "harmful"
12
+ threat_type = "CREDENTIAL HARVESTING"
13
+
14
+ strings:
15
+
16
+ ////////////////////////////////////////////////
17
+ //// Malicious action patterns (not just any file I/O)
18
+ ////////////////////////////////////////////////
19
+
20
+ // Actual malicious credential theft patterns
21
+ $credential_theft_actions = /\b(steal|grab|exfiltrate|leak|transmit|post.*http|curl.*http|wget.*http)\b[^\n]*(credential|password|key|token|secret|ssh|aws)/i
22
+
23
+ // Network transfer with credentials
24
+ $network_credential_transfer = /\b(requests\.(post|get|put)|urllib\.request|socket\.send|base64\.b64encode)\s*\([^\)]*\b(credential|password|key|token|secret|api_key|private_key)\b/i
25
+
26
+ ////////////////////////////////////////////////
27
+ //// All Content-key based credential patterns
28
+ ////////////////////////////////////////////////
29
+
30
+ // API credentials and authentication tokens
31
+ $api_credentials = /\b([Aa][Pp][Ii][\_\-]?[Kk][Ee][Yy].*[A-Za-z0-9]{16,512}|[Bb]earer\s+[A-Za-z0-9\-_]{16,}|AKIA[0-9A-Z]{16}|ghp_[A-Za-z0-9]{36}|sk-[A-Za-z0-9]{48})/
32
+
33
+ // SSH keys, certificates and credential file content (consolidated)
34
+ $key_certificate_content = /(-----BEGIN (RSA |OPENSSH |EC |DSA |CERTIFICATE|PRIVATE KEY|ENCRYPTED PRIVATE KEY)-----|ssh-(rsa|ed25519)\s+[A-Za-z0-9+\/=]{8})/
35
+
36
+ // AI/ML model API key names (very specific)
37
+ $ai_model_credential_names = /\b(OPENAI_API_KEY|ANTHROPIC_API_KEY|CLAUDE_API_KEY|GOOGLE_AI_KEY|GEMINI_API_KEY|COHERE_API_KEY|HUGGINGFACE_TOKEN|HF_TOKEN|TOGETHER_API_KEY|REPLICATE_API_TOKEN|MISTRAL_API_KEY)\s*=\s*['\"][A-Za-z0-9\-_]{20,}['\"]/
38
+
39
+ // Suspicious environment variable theft (not just reading)
40
+ $env_var_theft = /\b(os\.environ\s*\[\s*['\"]?(AWS_SECRET|API_KEY|SECRET_KEY|PASSWORD|TOKEN)['\"]?\s*\]|getenv\s*\(\s*['\"]?(AWS_SECRET|API_KEY|SECRET_KEY|PASSWORD)['\"]?\s*\))\s*.*\s*(requests\.|urllib\.|socket\.|print\(|sys\.stdout)/i
41
+
42
+ ////////////////////////////////////////////////
43
+ //// Specific credential file access (full paths only)
44
+ ////////////////////////////////////////////////
45
+
46
+ // Specific credential file paths with actual access
47
+ $credential_file_access = /\b(open|read)\s*\(\s*['\"]?\s*(~\/\.ssh\/id_rsa|~\/\.ssh\/id_dsa|~\/\.ssh\/id_ecdsa|~\/\.aws\/credentials|~\/\.kube\/config|\/etc\/passwd|\/etc\/shadow|~\/\.netrc|~\/\.pgpass|credentials\.json|service_account\.json|private_key\.pem)\b/i
48
+
49
+ // Hardcoded credential file paths in strings
50
+ $hardcoded_credential_paths = /['\"][\~\/]+(\.ssh\/id_rsa|\.ssh\/id_dsa|\.aws\/credentials|\.kube\/config|etc\/passwd|etc\/shadow)['\"]/
51
+
52
+ // Pattern for exfiltration action words
53
+ $leak_param = /\b(leak|exfiltrate|export|dump) [^\n]*(parameter|context|files?|credentials?|keys?|tokens?|secrets?)\b/i
54
+
55
+ // Base64 credential encoding patterns
56
+ $base64_credential_encoding = /\b(base64\s+encode [^\n]*credentials?|concatenate [^\n]*conversation\s+history)\b/i
57
+
58
+ // MCP-specific credential patterns
59
+ $mcp_credential_patterns = /\b(claude_desktop_config\.json|~\/\.cursor\/logs\/conversations|plaintext[^\n]*api[^\n]*key|-rw-r--r--[^\n]*password)\b/i
60
+
61
+ // WhatsApp exploit
62
+ $whatsapp_exploit = /\b(_get_all_messages[^\n]*messages\.db|forward[^\n]*message[^\n]*proxy[^\n]*number|whatsapp[^\n]*message[^\n]*history|contact[^\n]*list[^\n]*exfiltrat|reprogram[^\n]*agent[^\n]*interaction)\b/i
63
+
64
+ // Legitimate Python patterns to exclude
65
+ $python_imports = /\b(from|import)\s+(pathlib|typing|dataclasses|argparse|json|sys|os|re|collections|functools|itertools)/i
66
+ $python_type_hints = /\b(Dict|List|Tuple|Optional|Union|Path|Set|Callable|Any)\s*\[/
67
+ $function_definitions = /\bdef\s+(read|write|load|save|extract|process|parse|get|set)_\w+\s*\(/
68
+ $template_indicators = /(\bYOUR_API_KEY|\bREPLACE_WITH|\bINSERT_KEY|\.example|\.sample|\.template|<your|<insert|placeholder)/i
69
+
70
+ condition:
71
+
72
+ // Exclude legitimate Python code patterns
73
+ not $python_imports and
74
+ not $python_type_hints and
75
+ not $function_definitions and
76
+ not $template_indicators and
77
+
78
+ (
79
+ // Actual API credentials (keys, tokens)
80
+ $api_credentials or
81
+
82
+ // Actual SSH/private key content
83
+ $key_certificate_content or
84
+
85
+ // Specific credential file access
86
+ $credential_file_access or
87
+
88
+ // Hardcoded credential paths
89
+ $hardcoded_credential_paths or
90
+
91
+ // AI model API keys (very specific)
92
+ $ai_model_credential_names or
93
+
94
+ // Credential theft actions
95
+ $credential_theft_actions or
96
+
97
+ // Network credential transfer
98
+ $network_credential_transfer or
99
+
100
+ // Environment variable theft
101
+ $env_var_theft or
102
+
103
+ // Exfiltration attempts
104
+ $leak_param or
105
+
106
+ // Base64 credential encoding
107
+ $base64_credential_encoding or
108
+
109
+ // MCP-specific patterns
110
+ $mcp_credential_patterns or
111
+
112
+ // WhatsApp exploit
113
+ $whatsapp_exploit
114
+ )
115
+ }
@@ -0,0 +1,71 @@
1
+ //////////////////////////////////////////
2
+ // Prompt Injection Detection Rule
3
+ // Target: Instruction override patterns, Tool injection commands
4
+ //////////////////////////////////////////
5
+
6
+ rule prompt_injection{
7
+
8
+ meta:
9
+
10
+ author = "Cisco"
11
+ description = "Detects prompt strings used to override or force malicious tool calls"
12
+ classification = "harmful"
13
+ threat_type = "PROMPT INJECTION"
14
+
15
+ strings:
16
+
17
+ // Instruction override patterns (exclude Python type comments)
18
+ $instruction_overrides = /\b(Bypass|Dis\W?regard|Do not (follow|Obey)|Forget|Ignore)\s+((all|any|each|every|most|some)\s+(of\s+)?)?((your|the)\s)?(command|communication|conte[nx]t|conversation|data|guidelines|input|instruction|message|request|response|text)(s)?/i
19
+
20
+ // Legitimate patterns to exclude
21
+ $python_type_comment = /# type: ignore/
22
+ $legitimate_ignore = /ignore[_\s](case|whitespace|errors|warnings|deprecation)/i
23
+
24
+ // Tool injection commands
25
+ $tool_injection_commands = /\b(inject tool[_\s]calls?|now call function|use function)\b/i
26
+
27
+ // Shadow parameter names
28
+ $shadow_parameters = /\b(internalOnly|hiddenParam|shadowTool|bypassChecks|sandboxEscape)\b/i
29
+
30
+ // Hidden behavior instructions
31
+ $hidden_behavior = /\b(do\s+not\s+(mention|tell|execute)|tell\s+(the )?user\s+only\s+about|do\s+not\s+mention\s+this\s+to\s+user)\b/i
32
+
33
+ // Advanced command override patterns (from advanced analyzer)
34
+ $advanced_overrides = /\b(disregard\s+(all\s+)?safety\s+guidelines|forget\s+(everything|all)\s+(before|above)|system\s*prompt\s*override)\b/i
35
+
36
+ // Role redefinition attempts
37
+ $role_redefinition = /\bnew\s+(instructions|directive|guidelines)s?\s*:\s*you\s+are\b/i
38
+
39
+ // Privilege escalation patterns
40
+ $privilege_escalation = /\b(grant\s+(me\s+)?admin\s+(access|privileges?)|bypass\s+(all\s+)?security\s+checks?|elevated\s+permissions?\s+required|sudo\s+mode\s+enabled?|developer\s+mode\s+activated?)\b/i
41
+
42
+
43
+ condition:
44
+
45
+ // Exclude legitimate patterns
46
+ not $python_type_comment and
47
+ not $legitimate_ignore and
48
+
49
+ (
50
+ // Instruction overrides
51
+ $instruction_overrides or
52
+
53
+ // Tool injection commands
54
+ $tool_injection_commands or
55
+
56
+ // Shadow parameters
57
+ $shadow_parameters or
58
+
59
+ // Hidden behavior instructions
60
+ $hidden_behavior or
61
+
62
+ // Advanced command override patterns
63
+ $advanced_overrides or
64
+
65
+ // Role redefinition attempts
66
+ $role_redefinition or
67
+
68
+ // Privilege escalation patterns
69
+ $privilege_escalation
70
+ )
71
+ }
@@ -0,0 +1,83 @@
1
+ //////////////////////////////////////////
2
+ // Detects common scripting payloads (JS, VBScript, etc.) embeddings.
3
+ // Target: JavaScript, VBScript, or ActiveX payloads.
4
+ // (Event handlers or inline scripts)
5
+ //////////////////////////////////////////
6
+
7
+ rule script_injection{
8
+
9
+ meta:
10
+ author = "Cisco"
11
+ description = "Detects embedded scripting payloads (JS, VBScript, etc.) in MCP tool descriptions"
12
+ classification = "harmful"
13
+ threat_type = "INJECTION ATTACK"
14
+
15
+ strings:
16
+
17
+ // Script tags and protocol handlers (exclude XML namespaces)
18
+ $tags = /(<\/?script[^>]*>|javascript:)/i
19
+
20
+ // ALWAYS exclude (safe in all file types)
21
+ $xml_namespace = /(xmlns:script=|<script:module|<script:)/
22
+ $openoffice_xml = /openoffice\.org\/2000\/script/
23
+ $legitimate_cdn = /(cdnjs\.cloudflare\.com|cdn\.jsdelivr\.net|unpkg\.com)/i
24
+
25
+ // Only exclude in MARKDOWN files (risky in .py files!)
26
+ // Check for markdown-specific syntax
27
+ $markdown_heading = /^#\s+/
28
+ $markdown_list = /^\*\s+/
29
+ $markdown_code_block = /(```html|```javascript|```js)/i
30
+ $documentation_context = /(example.*html|artifact.*structure|template|single.*file)/i
31
+
32
+ // Execution functions
33
+ $execution_functions = /\b(setTimeout|Function|setInterval)\s*\(/i
34
+
35
+ // VBScript execution and Windows Script Host objects
36
+ $vbs_execution = /\b(vbscript|CreateObject|WScript\.Shell|Shell\.Application)\b/i
37
+
38
+ // VBScript dangerous functions (more specific to avoid false positives in docs)
39
+ $vbs_dangerous_functions = /\b(WScript\.Shell\.Exec|Shell\.Application\.ShellExecute|CreateObject.*Exec)\s*\(/i
40
+
41
+ // Base64 encoded script data URIs
42
+ $encoded_script_uris = /\bdata:(text\/html|application\/javascript);base64\b/i
43
+
44
+ // ANSI terminal deception patterns
45
+ $ansi_deception = /(\\x1[Bb]\[38;5;\d+|\\x1[Bb]\[2F\\x1[Bb]\[1G|\\x1[Bb]\[1;1H\\x1[Bb]\[0J|\\x1[Bb]\]8;;.*\\x1[Bb]\\|\\033\[[0-9;]*m|\\e\[[0-9;]*[mGKHF])/i
46
+
47
+ // Hidden instruction obfuscation
48
+ $hidden_obfuscation = /\b(padding.*push.*off.*screen|hidden.*scrollbar|overflow.*hidden.*instruction|invisible.*text.*color)\b/i
49
+
50
+ condition:
51
+
52
+ // ALWAYS exclude (safe everywhere)
53
+ not $xml_namespace and
54
+ not $openoffice_xml and
55
+ not $legitimate_cdn and
56
+
57
+ // Only exclude markdown patterns if file has markdown indicators
58
+ not (($markdown_heading or $markdown_list) and ($markdown_code_block or $documentation_context)) and
59
+
60
+ (
61
+ // Script tags and protocol handlers
62
+ $tags or
63
+
64
+ // Execution functions
65
+ $execution_functions or
66
+
67
+ // VBScript execution
68
+ $vbs_execution or
69
+
70
+ // VBScript dangerous functions
71
+ $vbs_dangerous_functions or
72
+
73
+ // Base64 encoded script URIs
74
+ $encoded_script_uris or
75
+
76
+ // ANSI terminal deception
77
+ $ansi_deception or
78
+
79
+ // Hidden instruction obfuscation
80
+ $hidden_obfuscation
81
+ )
82
+
83
+ }
@@ -0,0 +1,57 @@
1
+ //////////////////////////////////////////
2
+ // Skill Discovery Surface Abuse Detection
3
+ // Target: Over-broad descriptions, keyword baiting, activation manipulation
4
+ // For Claude Skills YAML frontmatter and descriptions
5
+ //////////////////////////////////////////
6
+
7
+ rule skill_discovery_abuse{
8
+
9
+ meta:
10
+ author = "Cisco"
11
+ description = "Detects manipulation of skill discovery to increase unwanted activation"
12
+ classification = "harmful"
13
+ threat_type = "SKILL DISCOVERY ABUSE"
14
+
15
+ strings:
16
+
17
+ // Over-broad capability claims
18
+ $overbroad_claims = /\b(can do (anything|everything)|general (purpose )?assistant|all-purpose|universal (tool|skill|helper)|always use (this|me)|default (tool|skill|assistant))\b/i
19
+
20
+ // Keyword baiting patterns - match same word repeated in comma lists
21
+ // Using explicit word patterns since YARA doesn't support backreferences
22
+ $keyword_stuffing_file = /\bfile\s*,\s*file\s*,\s*file\s*,\s*file\b/i
23
+ $keyword_stuffing_data = /\bdata\s*,\s*data\s*,\s*data\s*,\s*data\b/i
24
+ $keyword_stuffing_code = /\bcode\s*,\s*code\s*,\s*code\s*,\s*code\b/i
25
+
26
+ // Activation priority manipulation
27
+ $activation_priority = /\b(use (this|me) (first|before)|priority (skill|tool)|primary (tool|skill)|preferred (tool|skill|method)|call (this|me) (before|first))\b/i
28
+
29
+ // Impersonation patterns (beyond just Anthropic)
30
+ $trusted_impersonation = /\b(official|verified|trusted|certified|approved|endorsed|authentic|legitimate)\s+(skill|tool|extension|plugin|assistant)\b/i
31
+
32
+ // Over-promising descriptions (exclude comments and technical contexts)
33
+ $overpromising = /\b(100% (safe|secure|accurate)|guaranteed (to|that|when|if)|perfect|flawless|never (fails|errors)|always (works|succeeds))\b/i
34
+
35
+ // Hidden activation triggers
36
+ $hidden_triggers = /\b(secret (command|keyword)|hidden (feature|mode)|easter egg|backdoor (access|entry))\b/i
37
+
38
+ condition:
39
+
40
+ // Over-broad capability claims
41
+ $overbroad_claims or
42
+
43
+ // Keyword stuffing (same word repeated 4+ times)
44
+ $keyword_stuffing_file or $keyword_stuffing_data or $keyword_stuffing_code or
45
+
46
+ // Activation priority manipulation
47
+ $activation_priority or
48
+
49
+ // Trusted impersonation
50
+ $trusted_impersonation or
51
+
52
+ // Over-promising
53
+ $overpromising or
54
+
55
+ // Hidden triggers
56
+ $hidden_triggers
57
+ }
@@ -0,0 +1,73 @@
1
+ //////////////////////////////////////////
2
+ // SQL Injection Detection Rule
3
+ // Target: SQL keywords and operations, SQL tautologies and bypasses, Database-specific functions
4
+ //////////////////////////////////////////
5
+
6
+ rule sql_injection{
7
+
8
+ meta:
9
+ author = "Cisco"
10
+ description = "Detects SQL injection attack patterns including keywords, tautologies, and database functions"
11
+ classification = "harmful"
12
+ threat_type = "INJECTION ATTACK"
13
+
14
+ strings:
15
+
16
+ // SQL injection tautologies and bypasses - focus on actual injection payloads
17
+ $injection_tautologies = /(\bOR\s+['"]?1['"]?\s*=\s*['"]?1['"]?\s*(--|#|\/\*|;))/i
18
+
19
+ // Destructive SQL injections
20
+ $destructive_injections = /(';\s*DROP\s+TABLE|";\s*DROP\s+TABLE)/i
21
+
22
+ // Union-based SQL injection
23
+ $union_based_attacks = /(UNION\s+(ALL\s+)?SELECT|'\s*UNION\s+SELECT|"\s*UNION\s+SELECT)/i
24
+
25
+ // Time-based blind injection techniques (SQL context only)
26
+ $time_based_injections = /\b(SLEEP|WAITFOR\s+DELAY|BENCHMARK|pg_sleep)\s*\(/i
27
+
28
+ // Exclude Python sleep functions (not SQL injection)
29
+ $python_sleep = /(time\.sleep|asyncio\.sleep|threading\.[A-Za-z]*\.sleep)\s*\(/
30
+
31
+ // Error-based injection methods
32
+ $error_based_techniques = /\b(EXTRACTVALUE|UPDATEXML|EXP\(~\(SELECT|CAST)\s*\(/i
33
+
34
+ // Database-specific system objects in malicious contexts
35
+ $database_system_objects = /(\bSELECT [^;]*\b(information_schema|mysql\.user|all_tables|user_tables)\b|\bFROM\s+(information_schema|mysql\.user|dual|all_tables|user_tables)\b|LOAD_FILE\s*\(\s*['"][^'"]*\.(config|passwd|shadow|key)\b|INTO\s+OUTFILE\s+['"][^'"]*\.(txt|sql|php)\b|\b(xp_cmdshell|sp_executesql)\s*\(|dbms_[a-z_]+\s*\()/i
36
+
37
+ // SQL injection with USER() function in malicious context
38
+ $malicious_user_functions = /(\bUSER\s*\(\s*\)\s*(SELECT|FROM|WHERE|AND|OR|UNION)\b|CONCAT\s*\(\s*USER\s*\(\s*\))/i
39
+
40
+ // Common SQL operation patterns that appear in both legitimate and malicious contexts
41
+ $common_sql_ops = /(query_builder|sql_builder|orm_query|select_fields|insert_data|update_data|database_query|db_query|execute_query|prepared_statement|parameterized_query)/
42
+
43
+ // Common context phrases where these words appear in benign usage
44
+ $common_context_phrases = /\b(adds?\s+a\s+user|create\s+user|new\s+user|user\s+(account|profile|registration|authentication|permissions?|roles?)|user\s+(who|that)|for\s+user|the\s+user|current\s+user\s+(account|profile)|user\s+(input|data|information)|example:?\s+SELECT\s+USER\(\)|SELECT\s+USER\(\)\s+returns?|built-?in\s+function)\b/i
45
+
46
+ condition:
47
+
48
+ // Exclude Python sleep functions from all checks
49
+ not $python_sleep and (
50
+
51
+ // SQL injection tautologies
52
+ ($injection_tautologies and not $common_sql_ops and not $common_context_phrases) or
53
+
54
+ // Destructive SQL injections
55
+ ($destructive_injections and not $common_sql_ops and not $common_context_phrases) or
56
+
57
+ // Union-based attacks
58
+ ($union_based_attacks and not $common_sql_ops and not $common_context_phrases) or
59
+
60
+ // Time-based blind injection
61
+ ($time_based_injections and not $common_sql_ops and not $common_context_phrases) or
62
+
63
+ // Error-based injection techniques
64
+ ($error_based_techniques and not $common_sql_ops and not $common_context_phrases) or
65
+
66
+ // Database system object access
67
+ ($database_system_objects and not $common_sql_ops and not $common_context_phrases) or
68
+
69
+ // Malicious USER() function usage
70
+ ($malicious_user_functions and not $common_sql_ops and not $common_context_phrases)
71
+
72
+ )
73
+ }
@@ -0,0 +1,65 @@
1
+ //////////////////////////////////////////
2
+ // System Manipulation and Privilege Escalation Detection
3
+ // Target: File destruction and manipulation operations
4
+ // (Process control and termination)
5
+ //////////////////////////////////////////
6
+
7
+ rule system_manipulation{
8
+
9
+ meta:
10
+ author = "Cisco"
11
+ description = "Detects system manipulation, privilege escalation, and destructive file operations"
12
+ classification = "harmful"
13
+ threat_type = "SYSTEM MANIPULATION"
14
+
15
+ strings:
16
+ // Suspicious environment variable manipulation (not just reading)
17
+ $env_var_manipulation = /\b(os\.environ\s*\[[^\]]*\]\s*=|export\s+PATH=|unset\s+(PATH|HOME|USER))\b/i
18
+
19
+ // File destruction and manipulation
20
+ $file_destruction = /\b(rm\s+-rf|dd\s+if=\/dev\/zero|wipefs|shred\s+-|find\s+[^\n]+-delete)\b/i
21
+
22
+ // Dangerous file permission changes
23
+ $permission_manipulation = /\b(chmod\s+(777|4755|6755|[ug]?\+s)|(chown|chgrp)\s+(root|0)|setuid|setgid)\b/i
24
+
25
+ // Critical system file access
26
+ $critical_system_access = /\b(\/etc\/(passwd|shadow|sudoers)|\/root\/\.ssh|~\/\.aws\/credentials|~\/\.ssh\/id_rsa)\b/i
27
+
28
+ // Privilege escalation patterns
29
+ $privilege_escalation = /\b(sudo\s+-[si]|su\s+-c?|runuser|doas)\b/i
30
+
31
+ // Dangerous process operations
32
+ $process_manipulation = /\b(kill\s+-9\s+[0-9]+|killall\s+-9|pkill\s+-9)\b/i
33
+
34
+ // Dangerous recursive operations with wildcards
35
+ $recursive_operations = /\b(rm\s+-rf\s+[\$\/\*]|find\s+\/\s+-delete)\b/i
36
+
37
+ // System path manipulation
38
+ $path_manipulation = /\b(PATH=\/tmp|PATH=\.:|export\s+PATH=[\$\{])/i
39
+
40
+ condition:
41
+
42
+ // Environment variable manipulation (not just reading)
43
+ $env_var_manipulation or
44
+
45
+ // File destruction
46
+ $file_destruction or
47
+
48
+ // Permission manipulation
49
+ $permission_manipulation or
50
+
51
+ // Critical system access
52
+ $critical_system_access or
53
+
54
+ // Privilege escalation
55
+ $privilege_escalation or
56
+
57
+ // Process manipulation
58
+ $process_manipulation or
59
+
60
+ // Recursive operations
61
+ $recursive_operations or
62
+
63
+ // PATH manipulation
64
+ $path_manipulation
65
+ }