T09 · Insecure Skill Coding Practices
- Location
scripts/gitea_api.py:15- Finding
Environment Gitea Token Disclosure Through Payload-Controlled Server URL
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill mostly fits its KB maintenance purpose, but it can expose the Gitea bot token if an input payload redirects authenticated requests.
Review before installing. This should only run with trusted payload inputs or after changing the Gitea client so authenticated requests use a trusted configured HTTPS origin and allowed owner/repo, not payload-provided destinations. Use a least-privileged bot token limited to the intended KB repository, and rotate the token if untrusted payloads may already have been used.
scripts/gitea_api.py:15Environment Gitea Token Disclosure Through Payload-Controlled Server URL
The declared description is narrowly about scheduled maintenance of six team overview pages plus hidden status files, with careful avoidance of ordinary page rewrites. The supplied code instead is a generic catalog/index module. It manipulates a catalog.json-like structure, processes arbitrary page entries, normalizes relations across many page categories, and renders a broad 'Knowledge Base Index' markdown document. This is a materially different primary purpose from maintaining only six overview pages. While both relate to a knowledge base, the implementation shown lacks the declared maintenance behavior, change inspection logic, status-file writing, and scope limitation to overview pages.
The declared description promises substantive KB maintenance behavior involving reading existing team KB content, reasoning over recent changes, selectively updating overview pages, and writing status files. The actual code chunk contains only a minimal setup script that verifies Python 3 is installed and echoes a readiness message. This is materially different from the declared primary purpose and lacks the described capabilities entirely.
The skill declares access to environment variables, filesystem reads/writes, and network-reachable Gitea operations, but does not declare an explicit tool/permission scope. In an agent setting, missing scope boundaries increases the chance of over-broad access, misuse of secrets such as GITEA_BOT_TOKEN, or unintended writes beyond the intended maintenance workflow.
The primary operational instructions begin under a Chinese heading and continue in Chinese, which imposes a language requirement on operators or downstream agents. The file does not offer a language choice or explain that the skill is intentionally limited to a Chinese-language environment.
This code performs remote repository content creation or modification via PUT requests to the Gitea API, which can change persistent project data. There is no confirmation prompt, user-facing log message, or explanatory comment/docstring in this file warning that calling these methods will write to the repository.
The overview target metadata hard-codes user-facing titles such as "团队总览" and related labels in Chinese. Under the policy, locale-specific language is a violation unless the skill offers user opt-in or clearly documents that the tool is intentionally region-specific, which this file does not do.
The manifest says this skill should incrementally update only the six overview pages and write hidden maintenance status files, while avoiding rewriting ordinary knowledge pages. Here, after overview-page changes, the code also rewrites top-level shared metadata files catalog.json and index.md, which extends behavior beyond the stated 'only the six overview pages' plus hidden status files scope.
The validation text states that kb_maintenance may only write fixed overview pages, presenting a stricter intent than the implementation actually follows. Elsewhere in the file, the code writes catalog.json, index.md, and hidden maintenance status/run-history files, so the inline intent communicated by this message is contradicted by actual behavior.
This code reads multiple values from environment variables, including platform and repository identifiers, and silently incorporates them into the payload. There is no confirmation prompt, logging, comment, or docstring disclosing that runtime behavior depends on environment-provided data.
The function creates parent directories and writes JSON output to a caller-supplied path, but the code provides no prompt, log message, comment, or docstring indicating that it will modify the filesystem. For a code-file review under this rule, file writes should have some visible disclosure unless already documented elsewhere.