Back to skill

Security audit

Alpha Vantage API

Security checks for vulnerabilities and agentic risk

Overview

This Alpha Vantage skill appears purpose-aligned, but it handles the user's API key in ways that can expose it locally or in logs.

Review this skill before installing if you plan to use a personal Alpha Vantage key. Prefer the demo key or a low-privilege/rotatable key, avoid running the documented apikey command where shell history or logs are captured, and rotate any key that was already printed or stored by the tool.

Vulnerability Patterns
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
alpha.js:29
Finding

Insecure API Key Exposure Through Command-Line Arguments, Output, Plaintext Storage, and Request URLs

Content
View full analysis

Vulnerability Details

File Location: SKILL.md:25-29; alpha.js:29-34; alpha.js:68; alpha.js:104; alpha.js:144; alpha.js:184; alpha.js:224; alpha.js:251; alpha.js:317-326
Vulnerability Type: Sensitive credential exposure and insecure secret storage
Risk Level: Medium

Vulnerable Code

SKILL.md:25-29 documents passing the API key as a command-line argument:

bash
# Use your own API key
node alpha.js apikey YOUR_API_KEY

alpha.js:29-34 stores the key in a plaintext JSON file without explicitly restrictive permissions:

javascript
// Save configuration
function saveConfig() {
  fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
}

alpha.js:317-326 reads the secret directly from the command line, persists it, and prints the complete value:

javascript
case 'apikey':
  if (!args[1]) {
    console.error('Please provide an API key');
    process.exit(1);
  }
  config.apiKey = args[1];
  saveConfig();
  console.log(`API key has been set to: ${args[1]}`);
  process.exit(0);

The original source contains equivalent user-facing messages in Chinese. The security-relevant behavior is the direct use and disclosure of args[1].

The key is also embedded in request URLs at alpha.js:68, 104, 144, 184, 224, and 251:

javascript
const url = `https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=${symbol}&apikey=${config.apiKey}`;
javascript
const url = `https://www.alphavantage.co/query?function=TIME_SERIES_DAILY&symbol=${symbol}&outputsize=${outputSize}&apikey=${config.apiKey}`;
javascript
const url = `https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY&symbol=${symbol}&apikey=${config.apiKey}`;
javascript
const url = `https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol=${symbol}&apikey=${config.apiKey}`;
j
...[truncated 2805 chars]
Remediation
View remediation

Remediation Suggestions

  1. Do not accept secrets as ordinary command-line arguments.

    • Prefer the existing ALPHA_KEY environment-variable mechanism for noninteractive execution.
    • For interactive configuration, read the key from a masked prompt or standard input without echoing it.
    • Update SKILL.md so it no longer recommends node alpha.js apikey YOUR_API_KEY.
  2. Never print the complete credential.

    • Replace the current confirmation with a generic message such as API key configured successfully.
    • If identification is necessary, display only a small masked suffix, such as ****1234.
  3. Use secure credential storage.

    • Prefer an operating-system credential manager or secret-management service.
    • If local file storage remains necessary, create the file with owner-only permissions and verify permissions after creation:
    javascript
    fs.writeFileSync(
      CONFIG_FILE,
      JSON.stringify(config, null, 2),
      { encoding: 'utf8', mode: 0o600 }
    );
    fs.chmodSync(CONFIG_FILE, 0o600);
    
    • Ensure config.json is excluded from version control, backups, support bundles, and artifact packaging where appropriate.
  4. Minimize URL-based credential exposure.

    • Avoid logging complete request URLs.
    • Redact apikey values in diagnostics, telemetry, proxy logs, and exception reports.
    • If the upstream API supports a credential header, use that mechanism instead of a query parameter. If Alpha Vantage requires a query parameter, constrain logging and instrumentation accordingly.
  5. Rotate exposed keys.

    • Any key previously supplied through the documented CLI command, printed to logs, or stored with permissive access should be treated as potentially disclosed and replaced.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (1)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This JavaScript file presents its description, help text, prompts, and errors entirely in Chinese, which constitutes a locale/language constraint embedded in natural-language strings. The file does not offer any user opt-in, fallback language, or documented justification for restricting output to Chinese.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.