T09 · Insecure Skill Coding Practices
- Location
scripts/attributor.py:125- Finding
Arbitrary Python Code Execution Through Untrusted Prediction Module Loading
- Content
View full analysis
Vulnerability Details
File Location:
scripts/attributor.py:125-126
Vulnerability Type: Arbitrary code execution through unrestricted dynamic evaluation
Risk Level: HighVulnerable Code
python ns = {}; exec(compile(open(a.predict, encoding="utf-8").read(), a.predict, "exec"), ns) predict = ns["predict"]Technical Analysis
The
--predictcommand-line argument controls the path passed toopen(). The application reads the entire selected Python file, compiles it, and executes it withexec()in the current process. Execution is not restricted to the expectedpredict(r)function: all top-level statements in the supplied file run immediately.No source validation, capability restriction, sandbox, integrity check, or trust confirmation is applied. Consequently, a prediction module obtained from an untrusted source can execute arbitrary Python operations with the same operating-system identity and environment as the attribution process.
Attack Path
- An attacker creates or modifies a Python file that defines the expected
predictfunction but also contains malicious top-level statements. - The attacker persuades a user or automated Agent to use that file as the documented
--predictinput:bash python scripts/attributor.py --data d.json --predict malicious.py --instance i.json - The application reads and executes the complete contents of
malicious.pyat line 125. - The malicious statements execute before the attribution workflow calls
predict. - The file may still provide a legitimate-looking
predictfunction and attribution output, concealing the side effects.
Impact Assessment
Successful exploitation provides arbitrary code execution with the privileges of the process running the Skill. Depending on that account's permissions and environment, an attacker could read or modify accessible files, obtain environment variables or locally available ...[truncated 224 chars]
- An attacker creates or modifies a Python file that defines the expected
- Remediation
View remediation
Remediation Suggestions
- Prefer a declarative, non-executable model format rather than accepting arbitrary Python source files.
- If custom prediction logic is required, run it in a separate, disposable process with a narrow JSON input/output protocol.
- Apply operating-system sandboxing to that process, including a dedicated unprivileged identity, a read-only filesystem where possible, strict resource limits, and denied network access.
- Use an explicit allowlist for files or plugins and verify their cryptographic hashes or signatures before execution.
- Clearly warn users that Python prediction files are executable programs, not passive model data, and require explicit confirmation before loading untrusted files.
- Do not treat restricted
exec()globals as a sufficient security boundary; Python evaluation requires process-level isolation for hostile code. - Add a security test that supplies a prediction file with a top-level side effect and verifies that the main attribution process cannot execute that side effect.
