T09 · Insecure Skill Coding Practices
- Location
scar_code_review.py:115- Finding
Untrusted Persistent Regular Expressions Can Cause Denial of Service
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a local code-review helper with disclosed file reading and scar-record storage, with some implementation cautions but no evidence of hidden, destructive, or exfiltrating behavior.
Install only if you want a local Python code-review helper that reads files you point it at and stores review scars in a JSONL file. Treat scar files as trusted configuration, since their regex patterns are executed by Python's regex engine, and be cautious reviewing attacker-controlled code in an interactive terminal until output escaping is improved.
scar_code_review.py:115Untrusted Persistent Regular Expressions Can Cause Denial of Service
scar_code_review.py:529Attacker-Controlled Terminal Escape Sequences Are Printed Without Sanitization
Model output is used without validation or sanitization. Unvalidated output injected into downstream contexts (SQL, shell, HTML) enables injection attacks and arbitrary code execution.
assert any("XSS" in f["message"] for f in findings)
def test_dangerously_set(self):
lines = ['<div dangerouslySetInnerHTML={{__html: data}} />']
findings = _check_security(lines)
assert any("XSS" in f["message"] for f in findings)
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).
assert any("eval" in f["message"].lower() for f in findings)
def test_subprocess_shell(self):
lines = ['subprocess.run(cmd, shell=True)']
findings = _check_security(lines)
assert any("eval" in f["message"].lower() or "shell" in f["message"].lower()
for f in findings)
The skill exposes code execution capabilities through Python-based review workflows and explicitly supports reading files, writing scar records, and processing diffs, yet it declares no tool scope restrictions. Without explicit permissions or allowed-tools boundaries, an agent may grant broader access than necessary, increasing the blast radius if the skill is misused or prompt-injected into operating on sensitive files or invoking shell/network functionality.
This Python file performs a file-creation and append operation on the scar database JSONL file. Although the function docstring explains that a scar is recorded, there is no inline warning, confirmation, or user-facing disclosure near the write operation itself, and this operation modifies local user data.
The docstring and implementation explicitly restrict keyword extraction to English words and Japanese characters only. This is a natural-language policy concern because it bakes in language handling assumptions without offering the user any opt-in, configuration, or explanation for excluding other languages.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
class TestCLI:
def test_cli_review(self):
src = _write_temp_file('password = "hunter2"\n')
result = subprocess.run(
[sys.executable, str(Path(__file__).parent / "scar_code_review.py"),
"review", src],
capture_output=True, text=True,
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
script = str(Path(__file__).parent / "scar_code_review.py")
# Record
result = subprocess.run(
[sys.executable, script, "--scar-file", scar_file,
"record-miss", "--what-missed", "test miss",
"--pattern", "test.*pattern", "--severity", "high"],
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
assert "SCAR RECORDED" in result.stdout
# List
result = subprocess.run(
[sys.executable, script, "--scar-file", scar_file, "list-scars"],
capture_output=True, text=True,
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def test_cli_no_command(self):
script = str(Path(__file__).parent / "scar_code_review.py")
result = subprocess.run(
[sys.executable, script],
capture_output=True, text=True,
)