T09 · Insecure Skill Coding Practices
- Location
scripts/run.js:251- Finding
Bearer Token Disclosure Through an Unrestricted Server URL Override
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This Instagram discovery skill is mostly purpose-related, but it gives a token-bearing runner broader and less constrained authority than the skill description suggests.
Review this before installing. Use an environment-injected KEYAPI_TOKEN rather than the interactive prompt, do not store the token in the skill directory, avoid setting KEYAPI_SERVER_URL unless you fully trust the endpoint, and treat .keyapi-cache as potentially sensitive collected social data. Install under a normal user account and consider pinning dependencies with a reviewed lockfile.
scripts/run.js:251Bearer Token Disclosure Through an Unrestricted Server URL Override
scripts/run.js:220API Token Is Entered Visibly and Persisted in a Plaintext Project File
package.json:1Mutable Dependency Range Without a Lockfile Prevents Reproducible Installation
The declared description suggests a specialized Instagram content exploration capability. However, the supplied code does not implement Instagram-specific search or discovery features itself. Instead, it is a general-purpose runner for any KeyAPI MCP tool on any supported platform, with the default platform set to TikTok and examples including YouTube. This is a materially different primary purpose and broader capability set than declared. The extra features like caching and pagination are supporting details, but the major mismatch is that the code is a platform-agnostic tool invoker rather than an Instagram-focused content discovery skill.
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Referenced artifact was not completely inspected
node scripts/run.js --platform instagram --list-tools
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");
// ── .env loader ───────────────────────────────────────────────────────────────
(function loadDotenv() {
const envPath = join(ROOT, ".env");
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");
// ── .env loader ───────────────────────────────────────────────────────────────
(function loadDotenv() {
const envPath = join(ROOT, ".env");
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");
// ── .env loader ───────────────────────────────────────────────────────────────
(function loadDotenv() {
const envPath = join(ROOT, ".env");
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");
// ── .env loader ───────────────────────────────────────────────────────────────
(function loadDotenv() {
const envPath = join(ROOT, ".env");
The .env loader reads secrets from a local file into process.env. While common, it broadens credential exposure within the process and can enable unintended use of locally stored tokens, especially in a generic tool runner that connects to remote services.
// ── .env loader ───────────────────────────────────────────────────────────────
(function loadDotenv() {
const envPath = join(ROOT, ".env");
if (!existsSync(envPath)) return;
for (const line of readFileSync(envPath, "utf8").split("\n")) {
const m = line.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/);
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
" → Register at https://keyapi.ai/ to obtain a free token, then either:\n" +
" export KEYAPI_TOKEN=your_token_here\n" +
" → Or create a .env file in the skill directory:\n" +
" echo \"KEYAPI_TOKEN=your_token_here\" > .env"
);
}
const { createInterface } = await import("readline");
This line writes the supplied KEYAPI_TOKEN directly to a plaintext .env file in the project directory. If the directory is shared, backed up, or accidentally committed, the credential can be disclosed and abused to make unauthorized API calls under the user's account.
reject(new Error("No token entered. Set KEYAPI_TOKEN and try again."));
return;
}
const envPath = join(ROOT, ".env");
writeFileSync(envPath, `KEYAPI_TOKEN=${token}\n`, "utf8");
log(`[token] Saved to ${envPath} — future runs will load it automatically`);
process.env.KEYAPI_TOKEN = token;
The skill requires access to the KEYAPI_TOKEN environment variable but does not declare an explicit tool scope such as allowed tools or permissions boundaries. That weakens least-privilege guarantees and makes it harder for a host or reviewer to constrain what the skill can access or execute, especially since the workflow invokes a Node-based runner that can make outbound requests using the token.
The skill explicitly instructs users to cache API responses under a local .keyapi-cache directory, including post details, comments, replies, likes, and other engagement data, but does not prominently warn users in the description or prerequisites that potentially sensitive third-party data will be stored on disk. This can lead to unintended retention, local disclosure to other users/processes, and accidental inclusion of collected social data in backups or source-control uploads.