Back to skill

Security audit

Cs Qweather Jwtgen

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed QWeather JWT token generator, with some avoidable credential-handling and logging risks users should understand.

Install only if you are comfortable letting the skill read your QWeather private key and QWeather identifiers, overwrite ~/.myjwtkey/last-token.dat, and create masked logs under /tmp/cslog. Keep ~/.openclaw/.env and ~/.myjwtkey/ed25519-private.pem private and user-owned; avoid storing unrelated secrets in the shared .env file if this skill will run unchanged.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (2)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/generateJWTtoken.py:22
Finding

Shared credential file is loaded without variable-level least-privilege controls

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/generateJWTtoken.py:41
Finding

Predictable log file in a shared temporary directory permits symlink-based file access

Content
View full analysis
str: """获取日志文件路径,每天一个文件,放在 /tmp/cslog/ 目录中。""" log_dir = "/tmp/cslog" os.makedirs(log_dir, exist_ok=True) today = datetime.now().strftime("%Y%m%d") return os.path.join(log_dir, f"generateJWTtoken-{today}.log") def _log(msg: str) -> None: """写入日志文件并在 stderr 打印。""" ts = datetime.now().strftime("%H:%M:%S") line = f"[{ts}] {msg}" log_path = _get_log_path() with open(log_path, "a", encoding="utf-8") as f: f.write(line + "\n") print(line, file=sys.stderr) ``` ### Technical Analysis The script uses the globally predictable directory `/tmp/cslog` and a date-derived filename. It creates and opens the file without checking: - Whether the directory is owned by the invoking user. - Whether the log path is a symbolic link. - Whether the target is a regular file. - Whether an existing file has safe ownership and permissions. Python's normal `open(..., "a")` follows symbolic links. If an attacker can pre-create `/tmp/cslog` or write into an existing insecurely configured instance of that directory, the attacker can place a symbolic link at the expected daily filename. A subsequent invocation then appends log messages to the link target with the privileges of the invoking process. The file is not created with an explicit `0600` mode. Its initial permissions depend on the process umask, potentially making masked identifiers and operational metadata visible to other local users. ### Attack Path 1. A local attacker predicts the filename, such as `/tmp/cslog/generateJWTtoken-20260916.log`. 2. Before the victim runs the Skill, the attacker creates `/tmp/cslog` if it does not already exist and places a symbolic link at the predicted log path. 3. The symbolic link points to a file writable by the victim ...[truncated 1295 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (8)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/generateJWTtoken.py (reported line 5)May include surrounding context.

python
"""
生成和风天气 JWT Token 的工具。

环境变量(支持从 ~/.openclaw/.env 自动加载):
    QWEATHER_SUB  和风账户的用户标识(sub 字段)
    QWEATHER_KID  和风账户的密钥 ID(kid 字段)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/generateJWTtoken.py (reported line 22)May include surrounding context.

python
"""
生成和风天气 JWT Token 的工具。

环境变量(支持从 ~/.openclaw/.env 自动加载):
    QWEATHER_SUB  和风账户的用户标识(sub 字段)
    QWEATHER_KID  和风账户的密钥 ID(kid 字段)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/generateJWTtoken.py (reported line 93)May include surrounding context.

python
"""
生成和风天气 JWT Token 的工具。

环境变量(支持从 ~/.openclaw/.env 自动加载):
    QWEATHER_SUB  和风账户的用户标识(sub 字段)
    QWEATHER_KID  和风账户的密钥 ID(kid 字段)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/generateJWTtoken.py (reported line 101)May include surrounding context.

python
"""
生成和风天气 JWT Token 的工具。

环境变量(支持从 ~/.openclaw/.env 自动加载):
    QWEATHER_SUB  和风账户的用户标识(sub 字段)
    QWEATHER_KID  和风账户的密钥 ID(kid 字段)

Credential Access

High
Category
Privilege Escalation
Confidence
83% confidence
Finding

The script loads secrets from '~/.openclaw/.env' with override=True, which forcibly replaces existing environment variables with values from a local file. If that file is writable by another local user/process or symlinked, the script could be tricked into using attacker-controlled identifiers, causing token generation under unexpected identities or operational misuse; automatic secret loading also broadens the trusted input surface.

Content

Scanner excerpt · scripts/generateJWTtoken.py (reported line 27)May include surrounding context.

python
import dotenv
    # 优先加载 ~/.openclaw/.env(OpenClaw 标准配置位置)
    # 若 OpenClaw 已将 env 注入了当前进程,此调用不会覆盖已存在的变量
    dotenv.load_dotenv(os.path.expanduser("~/.openclaw/.env"), override=True)
except ImportError:
    # 未安装 dotenv 时跳过,完全依赖环境继承
    pass

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill documents and invokes capabilities that access environment variables, read a private key from disk, write a token to disk, and execute a shell command, but it does not declare any tool scope or permission boundaries. In an agent environment, this weakens least-privilege controls and can allow broader-than-expected access to secrets and filesystem state, increasing the blast radius if the skill is misused or compromised.

Content

No source excerpt is available for this finding.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · SKILL.md (reported line 39)May include surrounding context.

必须位于 ~/.myjwtkey/ed25519-private.pem,权限应为 600。

bash
chmod 600 ~/.myjwtkey/ed25519-private.pem

Token 输出文件

Tainted flow: 'token_file' from os.environ.get (line 125, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · scripts/generateJWTtoken.py (reported line 68)May include surrounding context.

python
"""将 token 写入 ~/.myjwtkey/last-token.dat,返回文件路径。"""
    token_file = os.path.expanduser("~/.myjwtkey/last-token.dat")
    os.makedirs(os.path.dirname(token_file), exist_ok=True)
    with open(token_file, "w", encoding="utf-8") as f:
        f.write(token)
    os.chmod(token_file, 0o600)
    return token_file