T09 · Insecure Skill Coding Practices
- Location
lib/client.mjs:39- Finding
Authentication Requests Can Be Redirected to an Arbitrary Network Destination
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This appears to be a legitimate AiCoin analytics skill, but it needs review because it broadly handles local API secrets and can call much more of the AiCoin API than its Hyperliquid framing suggests.
Install only if you are comfortable with a networked AiCoin API tool that may read existing .env files, save an AiCoin API secret in plaintext, and call non-Hyperliquid AiCoin endpoints. Use a dedicated low-privilege AiCoin key, keep unrelated secrets out of the working and OpenClaw .env files, and verify AICOIN_BASE_URL points only to the official AiCoin service. I found no evidence of wallet private-key access, trading authority, destructive actions, or hidden persistence.
lib/client.mjs:39Authentication Requests Can Be Redirected to an Arbitrary Network Destination
lib/client.mjs:130API Secrets Are Accepted in Process Arguments and Written to Plaintext Files Without Explicit Permission Hardening
lib/defaults.json:1Reusable Shared API Credential Is Embedded in the Distributed Source
Referenced artifact was not completely inspected
node scripts/aicoin.mjs <接口> '<JSON 参数>'
Referenced artifact was not completely inspected
node scripts/aicoin.mjs <接口> '<JSON 参数>'
Referenced artifact was not completely inspected
node scripts/aicoin.mjs <接口> '<JSON 参数>'
Referenced artifact was not completely inspected
node scripts/aicoin.mjs <接口> '<JSON 参数>'
Referenced artifact was not completely inspected
node scripts/aicoin.mjs <接口> '<JSON 参数>'
Referenced artifact was not completely inspected
node scripts/aicoin.mjs <接口> '<JSON 参数>'
Referenced artifact was not completely inspected
node scripts/aicoin.mjs <接口> '<JSON 参数>'
This code explicitly implements .env discovery and secret ingestion from the working directory and user-home OpenClaw paths, giving the skill access to locally stored credentials beyond its immediate runtime inputs. In an agent ecosystem, that materially increases the blast radius because the skill can read secrets that belong to other tools or sessions.
const __dirname = dirname(fileURLToPath(import.meta.url));
// ── .env auto-load (OpenClaw exec may not inject env into child processes) ──
const ENV_FILES = [
resolve(process.cwd(), '.env'),
resolve(process.env.HOME || '', '.openclaw', 'workspace', '.env'),
Including the workspace .env path in the search list causes the skill to ingest credentials from a shared execution area, not just from its own dedicated configuration. That increases the chance of cross-skill secret exposure and unintended credential reuse in a multi-tool environment.
// ── .env auto-load (OpenClaw exec may not inject env into child processes) ──
const ENV_FILES = [
resolve(process.cwd(), '.env'),
resolve(process.env.HOME || '', '.openclaw', 'workspace', '.env'),
resolve(process.env.HOME || '', '.openclaw', '.env'),
];
Searching the user's home OpenClaw .env further broadens credential access beyond the local project boundary. This makes the behavior more dangerous in context because an analytics skill can pull in account-level secrets from a global agent environment that the user did not intend this skill to read.
// ── .env auto-load (OpenClaw exec may not inject env into child processes) ──
const ENV_FILES = [
resolve(process.cwd(), '.env'),
resolve(process.env.HOME || '', '.openclaw', 'workspace', '.env'),
resolve(process.env.HOME || '', '.openclaw', '.env'),
];
for (const file of ENV_FILES) {
The loop over multiple candidate .env files operationalizes broad secret harvesting rather than a single explicit configuration source. In the context of a read-only analytics skill, this is an unnecessary elevation in credential access capability and increases exposure if the process, logs, or dependent modules are compromised.
const ENV_FILES = [
resolve(process.cwd(), '.env'),
resolve(process.env.HOME || '', '.openclaw', 'workspace', '.env'),
resolve(process.env.HOME || '', '.openclaw', '.env'),
];
for (const file of ENV_FILES) {
if (!existsSync(file)) continue;
Assigning discovered .env values into process.env makes all subsequently loaded code in the same process able to access those secrets, not just this client module. That propagation can unintentionally widen internal exposure and facilitate leakage through unrelated libraries or debugging output.
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) v = v.slice(1, -1);
if (!process.env[k]) process.env[k] = v;
}
} catch { /* ignore unreadable .env */ }
}
const defaults = JSON.parse(readFileSync(resolve(__dirname, 'defaults.json'), 'utf-8'));
The saveKey function not only accesses credentials but persists them to a discovered .env file after a network validation step. This creates long-lived secrets on disk in potentially shared or poorly protected locations, making theft, accidental commit, and cross-tool exposure substantially more likely.
return hit ? { method: hit.method, spec: hit } : null;
}
// Persist a new key pair to the workspace .env (validates before writing).
export async function saveKey(keyId, secret) {
const headers = authHeaders(keyId, secret);
const res = await fetch(`${BASE}/api/v3/coins/tickers?coin_key=bitcoin`, { headers, signal: AbortSignal.timeout(15000) });
The endpoint catalog grants access to a very broad authenticated API surface far beyond the declared Hyperliquid whale/perps analytics scope, including content, airdrops, equities, macro, signals, and treasury data. In an agent-skill setting, this violates least privilege and creates scope-confusion risk: prompts intended for Hyperliquid analytics could be steered into unrelated data access paths, increasing chances of unauthorized or privacy-invasive retrieval.
The CLI explicitly allows calling any AiCoin v3 endpoint, which materially exceeds the declared Hyperliquid analytics scope. In an agent-skill context, this breaks least-privilege and can enable unintended access to unrelated data domains or premium API surfaces the user did not intend to expose.
The script includes direct credential handling and persistence to .env, which is a genuine credential-access surface. In an agent skill, accepting and storing secrets is especially sensitive because it can normalize secret submission and create durable local exposure if the workspace is later leaked or misconfigured.
// node scripts/aicoin.mjs <endpoint> ['<json params>'] call any v3 endpoint
// node scripts/aicoin.mjs catalog [group|endpoint] list endpoints (the live API menu)
// node scripts/aicoin.mjs key show API key status + access probe
// node scripts/aicoin.mjs set-key <id> <secret> validate & save a new key to .env
//
// Endpoint = the path after /api/v3/ , e.g. market/ticker , hyperliquid/whales/open-positions
// Every call prints the v3 envelope {ok, data, error, meta}. Check `ok` first.
A read-oriented analytics skill includes a credential capture and persistence path via set-key, storing secrets to .env. Secret collection and local persistence are high-risk capabilities, especially when unnecessary for the core advertised use, and increase the blast radius if the environment is exposed.
The skill declares executable behavior that uses environment variables and network access, but it does not constrain or disclose tool scope via an explicit permissions or allowed-tools policy. In an agent setting, that increases the risk of overbroad execution and accidental exposure of secrets or unexpected outbound requests, especially because the skill also documents credential handling and live API interaction.
The trigger description is overly broad and includes generic 'on-chain whale' and 'smart money' phrases that extend beyond Hyperliquid-specific analytics. In a multi-skill agent, this can cause misrouting, leading the agent to select a skill with broader networked capabilities and credential handling for queries that should go to a narrower or different tool, increasing the chance of unnecessary data access or unsafe execution.
The manifest markets this as a Hyperliquid analytics skill, but the documented command accepts an arbitrary API path after /api/v3/, which expands capability beyond the stated scope. That scope mismatch is dangerous because an agent may invoke unrelated endpoints, including ones with different data sensitivity or side effects, under the assumption that the skill is narrowly read-only and domain-limited.
A read-only analytics skill includes a set-key feature that writes credentials into a local .env, which exceeds the minimum capability needed for data retrieval. This is risky because it encourages secret ingestion and persistence inside the agent environment, creating opportunities for credential mishandling, unintended reuse by other tools, or leakage through logs, workspace access, or later commands.
The skill proactively scans multiple .env locations and imports secrets into process.env, even though the declared use case is passive analytics. This unjustified credential-management behavior broadens access to unrelated secrets in the execution environment and can enable accidental reuse or downstream leakage if other code paths expose environment variables or write them back to disk.
The client includes a function that validates and then persists API credentials into a local .env file, creating a durable secret at rest in the workspace. For a skill described as read-only analytics that reportedly does not require wallet keys, this expands the secret-handling surface unnecessarily and increases the chance of later disclosure through logs, backups, repo commits, or other tools reading the same workspace files.
saveKey updates or creates .env entries without any confirmation, preview, or warning to the user, so invoking this path silently changes persistent authentication state. This can overwrite valid credentials, plant attacker-supplied keys, or leave secrets stored in a location the user did not intend.
The returned error strings are hard-coded in Chinese ("key 验证失败" and "验证请求失败") with no indication that language is configurable or region-specific. This imposes a specific language on users without opt-in, which violates the stated language/locale policy.