T09 · Insecure Skill Coding Practices
- Location
modules/email_fetcher.py:18- Finding
Arbitrary File Write Through an Untrusted Email Attachment Filename
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill does what it claims, but it handles email credentials, untrusted ZIP attachments, student code, and grading records with unsafe scoping and validation.
Review before installing. Use only a dedicated QQ mailbox and app-specific authorization code, process mail only from trusted senders, and run this skill in an isolated workspace with no sensitive files or host credentials. Do not rely on the generated grades without review, because student submissions can influence the AI prompt. The ZIP download and extraction code should be fixed before production use.
modules/email_fetcher.py:18Arbitrary File Write Through an Untrusted Email Attachment Filename
modules/extractor.py:4Unsafe Extraction of Untrusted ZIP Archives
modules/ai_grader.py:16Student-Controlled Prompt Injection Can Manipulate AI Grades
modules/grader.py:4Grading Module Can Execute Untrusted Student Python Without Isolation
modules/excel_writer.py:4Untrusted Grading Data Can Be Exported as Spreadsheet Formulas
requirements.txt:1Unpinned Dependencies and an Undeclared Runtime Package
This grader runs student-provided Python files without any warning, sandboxing, or security controls beyond a timeout. In the context of a grading skill, the input is explicitly adversarial or at least untrusted, so executing submissions directly can lead to arbitrary code execution on the grading machine and compromise of other students' data or platform infrastructure.
The skill declares email_user and email_auth_code as inputs but provides no warning about sensitivity, no guidance on secure handling, and no indication that a mailbox authorization code will be used to authenticate to QQ Mail. Collecting email credentials without disclosure materially increases the risk of credential misuse, accidental exposure in logs, or overbroad mailbox access.
The function retrieves email attachments using email_user and email_auth_code, which indicates access to sensitive credentials and mailbox contents. In this file there is no confirmation prompt, user-facing notice, or explanatory comment/docstring disclosing that the skill will access the user's email account.
The function recursively reads all Python files from both the student and template directories and includes their full contents in a prompt sent to an external LLM API. That creates a real source-code exfiltration path: student submissions, reference solutions, embedded secrets, or proprietary grading material may be disclosed to a third party without minimization, consent, or access controls.
The natural-language prompt requires the model to grade and respond in Chinese, including fixed Chinese field labels. This enforces a specific language/locale without any user opt-in or documented justification, which is a natural-language policy concern.
The code sends the student and template code to an external API but provides no user-facing warning, consent mechanism, or in-file indication that local source code leaves the system. In an educational context this is sensitive because submissions and answer keys may be confidential, and undisclosed transfer increases privacy, compliance, and trust risks.
The function logs into a real mailbox using supplied credentials/auth code and enumerates unread messages without any visible disclosure, access scoping, or consent checks. In an agent skill context, silent access to a user's inbox is sensitive because it enables collection of private email content and attachments beyond what a user may reasonably expect.
The code automatically writes unseen email ZIP attachments to local storage with no validation, user notification, or consent flow. This creates a risky ingestion path for untrusted content and can expose the host to malware staging, disk abuse, or downstream processing of attacker-controlled files.
This extraction code writes files from an untrusted ZIP archive directly to disk using extractall() without validating member paths. A crafted archive can perform path traversal (Zip Slip) and overwrite files outside the intended extraction directory, potentially leading to arbitrary file overwrite and code or configuration tampering; the lack of user-facing disclosure is secondary to this more serious unsafe extraction behavior.
The code executes a Python file in a subprocess based on a path discovered from the student directory, which means untrusted student code is intentionally run by the grader. Even without shell=True, this is dangerous because the executed code can read files, exfiltrate secrets, consume resources, or attack the host environment; the 5-second timeout only limits runtime and does not provide isolation.
def run_code(file_path):
try:
result = subprocess.run(
["python", file_path],
capture_output=True,
text=True,
The workflow states that ZIP attachments are downloaded, extracted, and used to generate local Excel output, but it does not warn about the filesystem risks of extracting archives or writing files locally. ZIP extraction can expose the host to malicious archive contents such as path traversal or oversized payloads, while output generation may overwrite or create sensitive files unexpectedly.
The skill requests QQ email credentials and processes attachments from a mailbox, but it does not warn users about the sensitivity of the authorization code or the risks of automatically downloading content from email. This can lead users to provide credentials without understanding exposure risks, and to ingest potentially malicious attachments from untrusted or spoofed senders.
The manifest states that the skill will automatically download homework from a QQ mailbox and generate an Excel file, but it does not disclose mailbox access scope, what data will be read, where attachments or outputs will be stored, or what user consent is expected. This creates a real security and privacy risk because users may provide access credentials without understanding that the skill will access potentially sensitive email content and write files to disk.
The skill extracts archives from email attachments without any visible validation or sandboxing before processing. If the unzip helper does not defend against path traversal, zip bombs, or unsafe file types, a crafted attachment could overwrite files or exhaust disk resources on the local system.
The call to save_to_excel(results, assignment_id) persists student names, IDs, scores, and comments to a file. There is no visible warning, prompt, or comment in this file informing the user that graded student data will be stored locally.
Reading an API credential from the environment is access to sensitive configuration. In this file there is no comment, docstring, or user-visible message explaining that a credential is required and will be used for external API access.
The regular expression requires filenames containing the Chinese phrase "第...次作业", which imposes a specific language/locale convention. The file provides no natural-language justification or opt-in indicating that this parser is intentionally limited to a Chinese-language regional workflow.
This code writes user-provided data to an .xlsx file on disk, which is a file-write operation covered by the missing-warning rule for code files. There is no confirmation prompt, logging/print statement, or explanatory docstring/comment disclosing that the function creates output under data/results.
The dependency 'pandas' is unpinned, so installations may resolve to different versions over time, reducing build reproducibility and potentially pulling in a vulnerable or breaking release unexpectedly. In a security context, lack of version pinning weakens supply-chain control even though the file itself does not prove exploitation.
pandas
openpyxl
The manifest references 'pandas' without a version pin, and known advisories exist for some releases, so it is impossible to verify from this file whether deployment will select an affected version. The risk is contextual and indirect here: the issue is uncertainty and potential exposure, not confirmation that a vulnerable version is in use.
The dependency 'openpyxl' is unpinned, which allows future installs to fetch any currently available version and makes the environment non-reproducible. This increases supply-chain risk because a vulnerable or incompatible version could be installed without explicit review.
pandas
openpyxl
The manifest references 'openpyxl' without pinning a version, while known advisories affect some historical releases, so the actual security posture cannot be verified from this file alone. Because openpyxl commonly processes spreadsheet/XML content, using an affected version could matter if the skill handles untrusted files.
The natural-language instructions and labels are written in Chinese, which effectively forces a specific language for users without any opt-in or alternative language option. The policy allows locale constraints when they are documented and justified, but this file does not state that the skill is intentionally limited to Chinese-speaking users or a China-specific environment.
The only natural-language description is written in Chinese and presents the skill behavior without indicating language options or that the skill is specifically limited to a Chinese-language context. Under the policy, forcing a specific language or locale without opt-in can be a natural-language policy concern.