T09 · Insecure Skill Coding Practices
- Location
scripts/guardrails.py:103- Finding
Caller-Controlled Flags Can Authorize Critical Operations
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This safety skill is not clearly malicious, but its promised guardrail is too easy to bypass and it adds unnecessary persistent learning data, so users should review it before relying on it.
Do not rely on this skill as a sole safety boundary for autonomous command execution. It should be reviewed or fixed so critical actions are non-overridable by caller-provided flags, unknown commands fail closed, audit logs are truly durable if advertised, and the learner is removed or made explicitly opt-in with clear retention and deletion controls.
scripts/guardrails.py:103Caller-Controlled Flags Can Authorize Critical Operations
scripts/guardrails.py:126Security Audit Records Are Not Persisted Across Processes
scripts/guardrails.py:26Raw Regular-Expression Classification Allows Dangerous Command Variants to Bypass the Gate
This skill claims to be a pre-execution safety gate, but the documented content also introduces a generic learning subsystem and does not provide verifiable implementation of the promised guardrail behavior. In unattended automation, such a description-behavior mismatch is dangerous because users may rely on the skill to block destructive actions when it may instead only record usage data, creating a false sense of protection.
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
## 内置规则(可扩展)
- DENY:`rm -rf`、`format`、`dd if=...of=/dev`、`shutdown/reboot`、`mkfs`、无条件 `drop/truncate`、
`git push --force`、`git reset --hard`、fork 炸弹、`curl|bash`/`wget|sh` 下载即执行。
- CONFIRM:`rm -`、删除/更新/插入/改表、对外发送/upload/post、提权、安装依赖、终止进程、部署发布、资金转移。
## 用法
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
rm -rf、format、dd if=...of=/dev、shutdown/reboot、mkfs、无条件 drop/truncate、
git push --force、git reset --hard、fork 炸弹、curl|bash/wget|sh 下载即执行。rm -、删除/更新/插入/改表、对外发送/upload/post、提权、安装依赖、终止进程、部署发布、资金转移。Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
用法:
python guardrails.py --selftest
python guardrails.py --action "rm -rf /data" --context '{"user_approved":false}'
python guardrails.py --audit # 打印当前审计日志
"""
import argparse
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
用法:
python guardrails.py --selftest
python guardrails.py --action "rm -rf /data" --context '{"user_approved":false}'
python guardrails.py --audit # 打印当前审计日志
"""
import argparse
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
用法:
python guardrails.py --selftest
python guardrails.py --action "rm -rf /data" --context '{"user_approved":false}'
python guardrails.py --audit # 打印当前审计日志
"""
import argparse
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
用法:
python guardrails.py --selftest
python guardrails.py --action "rm -rf /data" --context '{"user_approved":false}'
python guardrails.py --audit # 打印当前审计日志
"""
import argparse
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
ok = True
# 1) 危险动作被拦截
d, n, _ = gate("rm -rf /data/important", {})
assert d == "DENY", f"期望 DENY,实际 {d}: {n}"
print("[1] 危险递归删除 -> DENY ✓")
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
ok = True
# 1) 危险动作被拦截
d, n, _ = gate("rm -rf /data/important", {})
assert d == "DENY", f"期望 DENY,实际 {d}: {n}"
print("[1] 危险递归删除 -> DENY ✓")
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
print("[1] 危险递归删除 -> DENY ✓")
# 2) 中危需确认(未授权)
d, n, _ = gate("delete /tmp/cache", {})
assert d == "CONFIRM", f"期望 CONFIRM,实际 {d}: {n}"
print("[2] 删除操作未授权 -> CONFIRM ✓")
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
print("[1] 危险递归删除 -> DENY ✓")
# 2) 中危需确认(未授权)
d, n, _ = gate("delete /tmp/cache", {})
assert d == "CONFIRM", f"期望 CONFIRM,实际 {d}: {n}"
print("[2] 删除操作未授权 -> CONFIRM ✓")
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
print("[1] 危险递归删除 -> DENY ✓")
# 2) 中危需确认(未授权)
d, n, _ = gate("delete /tmp/cache", {})
assert d == "CONFIRM", f"期望 CONFIRM,实际 {d}: {n}"
print("[2] 删除操作未授权 -> CONFIRM ✓")
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
print("[4] 只读动作 -> ALLOW ✓")
# 5) 强推未经授权必须拦截(绝不无条件 ALLOW)
d, n, _ = gate("git push --force origin main", {})
assert d == "DENY", f"force push 无授权应 DENY,实际 {d}: {n}"
print(f"[5] 强推无授权 -> DENY ✓")
Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).
print("[4] 只读动作 -> ALLOW ✓")
# 5) 强推未经授权必须拦截(绝不无条件 ALLOW)
d, n, _ = gate("git push --force origin main", {})
assert d == "DENY", f"force push 无授权应 DENY,实际 {d}: {n}"
print(f"[5] 强推无授权 -> DENY ✓")
The file implements a generic cross-skill 'self-evolution' telemetry/learning component rather than a narrowly scoped pre-execution safety guardrail. In the context of a safety-filter skill, this capability expansion is dangerous because it introduces persistent behavior tracking and future prompt/skill modification guidance that is unrelated to the declared purpose, increasing attack surface and enabling silent collection of operational metadata.
The script persistently stores capability usage, failures, notes, recurring errors, and arbitrary user preferences to disk, which is not justified for a pre-execution safety filter. If sensitive commands, error notes, or personal preferences are recorded, this creates an unnecessary privacy and security exposure, especially in unattended automation where data may accumulate silently over time.
The manifest describes behavior that writes persistent data (learned_patterns.json and audit logs) but does not declare any tool scope or permissions boundaries. In an autonomous-agent context, undeclared write capability undermines least privilege and prevents operators from understanding or constraining what the skill can modify.
The trigger phrases are broad and overlap with common language, increasing the chance that the skill activates in contexts where it was not intended. In autonomous or semi-automatic systems, overbroad activation can cause unexpected interception, logging, or memory writes, and may alter workflows without clear operator intent.
A safety-gate skill should have a narrowly scoped purpose, but this manifest adds a self-evolution/learning subsystem unrelated to action-risk gating. That scope expansion increases attack surface and operational ambiguity, especially in privileged automation flows where a guardrail component is expected to be deterministic and minimal.
The documentation directs the skill to collect and persist user preferences, usage history, error notes, and improvements even though those data are not necessary for a safety-guardrails function. Unnecessary retention creates privacy and data-handling risk, and in multi-session agent environments it can influence future actions based on stale or sensitive context.
The learning module stores free-form preferences, notes, and error details in plain-language memory, which can easily capture sensitive user or operational data and reuse it later. In agent systems, this creates a cross-session data leakage risk and can expose secrets, personal data, or internal workflow details through later outputs or compromise of local files.
This Python file contains its module docstring, comments describing usage, and CLI help/output text entirely in Chinese, which imposes a specific language on users. The file does not offer any language selection, fallback, or indicate that the skill is intentionally region-specific.
The code and documentation claim audit records are persisted ('落盘'), but _AUDIT is only an in-memory list. In an unattended guardrail skill, this undermines forensicability and accountability because decisions disappear on process exit or restart, making it easier for dangerous actions to occur without durable audit evidence.
The code writes learned_patterns.json containing user preferences and operation notes without any user-facing warning or consent flow. This is dangerous because notes and preferences can contain sensitive operational context, and silent persistence undermines user expectations and can leak data to other local users, backups, or later processes.
The skill instructs storing a user's language preference for future reuse without clearly framing that storage as optional or requiring explicit consent. Even low-sensitivity preferences become problematic when silently persisted across sessions, particularly in systems expected to minimize retained user data.