T09 · Insecure Skill Coding Practices
- Location
scripts/api-client.ts:76- Finding
API Key Exfiltration Through Unvalidated Endpoint Input
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill has a coherent A-share market-data purpose, but its required API client can expose the API key to an unintended host and uses unpinned npx execution.
Review before installing. This skill should only be used after the client enforces an allowlist of /api/stock endpoints, verifies the final origin is api.aipmedia.cn before attaching the API key, and replaces unpinned `npx tsx` with a locked local or compiled runner.
scripts/api-client.ts:76API Key Exfiltration Through Unvalidated Endpoint Input
SKILL.md:14Unpinned Runtime Package Execution Through npx
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
* 安全说明(Security Notice)
* ─────────────────────────────────────────────────────────────────
* 此脚本仅做两件事:
* 1. 从本地 .env 文件或环境变量中读取 ASTOCK_API_KEY
* 2. 将该 Key 作为 HTTP Header 发送至 https://api.aipmedia.cn
*
* 不会读取任何其他文件,不会上传本地文件内容,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
* 安全说明(Security Notice)
* ─────────────────────────────────────────────────────────────────
* 此脚本仅做两件事:
* 1. 从本地 .env 文件或环境变量中读取 ASTOCK_API_KEY
* 2. 将该 Key 作为 HTTP Header 发送至 https://api.aipmedia.cn
*
* 不会读取任何其他文件,不会上传本地文件内容,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
* 安全说明(Security Notice)
* ─────────────────────────────────────────────────────────────────
* 此脚本仅做两件事:
* 1. 从本地 .env 文件或环境变量中读取 ASTOCK_API_KEY
* 2. 将该 Key 作为 HTTP Header 发送至 https://api.aipmedia.cn
*
* 不会读取任何其他文件,不会上传本地文件内容,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
* 安全说明(Security Notice)
* ─────────────────────────────────────────────────────────────────
* 此脚本仅做两件事:
* 1. 从本地 .env 文件或环境变量中读取 ASTOCK_API_KEY
* 2. 将该 Key 作为 HTTP Header 发送至 https://api.aipmedia.cn
*
* 不会读取任何其他文件,不会上传本地文件内容,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
* 安全说明(Security Notice)
* ─────────────────────────────────────────────────────────────────
* 此脚本仅做两件事:
* 1. 从本地 .env 文件或环境变量中读取 ASTOCK_API_KEY
* 2. 将该 Key 作为 HTTP Header 发送至 https://api.aipmedia.cn
*
* 不会读取任何其他文件,不会上传本地文件内容,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
* 安全说明(Security Notice)
* ─────────────────────────────────────────────────────────────────
* 此脚本仅做两件事:
* 1. 从本地 .env 文件或环境变量中读取 ASTOCK_API_KEY
* 2. 将该 Key 作为 HTTP Header 发送至 https://api.aipmedia.cn
*
* 不会读取任何其他文件,不会上传本地文件内容,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
* 安全说明(Security Notice)
* ─────────────────────────────────────────────────────────────────
* 此脚本仅做两件事:
* 1. 从本地 .env 文件或环境变量中读取 ASTOCK_API_KEY
* 2. 将该 Key 作为 HTTP Header 发送至 https://api.aipmedia.cn
*
* 不会读取任何其他文件,不会上传本地文件内容,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
* 安全说明(Security Notice)
* ─────────────────────────────────────────────────────────────────
* 此脚本仅做两件事:
* 1. 从本地 .env 文件或环境变量中读取 ASTOCK_API_KEY
* 2. 将该 Key 作为 HTTP Header 发送至 https://api.aipmedia.cn
*
* 不会读取任何其他文件,不会上传本地文件内容,
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
// 1. 尝试读取 .env 文件(仅解析 ASTOCK_API_KEY 行,忽略其他所有内容)
const searchDirs = [process.cwd(), path.resolve(process.cwd(), "..")];
for (const dir of searchDirs) {
const envPath = path.join(dir, ".env");
if (fs.existsSync(envPath)) {
const lines = fs.readFileSync(envPath, "utf-8").split("\n");
for (const line of lines) {
The skill declares environment and network capabilities but does not define an explicit tool permission boundary such as allowed-tools or permissions. That increases the chance an agent runtime may execute the documented shell-based workflow with broader-than-intended access, especially since the skill instructs use of bash_tool and secret-backed API calls.
The manifest-level runtime reference to 'npx tsx' without version pinning embeds a supply-chain risk directly into the declared execution model. Because this is part of the skill metadata, automated systems may rely on it without additional scrutiny.
Invoking 'npx tsx' without pinning exact package versions introduces supply-chain risk because npx may resolve or download packages at runtime. A compromised or changed upstream package could execute arbitrary code in the agent environment, potentially exposing the ASTOCK_API_KEY or other local data.
This repeated instruction to use unpinned 'npx tsx' carries the same runtime package resolution risk throughout the skill. Repetition makes the unsafe execution path the primary supported workflow, increasing the likelihood of exploitation.
The trigger description is extremely broad and can activate on many generic stock-related mentions, causing the skill to run unexpectedly. In an agent setting, overbroad activation can lead to unnecessary network calls, inadvertent disclosure of user prompts to external services, and execution of shell workflows when the user did not intend a live-data action.
The skill again mandates an unpinned npx-based execution path, which can pull mutable code at runtime. In a skill that also handles API credentials, this creates a meaningful opportunity for code execution and secret exposure if the dependency chain is compromised.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
**所有 A 股数据必须通过下方 API 接口获取,严禁使用 Google Search、网页搜索或训练数据中的历史行情作为答案。**
- ✅ 正确:用 `bash_tool` 执行 TypeScript 脚本调用 `https://api.aipmedia.cn/api/stock/...`
- ❌ 错误:调用搜索引擎查询行情、引用训练数据中的股价、给出"大约/估计"的数字
如果接口调用失败,明确告知用户失败原因,不要用搜索结果替代。
The standard invocation example uses 'npx tsx' without version pinning, normalizing a supply-chain-sensitive pattern. Users or agents following the example may unknowingly execute updated third-party code with access to environment variables and filesystem context.
This command example repeats the same unpinned npx execution risk, and because it processes user-supplied endpoint parameters, it may be used frequently in normal operation. Frequent execution amplifies the blast radius of any upstream compromise.
Another unpinned 'npx tsx' example exposes the same supply-chain issue. The problem is not the API endpoint itself but the mutable command runner used to access it.
The documentation continues to direct agents to an unpinned runtime resolver, preserving the possibility of arbitrary code execution through dependency substitution or malicious updates. In an agent context, documented examples often become de facto trusted automation paths.
This example again relies on unpinned npx execution, which is dangerous because it can run non-reproducible code while the process has access to secrets and network. The skill context makes this more serious because API usage is mandatory, so the risky path is unavoidable during normal use.
The repeated unpinned npx pattern remains a true supply-chain vulnerability. Even if the script path is local, the command runner itself is mutable unless pinned and locked.
This final invocation example still uses unpinned 'npx tsx', preserving the same arbitrary-code-execution risk. Consistent repetition across the file indicates the unsafe practice is systemic rather than incidental.
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.
npx commands without a version suffix (e.g. @1.0.0) create a rug-pull risk if the upstream server is compromised and publishes a malicious update.