T09 · Insecure Skill Coding Practices
- Location
scripts/gitea_api.py:12- Finding
Gitea Bot Token Can Be Disclosed to a Payload-Controlled Server
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly matches its stated Research KB web-query purpose, but it handles credentials, attachment paths, and output paths without enough containment.
Review before installing. Only use this skill where payloads are produced by a trusted backend, GITEA_BOT_TOKEN is least-privilege and read-only if possible, Gitea host/repo values are fixed or allowlisted, attachment paths are constrained to an upload directory, and result paths are confined to a task workspace.
scripts/gitea_api.py:12Gitea Bot Token Can Be Disclosed to a Payload-Controlled Server
scripts/query_context.py:285Payload-Controlled Attachment Paths Allow Arbitrary Local-File Reads
scripts/run_task.py:95Unrestricted Output Paths Allow Overwriting Process-Writable Files
The declared purpose is a question-answering skill that performs guided web search, produces external citations, may attach references, and avoids persisting Q&A. The supplied code does none of that. Instead, it operates entirely on local catalog/page metadata for a knowledge base: loading JSON, filtering system/hidden pages, building catalog entries, merging entries, normalizing related page paths, and rendering an index markdown page. There is no dialogue handling, no web search, no citation generation, no attachment handling, and no evident QA-specific non-persistence logic. This is a materially different primary purpose, so it is a clear mismatch.
The declared description is about answering dialogue questions through guided web search with citations and optional attachments, explicitly stating no QA persistence. The supplied code does none of that: it is a storage/integration component for Gitea that can read files, test for existence, and upsert text content into a repository via authenticated API calls. The persistent write behavior is especially at odds with the declared 'no QA persistence' claim. This is a material description-behavior mismatch, not merely a supporting implementation detail.
This code chunk is a low-level serialization/input-output helper module, not a KB-answering or web-search skill implementation. Its capabilities are limited to parsing JSON payloads, repairing common JSON formatting issues, extracting JSON from fenced text, escaping control characters, and writing structured result envelopes to disk/stdout. Those behaviors are materially different from the declared end-user purpose. While file I/O utilities can be supporting infrastructure, the absence of any visible logic for search, dialogue response generation, citations, attachments, or QA workflow means the supplied code does not accurately represent the declared description.
This code chunk does not implement Research KB question answering or team-guided web search. Instead, its primary function is to read local files and extract preview text from supported formats, including Office documents and source/config/text files. That is a materially different behavior and introduces undeclared local file access/document parsing capabilities not reflected in the description. The absence of the declared search/citation/dialogue behavior and presence of unrelated file-extraction behavior indicate a clear mismatch.
The declared purpose focuses on a dialogue-answering skill driven by web search and citations with no persistence. This code chunk does not implement that primary behavior; instead it provides low-level utilities for local content handling and indexing-like operations. Most of these helpers could be supporting implementation details, but the inclusion of local file reading and safe path sanitization indicates access to local KB/doc resources, which is not reflected in the declared description or permissions. Because the actual code behavior centers on utility functions for local document processing rather than the stated QA/web-search flow, this is a description-behavior mismatch.
This file implements authenticated write access to a Gitea repository via upsert_text, which can create or modify repository contents. That capability is materially inconsistent with a skill described as a web-query tool with no QA persistence, increasing the risk of unauthorized data persistence, tampering, or covert exfiltration through repository writes.
The skill declares no explicit tool restrictions even though its instructions require environment access, local file reads/writes, and network operations. In an agent setting, missing scoped permissions increases the chance the runtime grants broader capabilities than necessary, enabling unintended data access or exfiltration if the skill or upstream inputs are abused.
The example schema explicitly requires the answer to be a '完整中文回答', which imposes a specific language on responses. The file does not indicate that users can choose another language or that this skill is limited to a Chinese-only context for compliance or regional reasons.
The code loads a bot token from environment variables and configures a client that can perform authenticated repository operations, including remote writes. In the context of a web-query-only skill, these hidden credentials and mutation capabilities expand the trust boundary unnecessarily and could be abused to alter stored knowledge or persist sensitive material.
This file accesses a sensitive credential via GITEA_BOT_TOKEN and uses it in Authorization headers for outbound API calls. There is no user-facing notice, logging, or inline documentation here warning that the skill uses stored credentials to authenticate network operations.
The code performs repository writes without any local indication that user interactions may trigger persistent remote changes. Lack of disclosure is dangerous because operators and users may reasonably assume the skill only performs web research, while it can silently modify external state and leave durable artifacts.
The file hard-codes Chinese natural-language output strings for the reference section heading and default source notices. This creates a locale/language policy issue because generated output is forced into a specific language with no user opt-in or documented region-specific justification.
The function constructs user-visible section titles such as "团队上下文" and "外部资料" directly in Chinese. Because these labels are always injected into the final answer, the skill imposes a fixed locale without opt-in or justification.
The returned context embeds compacted conversation history, including message content and source metadata, for later processing. Because this forwards prior user/assistant content into downstream analysis and possible web-query planning, the file should provide some visible disclosure or documented warning about reuse of conversation data.
The function reads text previews from attachment storage paths and includes that content in the returned context object. This transmits user-provided file content into downstream agent processing, but there is no confirmation prompt, visible user-facing log/print, or code comment warning about this privacy-relevant behavior.
This Python file includes a hardcoded natural-language fallback response in Chinese when answer recovery fails. Because the file does not offer a language/locale option or justify a Chinese-only response, it violates the language/locale policy criterion for natural-language policy violations.