T09 · Insecure Skill Coding Practices
- Location
tools/plot_interactive.py:55- Finding
Arbitrary Code Execution Through Unrestricted Evaluation of Function Expressions
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a coherent calculus teaching aid, but its plotting tool can execute user-provided function text as Python code.
Review before installing. The skill appears intended for calculus education, but do not use it with untrusted function inputs until the plotting code replaces eval with a safe math-expression parser and narrows tool permissions. Pin dependencies before production or classroom deployment.
tools/plot_interactive.py:55Arbitrary Code Execution Through Unrestricted Evaluation of Function Expressions
requirements.txt:4Non-Reproducible Dependency Resolution Due to Open-Ended Version Constraints
声明描述的是一个较完整的微积分概念学习助手,重点在多表征、动态可视化、交互演示、认知诊断和即时检测。实际代码只包含检测题模板与生成逻辑,确实与“即时检测”这一子功能相关,但没有任何可视化、GeoGebra 集成、诊断分析、学习路径调整或交互教学实现。因此代码只覆盖了声明中的一小部分,而且其主要可见行为更接近‘测验生成器’而非‘概念理解助手’。这属于描述与实际行为的实质性不匹配。
This path evaluates an untrusted function string directly as Python code via eval. Because the function parameter is externally controllable, an attacker can supply payloads that perform arbitrary computation or side effects when the plotting function is invoked.
x = x[x != a] # 排除间断点
try:
f = eval(f"lambda x: {function_str}")
y = f(x)
except:
y = np.sin(x)/x
Executing user-supplied function strings as Python code introduces a general-purpose execution primitive unrelated to the educational plotting task. In skill contexts, this is especially dangerous because users expect mathematical input handling, not arbitrary interpreter access.
This code file evaluates the user-controlled function parameter directly via eval, which is a safety-critical code-execution operation. Although the module has docstrings describing plotting behavior, there is no warning, confirmation, or visible disclosure that arbitrary expressions will be executed as Python code.
The derivative animation code turns user input into executable Python with eval, so each frame generation may run attacker-supplied code. Since this occurs inside a loop, a malicious expression could repeatedly trigger side effects or resource abuse, increasing operational risk.
fig, ax = plt.subplots(figsize=(8, 6))
x = np.linspace(-2, 4, 200)
f = eval(f"lambda x: {function_str}")
y = f(x)
ax.plot(x, y, 'b-', linewidth=2, label='f(x)')
This finding is valid because the derivative animation path also grants arbitrary code execution via the function parameter. The repeated frame-generation behavior can amplify impact through repeated execution, denial of service, or repeated access attempts.
The derivative animation routine also constructs and executes a lambda from the user-provided function string. This is equivalent to executing arbitrary code from input, yet the code provides no prompt, log, or explanatory comment disclosing that behavior.
The code builds a Python lambda from a user-controlled string using eval, which allows arbitrary Python expressions to execute in the process running the skill. In a visualization tool, this grants code-execution capability far beyond the intended purpose of plotting mathematical functions, enabling file access, environment inspection, or command execution depending on runtime permissions.
fig, ax = plt.subplots(figsize=(10, 6))
f = eval(f"lambda x: {function_str}")
# 绘制函数
x_smooth = np.linspace(a, b, 200)
The Riemann-sum path evaluates arbitrary Python from user input even though only numeric function plotting is needed. That unjustified capability expansion makes the skill materially more dangerous than its declared calculus-visualization purpose.
This plotting branch executes the function parameter through eval, creating a code-execution path from user input. There is no user-facing warning, confirmation, or documentation in this file indicating that arbitrary Python expressions will be run.
The Taylor comparison feature evaluates a user-controlled expression using eval, exposing arbitrary code execution under the application's privileges. The surrounding try/except does not mitigate the issue because malicious code may execute before any exception is raised.
x = np.linspace(-np.pi, np.pi, 200)
try:
f = eval(f"lambda x: {function_str}")
y_exact = f(x)
except:
y_exact = np.sin(x)
The Taylor-comparison feature exposes the same unsafe execution behavior, allowing code to run during what should be a harmless educational plot request. Skill context makes this more concerning because the feature appears benign and may therefore receive less scrutiny from operators and users.
The Taylor comparison function executes the user-provided expression by building a lambda with eval. Because this is a safety-critical execution of untrusted input and the file gives no user disclosure about it, it meets the missing-warning criterion for code files.
This markdown file presents the skill as a Chinese-language assistant from the title onward and all user-facing usage examples are in Chinese, without stating that other languages are supported or that Chinese is optional. Under the language/locale policy, forcing a specific language without user opt-in is a natural-language policy violation.
The configuration enables automatic saving of generated visualizations without any visible disclosure, consent, or path restrictions. In an agent with file operation capability, this can cause unexpected local file writes, privacy issues, and accumulation of artifacts even if the educational purpose is legitimate.
The template headings and instructional content are written in Chinese and the output format later also requires Chinese phrasing, which implies the skill operates in a fixed language. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly justified.
The prompt instructions, examples, and output expectations are all in Chinese, which effectively forces a specific language for use of the skill. Under the policy, language constraints should either be user-selectable or explicitly justified as region- or audience-specific.
The system prompt is written entirely in Chinese and defines the assistant role and behavior only in that language, which implies a fixed language/locale expectation. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the constraint is explicitly justified or optional.
Suspicious Unicode normalization or mixed-script content
This code file contains natural-language documentation entirely in Chinese and describes the skill as a general misconception-diagnosis system, but it does not indicate that Chinese is optional or that the tool is intentionally limited to a Chinese-speaking context. Under the locale policy rule, forcing a specific language without opt-in is a policy concern.
The skill constructs user-facing question text in Chinese regardless of user preference or environment. Because the file does not provide any mechanism for selecting another language or explain a justified regional restriction, this is a natural-language locale policy violation.
Suspicious Unicode normalization or mixed-script content
This code file contains natural-language descriptions entirely in Chinese and presents the skill purpose and authoring context in that language without any indication that users can choose another language or that the skill is intentionally region-specific. Under the policy rule, forcing a specific language without user opt-in is a natural-language locale violation.
Suspicious Unicode normalization or mixed-script content
This Python file contains natural-language descriptions that force a specific language/locale for the skill experience, including the module description and later user-facing output text. The policy allows locale constraints only when users are offered a choice or the restriction is clearly documented and justified, which is not present here.