T05 · Unauthorized Access and Privilege Escalation
- Location
query_events.py:57- Finding
Overbroad Parsing of a Shared Credential File
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill does what it says, but it handles sensitive device-event data and API credentials through a shared, mutable configuration file with weak destination controls.
Review this skill before installing. Use only a least-privilege, revocable API key; keep ~/.openclaw/.env permission-restricted; confirm AI_GATEWAY_HOST is the intended trusted HTTPS gateway; do not disable TLS verification in production; avoid passing the API key on the command line; and avoid storing unrelated secrets in the shared OpenClaw .env file.
query_events.py:57Overbroad Parsing of a Shared Credential File
query_events.py:101Bearer Credential Disclosure Through Configurable Host and Optional TLS Verification
query_events.py:141API Key Exposure Through Command-Line Arguments
SKILL.md:49Unpinned Third-Party Dependency Installation Guidance
The skill explicitly depends on a shared plaintext credential file at ~/.openclaw/.env that is readable by all skills under the same user. In a multi-skill agent environment, this creates a strong credential-theft and lateral-movement risk because any compromised or malicious skill with file-read access can harvest the API key and reuse it against the gateway.
openclaw:
requires:
bins: ["python3"]
configPaths: ["~/.openclaw/.env"]
primaryEnv: "AI_GATEWAY_API_KEY"
---
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
`POST /api/event/query` is an AI-powered event query API that supports natural language queries and returns an AI summary and event list.
## ⚠️ Display Rules (MUST be strictly followed)
The script outputs structured data in JSON format, which is the expected behavior. The display rules below are formatting instructions for the agent: the agent MUST parse the JSON output from the script, convert it into a user-friendly format according to the following rules before displaying it, and MUST NOT display the raw JSON directly.
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.
## ⚠️ Display Rules (MUST be strictly followed)
The script outputs structured data in JSON format, which is the expected behavior. The display rules below are formatting instructions for the agent: the agent MUST parse the JSON output from the script, convert it into a user-friendly format according to the following rules before displaying it, and MUST NOT display the raw JSON directly.
1. When `code == 0` and `data.events` is not empty:
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
脚本只负责调用接口和裁剪数据,展示逻辑由 agent 根据 SKILL.md 规则完成。
配置来源(统一规则):
- 持久化:~/.openclaw/.env (OpenClaw 客户端的"设置 API Key"会自动写入此文件)
- 临时覆盖:仅 API_KEY 支持命令行 --api-key,覆盖 .env 中的同名配置
- 不再读取任何 AI_GATEWAY_* 环境变量
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
脚本只负责调用接口和裁剪数据,展示逻辑由 agent 根据 SKILL.md 规则完成。
配置来源(统一规则):
- 持久化:~/.openclaw/.env (OpenClaw 客户端的"设置 API Key"会自动写入此文件)
- 临时覆盖:仅 API_KEY 支持命令行 --api-key,覆盖 .env 中的同名配置
- 不再读取任何 AI_GATEWAY_* 环境变量
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
脚本只负责调用接口和裁剪数据,展示逻辑由 agent 根据 SKILL.md 规则完成。
配置来源(统一规则):
- 持久化:~/.openclaw/.env (OpenClaw 客户端的"设置 API Key"会自动写入此文件)
- 临时覆盖:仅 API_KEY 支持命令行 --api-key,覆盖 .env 中的同名配置
- 不再读取任何 AI_GATEWAY_* 环境变量
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
脚本只负责调用接口和裁剪数据,展示逻辑由 agent 根据 SKILL.md 规则完成。
配置来源(统一规则):
- 持久化:~/.openclaw/.env (OpenClaw 客户端的"设置 API Key"会自动写入此文件)
- 临时覆盖:仅 API_KEY 支持命令行 --api-key,覆盖 .env 中的同名配置
- 不再读取任何 AI_GATEWAY_* 环境变量
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
脚本只负责调用接口和裁剪数据,展示逻辑由 agent 根据 SKILL.md 规则完成。
配置来源(统一规则):
- 持久化:~/.openclaw/.env (OpenClaw 客户端的"设置 API Key"会自动写入此文件)
- 临时覆盖:仅 API_KEY 支持命令行 --api-key,覆盖 .env 中的同名配置
- 不再读取任何 AI_GATEWAY_* 环境变量
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
脚本只负责调用接口和裁剪数据,展示逻辑由 agent 根据 SKILL.md 规则完成。
配置来源(统一规则):
- 持久化:~/.openclaw/.env (OpenClaw 客户端的"设置 API Key"会自动写入此文件)
- 临时覆盖:仅 API_KEY 支持命令行 --api-key,覆盖 .env 中的同名配置
- 不再读取任何 AI_GATEWAY_* 环境变量
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
脚本只负责调用接口和裁剪数据,展示逻辑由 agent 根据 SKILL.md 规则完成。
配置来源(统一规则):
- 持久化:~/.openclaw/.env (OpenClaw 客户端的"设置 API Key"会自动写入此文件)
- 临时覆盖:仅 API_KEY 支持命令行 --api-key,覆盖 .env 中的同名配置
- 不再读取任何 AI_GATEWAY_* 环境变量
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
从 ~/.openclaw/.env 文件加载配置。
这是 OpenClaw 客户端写入的持久化真值源,由所有 skill 共享。
"""
env_path = Path.home() / ".openclaw" / ".env"
if not env_path.exists():
return {}
result = {}
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
从 ~/.openclaw/.env 文件加载配置。
这是 OpenClaw 客户端写入的持久化真值源,由所有 skill 共享。
"""
env_path = Path.home() / ".openclaw" / ".env"
if not env_path.exists():
return {}
result = {}
Allowing the API host to be sourced from a shared ~/.openclaw/.env file means any actor who can modify that file can redirect authenticated requests to an attacker-controlled endpoint. Because the script sends the bearer token in the Authorization header, this can lead to credential exfiltration and disclosure of queried event data, especially dangerous in a skill context that handles surveillance/event information.
def get_api_host(env_vars):
"""
获取网关地址:~/.openclaw/.env 中的 AI_GATEWAY_HOST,未配置则用默认值。
"""
host = env_vars.get("AI_GATEWAY_HOST")
return host.rstrip("/") if host else DEFAULT_API_HOST
Reading AI_GATEWAY_VERIFY_SSL from shared configuration permits disabling TLS certificate validation, which exposes the bearer token and event data to man-in-the-middle interception. In this skill, the returned data may include event summaries and media URLs, so weakening transport security materially increases confidentiality and integrity risk.
def get_verify_ssl(env_vars):
"""
判断是否启用 TLS 证书验证。默认启用。
仅当 ~/.openclaw/.env 中显式设置 AI_GATEWAY_VERIFY_SSL=false 时禁用(仅开发环境)。
"""
val = env_vars.get("AI_GATEWAY_VERIFY_SSL", "true").lower()
return val not in ("false", "0", "no")
The skill declares file-read and network-reachable behavior but does not define explicit tool scope or allowed-tools boundaries in the manifest. In an agent environment, this increases the chance the skill is executed with broader capabilities than intended, enabling unintended access to local files such as shared credential material and outbound requests to attacker-controlled hosts if configuration is altered.
The manifest says AI_GATEWAY_API_KEY is a primary environment source, while the documentation says AI_GATEWAY_* environment variables are intentionally ignored. This inconsistency can cause the agent or operator to supply credentials through an unexpected channel, leading to stale, wrong, or less-protected secrets being used and undermining trust in the security model.
The skill relies on a persistent shared configuration file for credentials and host settings across sessions. Persistent shared state increases the blast radius of compromise: a malicious or compromised skill can read or alter the stored host or key once, and future invocations may continue using attacker-influenced configuration without user awareness.
### Configuration Source
The script reads `~/.openclaw/.env` as the single persistent configuration source. This file is shared by all skills and uses the format `KEY=VALUE` (one entry per line). OpenClaw clients write to this file when the user updates settings. The script does NOT read any `AI_GATEWAY_*` environment variables — env variables are intentionally ignored to avoid stale Gateway-process snapshots overriding the user's latest config.
## Security Notes
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
## Security Notes
- The shared credential file `~/.openclaw/.env` is readable by all skills under the same user. Ensure file permissions are restricted (e.g. `chmod 600 ~/.openclaw/.env`) and that only the OpenClaw service user has access. The IM clients write to this file under that user's home directory.
- TLS certificate verification is enabled by default. You MUST NOT disable it in production environments (disabling it introduces man-in-the-middle attack risks, and attackers may intercept API_KEY and device data)
- Before use, you MUST confirm that AI_GATEWAY_HOST points to a trusted domain
- You MUST use a least-privilege API_KEY to avoid reusing high-privilege credentials. This skill only requires event query permission
The request format specifies locale defaults to "zh_CN", which means the skill may force a specific language/locale behavior when the user does not explicitly choose one. The policy allows locale constraints only when the user is given a choice or the constraint is clearly justified as region-specific, which is not stated here.
The documentation at L015 states '不再读取任何 AI_GATEWAY_* 环境变量', which broadly claims those variables are no longer read. However, the code explicitly loads AI_GATEWAY_HOST and AI_GATEWAY_VERIFY_SSL from ~/.openclaw/.env in get_api_host and get_verify_ssl, and the docstring's '读取项' section also lists them. This is an internal documentation contradiction about configuration sources and behavior.
The script supports AI_GATEWAY_VERIFY_SSL=false, creating an unsafe transport default path even if the nominal default is true. If a local attacker, another skill, or compromised client modifies the shared ~/.openclaw/.env, authenticated API traffic can be intercepted or redirected without certificate validation, exposing bearer tokens and sensitive device event results.
def get_verify_ssl(env_vars):
"""
判断是否启用 TLS 证书验证。默认启用。
仅当 ~/.openclaw/.env 中显式设置 AI_GATEWAY_VERIFY_SSL=false 时禁用(仅开发环境)。
"""
val = env_vars.get("AI_GATEWAY_VERIFY_SSL", "true").lower()
return val not in ("false", "0", "no")
The command-line argument for locale hard-codes a default of zh_CN, which forces a specific language/locale behavior when the user does not explicitly choose one. The policy allows locale constraints only when user choice or a clearly justified region-specific limitation is provided, which is not evident here.
The display rules at L038 say that if there are more than 10 items, only the first 10 should be displayed, implying the script may return up to 10 for presentation. But the response documentation at L127 says the script has already trimmed the events array to the first 3 items. These statements conflict about the script's actual output behavior.