T09 · Insecure Skill Coding Practices
- Location
scripts/gitea_api.py:16- Finding
Payload-Controlled Gitea Endpoint Can Exfiltrate the Repository Bot Token
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly matches its Feishu-to-knowledge-base purpose, but task-controlled inputs can redirect credentials or cause local files to be archived too broadly.
Install only in a controlled environment where payloads and apply contexts are trusted. Before use, bind GITEA_BOT_TOKEN to an administrator-configured Gitea origin, reject payload-selected repository URLs, restrict archived source paths to the prepare workspace, protect Feishu token cache permissions, and use least-privilege Feishu/Gitea credentials.
scripts/gitea_api.py:16Payload-Controlled Gitea Endpoint Can Exfiltrate the Repository Bot Token
scripts/kb_writer.py:246Untrusted Apply Context Can Cause Arbitrary Local Files to Be Uploaded to Gitea
scripts/feishu_platform.py:50Feishu Tenant Access Token Is Cached in Plaintext Without Enforced File Permissions
The declared purpose centers on Feishu data collection and ingestion into a research knowledge base. The supplied code chunk is a local utility for catalog management: it loads raw JSON, derives page types from paths, constructs normalized catalog entries, merges page metadata, enforces relation/path constraints, creates reciprocal graph relationships, and renders a markdown index. It does not interact with Feishu APIs, network resources, chat messages, external documents, or ingestion workflows. This is a materially different primary purpose, so the description does not accurately represent the code.
The code chunk does not perform any Feishu polling, message/resource downloading, document/wiki/sheet reading, content evaluation, or prepare/apply ingestion logic described in the skill purpose. Instead, it is a repository client for Gitea that reads and upserts files and updates catalog/index metadata in a KB repo. While writing to a KB could be part of a larger ingestion pipeline, this specific code's primary behavior is direct Gitea repository file management, which is a materially different and undeclared capability relative to the supplied description.
This code chunk’s behavior does not match the declared end-to-end Feishu collection and KB-ingestion purpose. Instead, it is a generic helper module for extracting text previews from local files. While such a utility could support a larger ingestion pipeline by previewing downloaded attachments, the supplied chunk itself only performs local file parsing and formatting. It lacks any Feishu-specific access, message polling, doc/wiki/sheet/bitable reading through Feishu services, chat-segment evaluation, or prepare/apply ingestion workflow. Therefore this chunk is materially different from the declared primary purpose and should be flagged as a mismatch.
The skill describes capabilities that rely on environment variables, filesystem access, network calls, and repository writes, but it does not declare any explicit tool scope or permission boundaries. This creates an authorization ambiguity where an agent may invoke the skill without clear consent or least-privilege constraints, which is especially risky because the workflow reads chat history, downloads documents, and writes to a knowledge base.
The manifest description is broad enough to encourage invocation in many contexts without clear trigger conditions, while the skill can scan chat history, download resources, and write to a KB. Overbroad invocation language increases the chance of accidental use on sensitive data sources or use without the user appreciating the privacy and write implications.
The description does not prominently warn that the skill will write generated content into a persistent Gitea knowledge base and archive source materials. In this context, silent persistence is dangerous because users may expect analysis only, while the skill actually performs durable repository mutations that can expose confidential chat-derived data to a broader audience.
The operational instructions and content requirements are entirely in Chinese, and the skill does not mention any user language preference, opt-in, or locale limitation. This can amount to an implicit language policy constraint if the skill expects or forces operation in Chinese without user choice.
The skill is designed to scan Feishu group history and download message resources and documents, but the user-facing description lacks a strong privacy warning about this collection behavior. In a chat-ingestion context, that materially increases risk because it may process sensitive conversations, attachments, and linked documents beyond what a user expects from a generic 'ingest' skill.
The manifest description grants a broadly capable ingestion workflow: polling chats, downloading resources, reading cloud documents, judging retention value, and writing into a KB, but it does not state any activation constraints, scope limits, or approval boundaries. In a skill that has access to Feishu content and a KB write path, vague triggering increases the risk of over-collection or unintended execution on sensitive conversations and documents.
This file uses Chinese-only natural-language messages such as the credential error at L069, and similar Chinese strings appear throughout the file. That imposes a specific language on users without opt-in or any documented justification for a Chinese-only locale.
The code stores the Feishu tenant access token in a local JSON cache file under a path that may be shared or broadly readable, without setting restrictive permissions or documenting this persistence. If another local user, process, or skill can read that directory, the token could be reused to access Feishu data until expiry.
The function downloads message resources from Feishu and writes the returned bytes to a filesystem path, which is a safety-relevant file write. The code does not provide any confirmation, user-visible logging, or inline documentation explaining that external content will be saved locally.
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
data = api_bytes(payload, "GET", endpoint, query={"type": resource_type})
target = Path(output_path)
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(data)
return str(target)
This code persists compiled message segments and referenced Feishu documents to the local work directory using write_text, and also downloads attachments earlier in the flow. There is no confirmation prompt, print/log disclosure, or inline warning to indicate that chat content and linked documents will be stored on disk, which is a privacy-relevant operation involving user data.
The reset_work_root function unconditionally removes the resolved task work directory with shutil.rmtree when it exists. Although there is a basic path safety check, the operation is destructive and there is no user-facing notice, confirmation, or comment warning that prior locally stored ingestion artifacts will be deleted.
The manifest describes polling Feishu, reading source materials, judging preservation value, and ingesting into a Research KB through a prepare/apply workflow. This file directly creates or updates files in a Gitea repository, including catalog.json and index.md, which is a concrete repository mutation capability not mentioned in the manifest description of this skill file's behavior.
The upsert_bytes method performs remote file creation or modification via a PUT request to the Gitea contents API, which can change repository state. In this file there is no confirmation prompt, logging/print statement, or explanatory comment/docstring disclosing that repository contents will be written when this method is invoked.
The file hardcodes Chinese labels such as 相关概念, 相关资源, 相关代码页, and 相关页面, and later injects a Chinese section heading ## 关联页面 plus Chinese registration text for archived sources. This imposes a specific output language in generated content without offering a language choice or documenting a justified locale constraint.
This function writes generated content to repository paths via client.upsert_text for page files, catalog.json, and index.md, and also archives source files with client.upsert_bytes, but the file contains no confirmation prompt, user-facing log/print, or warning comment/docstring disclosing these side effects. Because these operations modify persisted knowledge-base content and store source artifacts, users may not be explicitly informed that data will be written and archived.
The natural-language description is tightly bound to Feishu group messages and Feishu cloud documents, which can reflect a platform- or locale-specific constraint, but the manifest text does not state that this limitation is intentional or user-selected. Under the policy rule, locale or language constraints should be explicitly justified or offered as a choice when relevant.
The manifest scope is centered on Feishu collection and KB ingestion workflow, but this file additionally pulls external SCM endpoint and bot credentials from environment variables. While possibly operationally useful, this credential-loading and repository-target discovery capability is not explicitly justified by the stated purpose and broadens the skill's operational reach.
The client reads sensitive configuration including GITEA_BOT_TOKEN from environment variables to authenticate API requests. This file does not include any user-facing warning, comment, or docstring indicating that credentials will be consumed from the environment.
The string literal returned for archive listings begins with Chinese text, which imposes a specific language in user-visible output. The file does not provide any user opt-in, locale selection, or documentation justifying a fixed Chinese locale.
The regexes in slugify, extract_keywords, and query_tokens explicitly support Chinese characters and Latin-alphanumeric tokens while excluding many other scripts, which can amount to an implicit language/locale constraint. There is no nearby natural-language documentation explaining this limitation, offering user choice, or justifying a region-specific scope.
The function creates parent directories and writes JSON content to an arbitrary path, which is a file-modifying operation. In this file there is no confirmation prompt, logging/print statement, or explanatory comment/docstring disclosing that the function will create directories and overwrite file contents.