T09 · Insecure Skill Coding Practices
- Location
xhs-keepalive.py:229- Finding
Authenticated Browser State Is Saved Without Restrictive File Permissions
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill appears to perform the advertised Xiaohongshu scraping, but it requires live login cookies and persists session/token data with weak containment.
Install only if you are comfortable giving the skill a live Xiaohongshu session. Prefer a dedicated account, keep cookie and data directories outside shared repos/backups, enforce owner-only permissions, delete data/state/token caches after use, and avoid running it on shared hosts or CI logs where command arguments and output may be captured.
xhs-keepalive.py:229Authenticated Browser State Is Saved Without Restrictive File Permissions
xhs-harvest.py:247Session-Derived Access Tokens and Authenticated Content Are Persisted With Default Permissions
xhs-fetch.py:334Short-Lived Access Tokens Are Exposed in Process Arguments and Console Output
docs/pitfalls.md:58Troubleshooting Guidance Uses Overly Broad Forced Process Termination
The skill metadata understates sensitive behaviors such as session/cookie management, local credential file handling, and anti-abuse/risk checks, while the documented core operations depend on those mechanisms. When a skill omits these security-relevant behaviors from its declared purpose, operators may enable it without understanding that it processes authenticated session material and persistent local state.
The skill metadata understates sensitive behaviors such as session/cookie management, local credential file handling, and anti-abuse/risk checks, while the documented core operations depend on those mechanisms. When a skill omits these security-relevant behaviors from its declared purpose, operators may enable it without understanding that it processes authenticated session material and persistent local state.
The skill explicitly requires users to supply authenticated Xiaohongshu cookies and browser fingerprint values so the tool can reuse a live logged-in session. Reusing session tokens outside the browser creates a high-value credential handling path: leakage of these files or logs could enable account takeover, impersonation, or abuse of the user's authenticated access.
The setup instructions tell users to copy all browser cookies via developer tools and save them into a local file consumed by the skill. This encourages bulk extraction of sensitive session material, potentially including more tokens than necessary, and normalizes unsafe credential handling that could expose the account if the file is read, backed up insecurely, or exfiltrated by another tool.
Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
# 1. 看 IP / 城市
curl -s "https://ipinfo.io/json" | python3 -m json.tool | head -10
# 2. 看 agent-browser 当前 cookies
agent-browser cookies get
The document is written primarily in Chinese and does not offer an English alternative or indicate that the skill is intentionally limited to a Chinese-speaking contributor base for a documented regional reason. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy concern.
The file's instructional and descriptive content is written entirely in Chinese, including contributor guidance, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-only audience. Under the stated policy, forcing a specific language without user opt-in is a natural-language policy violation.
The README explicitly instructs users to export live Xiaohongshu authentication cookies from their browser and store them locally in a plaintext file. Those cookies appear sufficient to impersonate the user session, so compromise of the file, accidental inclusion in logs/backups, or reuse by the skill beyond user expectations could enable account takeover or access to private account data.
The skill declares no explicit tool scope or permission boundaries despite clearly requiring environment access, filesystem reads/writes, network access, and shell execution. In an agent setting, this weakens least-privilege controls and makes it easier for the skill to be invoked with broader capabilities than users may reasonably expect.
The manifest description is entirely in Chinese and presents the skill purpose and requirements only in that language. Under the policy, locale or language constraints should not be imposed without user opt-in or a clearly documented justification, and this file does not offer either.
The operational instructions, warnings, examples, and troubleshooting sections are all presented only in Chinese. This creates a natural-language policy issue because users are not offered a language choice, and no explicit justification for a Chinese-only interface is stated.
The entire skill document is written in Chinese and includes user-facing operational guidance without any indication that language selection is optional or that the skill is intended only for a Chinese-speaking audience. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation.
The script automatically checks for and loads authenticated browser cookies into agent-browser without a clear runtime warning or consent step. In a skill explicitly designed to scrape Xiaohongshu using a logged-in session, this creates real credential/privacy risk because the tool can act with the user's authenticated account and access account-linked content.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
r = run(['agent-browser', 'cookies', 'get'], timeout=10)
if not r.stdout.strip() or 'web_session' not in r.stdout:
print("Loading cookies into agent-browser...")
subprocess.run(
['python3', str(Path(__file__).parent / 'xhs-keepalive.py'), 'load'],
timeout=30
)
The code reads document.cookie and extracts a session-linked user identifier from the browser context to influence scraping logic. Even though it only targets a specific cookie value, accessing browser cookies from automation code is sensitive and can expose or misuse authenticated session metadata without clear disclosure.
This Python file contains user-facing natural-language instructions, help text, status output, and report content entirely in Chinese, starting from the module docstring and continuing through the CLI experience. Under the policy rule, forcing a specific language without offering the user a language/locale option is a natural-language policy violation.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
不要在 stdout/stderr 里字符串 grep (脆弱,fetch 改字面量 harvest 就漏判)。
"""
cmd = ['python3', str(FETCH_SCRIPT)] + args
r = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
return r.returncode, r.stdout, r.stderr
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
不要在 stdout/stderr 里字符串 grep (脆弱,fetch 改字面量 harvest 就漏判)。
"""
cmd = ['python3', str(FETCH_SCRIPT)] + args
r = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
return r.returncode, r.stdout, r.stderr
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
注意:
- 不依赖任何第三方库 (除 agent-browser 自身)
- cookies 必须 chmod 600 (含 web_session + id_token 等敏感字段)
- xhs cookie 6-12 小时会失效 (web_session 短效),需要定期重导
"""
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
注意:
- 不依赖任何第三方库 (除 agent-browser 自身)
- cookies 必须 chmod 600 (含 web_session + id_token 等敏感字段)
- xhs cookie 6-12 小时会失效 (web_session 短效),需要定期重导
"""
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
注意:
- 不依赖任何第三方库 (除 agent-browser 自身)
- cookies 必须 chmod 600 (含 web_session + id_token 等敏感字段)
- xhs cookie 6-12 小时会失效 (web_session 短效),需要定期重导
"""
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
注意:
- 不依赖任何第三方库 (除 agent-browser 自身)
- cookies 必须 chmod 600 (含 web_session + id_token 等敏感字段)
- xhs cookie 6-12 小时会失效 (web_session 短效),需要定期重导
"""
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
注意:
- 不依赖任何第三方库 (除 agent-browser 自身)
- cookies 必须 chmod 600 (含 web_session + id_token 等敏感字段)
- xhs cookie 6-12 小时会失效 (web_session 短效),需要定期重导
"""
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
return 1
# 清掉旧的
subprocess.run(['agent-browser', 'cookies', 'clear'],
capture_output=True, text=True)
# 读 Netscape
The subprocess call itself is safely parameterized, but it forwards sensitive cookie names and values into command-line arguments. On many systems, command-line arguments can be exposed to other local processes/users through process listings, logs, crash reports, or audit tooling, which can leak authenticated session tokens such as web_session and id_token.
continue
domain, include_subdomain, path, secure, expires, name, value = parts[:7]
flags = _cookie_to_agent_browser_flags(name)
r = subprocess.run(
['agent-browser', 'cookies', 'set', name, value] + flags,
capture_output=True, text=True
)