T09 · Insecure Skill Coding Practices
- Location
中华大藏经定位.py:28- Finding
Plaintext Storage of an Authenticated Session Cookie
- Content
View full analysis
Vulnerability Details
File Location:
中华大藏经定位.py, lines 28-35 and 145-150
Vulnerability Type: Plaintext sensitive credential storage
Risk Level: Mediumpython def 取Cookie(): env = os.environ.get("FO_COOKIE", "").strip() if env: return env p = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fo_cookie.txt") if os.path.exists(p): return open(p, encoding="utf-8").read().strip() return ""The script also explicitly recommends the insecure fallback:
python print(" 1) 浏览器 F12 → Application → Cookies → 复制 fo.ancientbooks.cn 的 Cookie 整串;") print(" 2) 设环境变量: set FO_COOKIE=粘贴的Cookie (或写入本目录 fo_cookie.txt)")Technical Analysis
The optional authenticated locator accepts the user's complete
fo.ancientbooks.cnsession cookie fromfo_cookie.txt, a plaintext file stored in the Skill directory. The implementation neither checks nor enforces owner-only file permissions and provides no integration with a protected operating-system credential store.Session cookies are bearer credentials: possession may be sufficient to act as the authenticated user. Storing one beside source files increases the likelihood that it will be accidentally committed to source control, included in an archive, synchronized to shared storage, captured by a backup, or read by another local account or process.
The reviewed code transmits the cookie only to the declared HTTPS host and contains no evidence of intentional credential exfiltration. The vulnerability is the insecure local storage option, not malicious transmission.
Attack Path
- A user follows the script's instructions and copies their complete authenticated cookie into
fo_cookie.txt. - The project directory is committed, archived, synchronized, backed up, shared, or accessed by another local process or user.
- An attacker obtains the plaintext cookie from the exposed file.
- The attacke ...[truncated 712 chars]
- A user follows the script's instructions and copies their complete authenticated cookie into
- Remediation
View remediation
Remediation Suggestions
- Remove the project-local
fo_cookie.txtfallback and accept the credential only through a process-scoped secret mechanism or operating-system credential store. - If file-based input must remain supported:
- Require an explicit path outside the project directory.
- Reject files with permissions broader than owner read/write.
- Document the file as a sensitive bearer credential.
- Add
fo_cookie.txtto source-control and packaging ignore rules. - Refuse symbolic links and verify file ownership before reading.
- Prefer a narrowly scoped API token over a complete browser cookie if the service supports one.
- Avoid asking users to copy an entire browser cookie string when only a particular session value is required.
- Ensure credentials never appear in logs, errors, command output, generated reports, or subprocess argument lists.
- Advise users to revoke the session immediately if the file may have been exposed.
- Consider disabling the optional authenticated integration by default and requiring explicit user consent before credential use.
- Remove the project-local
