Back to skill

Security audit

preftrade AIO Quantitative Research Tools

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent MCP onboarding skill, but its instructions risk exposing a live API key and add a broad remote tool surface with weak scoping guidance.

Review before installing. Do not paste a real PREF key into the shown echo/export commands or run echo $PREFERENCE_API_KEY; use a secure prompt, OS keychain, or protected editor flow instead. Inspect and restrict the remote MCP tools you enable, and rotate the PREF key if you already exposed it in shell history, logs, transcripts, or shared terminal output.

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
skill.md:58
Finding

API Key Exposure Through Shell History, Terminal Output, and Permissive Initial File Permissions

Content
View full analysis

Vulnerability Details

File Location: skill.md, lines 58–68 and 125–126
Vulnerability Type: Insecure credential handling
Risk Level: Medium

Vulnerable Code

Lines 58–68:

bash
mkdir -p ~/.config/preference
echo '{"api_key":"pref_agent_xxx"}' > ~/.config/preference/credentials.json
chmod 600 ~/.config/preference/credentials.json
bash
export PREFERENCE_API_KEY='pref_agent_xxx'

Lines 125–126:

bash
echo $PREFERENCE_API_KEY     # should show your pref_agent_xxx key

Technical Analysis

The Skill instructs users to substitute a real bearer token directly into echo or export commands. Interactive shells may retain these commands in shell-history files, despite the surrounding documentation warning users not to expose the key through terminal history, logs, or prompts.

The troubleshooting command explicitly prints the complete token to standard output. This can expose it through terminal scrollback, screen sharing, command transcripts, session-recording systems, CI output, or support logs.

The credentials file is also created before chmod 600 is applied. Its initial permissions depend on the user's current umask. Under a permissive configuration, the file may briefly be readable by other local users or processes. The parent directory is created without an explicit restrictive mode as well.

Storing a service credential is necessary for the declared MCP onboarding functionality and does not itself exceed the Skill's required privileges. However, these examples do not apply least-exposure practices when creating and validating that credential.

Attack Path

  1. A user replaces pref_agent_xxx with a real PREF API key and runs the documented echo or export command.
  2. The command containing the plaintext key is retained in shell history, or the troubleshooting command prints the key into terminal output.
  3. A local user, process, terminal recorder, log op ...[truncated 1195 chars]
Remediation
View remediation

Remediation Suggestions

  1. Create the configuration directory with explicit owner-only permissions and set a restrictive umask before creating the credential file:

    bash
    install -d -m 700 ~/.config/preference
    umask 077
    
  2. Read the key without displaying it or placing it directly in the command line, then serialize it safely:

    bash
    read -rsp "PREF API key: " PREFERENCE_API_KEY
    printf '\n'
    jq -n --arg api_key "$PREFERENCE_API_KEY" \
      '{api_key:$api_key}' > ~/.config/preference/credentials.json
    chmod 600 ~/.config/preference/credentials.json
    unset PREFERENCE_API_KEY
    
  3. Prefer an operating-system credential store or secret manager where supported rather than a plaintext JSON file.

  4. Remove the instruction to run echo $PREFERENCE_API_KEY. Validate only whether the variable is populated:

    bash
    if test -n "${PREFERENCE_API_KEY:-}"; then
      echo "PREFERENCE_API_KEY is set"
    else
      echo "PREFERENCE_API_KEY is not set"
    fi
    
  5. Warn users who previously followed the examples to inspect and securely clear relevant shell history and logs, then rotate the key if it may have been exposed.

  6. Ensure MCP client configurations reference an environment variable or protected credential store rather than embedding the real bearer token in shared configuration files.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (7)

Credential Access

High
Category
Privilege Escalation
Confidence
88% confidence
Finding

The skill instructs writing a live API key directly with echo into a shell command, which conflicts with its own warning not to echo secrets into terminal history, logs, or prompts. In many environments, command history, process auditing, shell telemetry, or copied transcripts can expose the credential.

Content

Scanner excerpt · skill.md (reported line 61)May include surrounding context.

bash
mkdir -p ~/.config/preference
echo '{"api_key":"pref_agent_xxx"}' > ~/.config/preference/credentials.json
chmod 600 ~/.config/preference/credentials.json

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · skill.md (reported line 62)May include surrounding context.

bash
mkdir -p ~/.config/preference
echo '{"api_key":"pref_agent_xxx"}' > ~/.config/preference/credentials.json
chmod 600 ~/.config/preference/credentials.json

Or use an environment variable:

Unrestricted Tool Access

Medium
Category
Excessive Agency
Confidence
80% confidence
Finding

Telling an agent to 'call any tool to discover its schema' encourages broad, ungated interaction with a remote MCP exposing 670+ capabilities, without first constraining tool categories or requiring allowlisting. In an agent setting, unrestricted discovery can trigger unintended data access, external side effects, or use of risky tools beyond the user's intent.

Content

Scanner excerpt · skill.md (reported line 27)May include surrounding context.

md
3. install `https://pref.trade/mcp`
4. verify the MCP is using that key, not anonymous quota

Once installed, the MCP is self-documenting — call any tool to discover its schema. Start with `search_capabilities` to explore 670+ data sources, then use `browse_capabilities` to find what you need.

## Default Endpoint

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · skill.md (reported line 46)May include surrounding context.

1. Register if no key exists

bash
curl -s -X POST "https://pref.trade/v1/agents/register" \
  -H "Content-Type: application/json" \
  -d '{"name":"Research Agent","description":"Agent using PREF MCP"}' | jq

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · skill.md (reported line 60)May include surrounding context.

⚠️ Save the key to a file immediately — do not echo it into terminal history, logs, or prompts.

bash
mkdir -p ~/.config/preference
echo '{"api_key":"pref_agent_xxx"}' > ~/.config/preference/credentials.json
chmod 600 ~/.config/preference/credentials.json

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · skill.md (reported line 62)May include surrounding context.

bash
mkdir -p ~/.config/preference
echo '{"api_key":"pref_agent_xxx"}' > ~/.config/preference/credentials.json
chmod 600 ~/.config/preference/credentials.json

Or use an environment variable:

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · skill.md (reported line 79)May include surrounding context.

Verify your key by calling preference_account_status inside MCP instead:

bash
curl -s -X POST "https://pref.trade/mcp" \
  -H "Authorization: Bearer ${PREFERENCE_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"preference_account_status","arguments":{}}}'