Back to skill

Security audit

Polymarket Bot Skill

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent Polymarket trading-bot skill, but it handles live trading credentials unsafely and can enable live automated trades without clear user approval.

Review carefully before installing or running. Use only disposable or least-privilege credentials, do not paste private keys into prompts, keep live funds out until the code is changed to default to dry-run, remove credential printing, add explicit live-trading confirmation, and add strict position, market, and rate limits.

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

Error
Location
scripts/auth_setup.py:30
Finding
Sensitive CLOB API Credentials Disclosed Through Console Output## Vulnerability Details **File Location**: `scripts/auth_setup.py`, lines 30–32 **Vulnerability Type**: Sensitive credential exposure through console and log output **Risk Level**: High ### Vulnerable Code ```python creds = authenticate_with_clob(private_key) print("API creds derived:", creds) ``` The `authenticate_with_clob()` function returns authentication material described by the code as an API key, secret, and passphrase. The example entry point prints the complete returned object without redaction. ### Technical Analysis Console output is frequently captured by terminal history, CI/CD logs, process supervisors, container logging drivers, hosted execution environments, and centralized monitoring systems. Consequently, printing the credential object expands access to sensitive trading credentials beyond the bot process and violates least-disclosure principles. The private wallet key itself is not printed or transmitted by this statement. However, the exposed CLOB credentials may be reusable for authenticated account operations, depending on the permissions and authentication requirements enforced by the service. ### Attack Path 1. A user sets `POLY_PRIVATE_KEY` and runs `scripts/auth_setup.py`. 2. The script signs the authentication message and requests CLOB credentials from the configured Polymarket endpoint. 3. The endpoint returns an API key, secret, and passphrase. 4. Lines 30–31 store and print the full credential object. 5. Terminal output is retained in a log, CI job, container log, or process-supervisor journal. 6. An attacker or unauthorized operator with access to that output extracts the credentials. 7. The attacker attempts authenticated CLOB operations using the exposed credentials, subject to the account permissions and any additional controls imposed by the service. ### Impact Assessment An attacker who obtains valid trading credentials may be able to impersonate the affected CLOB account and perform authenticated operations, pote ...[truncated 396 chars]
Remediation
## Remediation Suggestions 1. Remove the credential value from all output: ```python creds = authenticate_with_clob(private_key) print("CLOB API credentials derived successfully.") ``` 2. If an identifier is operationally necessary, expose only a minimally useful redacted value: ```python api_key = creds.get("apiKey", "") masked = f"{api_key[:4]}...{api_key[-4:]}" if len(api_key) >= 8 else "[redacted]" print(f"CLOB authentication succeeded for key {masked}.") ``` 3. Add logging filters that redact fields such as `apiKey`, `secret`, `passphrase`, `private_key`, and authorization headers before messages reach any handler. 4. Avoid serializing credential objects in exceptions, debug logs, telemetry, crash reports, or tracing systems. 5. Restrict access to CI, container, and process-supervisor logs and configure short retention periods for sensitive workloads. 6. Rotate or revoke credentials that may previously have been printed. Review relevant logs and authenticated account activity for unauthorized use. 7. Keep credentials in memory only as long as required and pass them exclusively to the documented authentication client or request-signing mechanism.
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
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (15)

Credential Access

High
Category
Privilege Escalation
Content
if __name__ == "__main__":
    if not private_key:
        print("Error: Set POLY_PRIVATE_KEY in .env file.")
        exit(1)
    
    # Step 1: Authenticate and get API creds
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
if __name__ == "__main__":
    if not private_key:
        print("Error: Set POLY_PRIVATE_KEY in .env file.")
        exit(1)
    
    # Step 1: Authenticate and get API creds
Confidence
60% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill advertises capabilities that inherently involve network access and likely environment-secret usage, but it does not declare any explicit tool scope or permission boundaries. In an agent setting, this can cause over-broad execution assumptions, making it easier for the skill to access credentials or perform network actions without clear user review or least-privilege controls.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The skill discusses authentication setup and trade execution while presenting the workflow as routine automation, but it does not warn about private key/API credential sensitivity or the financial risk of live trading. This increases the chance that users will expose secrets or run destructive operations against real funds without understanding the consequences.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The quick-start tells users to execute bot scripts immediately, including strategy logic, without any visible guardrails about automated market interaction or the possibility of placing live orders. In the context of a trading bot skill, this is more dangerous than generic automation because even a small mistake can trigger irreversible blockchain transactions or unintended financial exposure.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The prompts explicitly instruct an AI to generate code for private-key-based authentication, autonomous trade execution, infinite monitoring loops, and copy trading, but provide no warnings or guardrails around secret handling, financial risk, authorization, or safe testing. In a trading-bot skill, this materially increases the chance that users will generate unsafe code that mishandles credentials or executes real-money trades without adequate review.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
The reference prompts instruct an AI/code generator to build trading code that accepts or loads a blockchain private key, but they do not warn about secret-handling risks or constrain how generated code should store, log, or expose credentials. In a bot/trading context, this can lead to insecure implementations that leak wallet keys through source files, logs, prompts, or environment dumps, enabling account takeover and unauthorized trades.

Description-Behavior Mismatch

Medium
Confidence
87% confidence
Finding
The manifest describes automation for fetching market data, placing trades, and implementing strategies like arbitrage, but this file implements a distinct social/copy-trading strategy based on leaderboard users' activity. Copying third-party traders is a materially different bot behavior than the manifest's described arbitrage-focused and general trading operations.

Context-Inappropriate Capability

Medium
Confidence
80% confidence
Finding
The code fetches leaderboard rankings and individual traders' trade histories to replicate their actions. While trading and market monitoring are in scope, surveillance of other traders for copy trading is a separate capability that is not explicitly supported by the manifest's stated purpose.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The bot can automatically place live orders based on external trader activity without any user confirmation, transaction preview, risk limits, or provenance checks. In a trading skill, this is especially dangerous because a manipulated or simply poor-quality data source could trigger repeated real-money trades, causing rapid financial loss.

External Transmission

Medium
Category
Data Exfiltration
Content
# Derive API key using CLOB endpoint
    url = "https://clob.polymarket.com/api-keys"
    response = requests.post(url, json={"signed_message": signed_message})
    if response.status_code == 200:
        api_data = response.json()
        return api_data  # Returns API key, secret, passphrase
Confidence
80% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Intent-Code Divergence

Medium
Confidence
98% confidence
Finding
The example code derives live API credentials from a blockchain private key and then prints those credentials to stdout. Stdout is commonly captured by terminals, shell history tooling, CI logs, container logs, and observability systems, so exposing an API key, secret, and passphrase can directly enable unauthorized trading or account abuse.

Missing User Warnings

Medium
Confidence
99% confidence
Finding
Printing the derived API credentials to stdout exposes sensitive authentication material in cleartext. Anyone with access to the console session, logs, CI artifacts, or shared runtime environment could reuse those credentials to act as the bot, place trades, or drain strategy value.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The script instantiates the trading bot with dry_run=False, which enables live order execution by default without any interactive confirmation, explicit CLI flag, or safety interlock. In a bot for prediction-market trading on Polygon, this increases the risk of unintended real-money transactions if the script is run in the wrong environment or by a user who assumes it is only a test integration.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The bot can trigger sell actions automatically based solely on market price thresholds, without any user confirmation, approval workflow, or explicit guardrails. In the context of a trading bot that can operate on live prediction markets, this creates a real risk of unintended asset liquidation, especially if market data is wrong, stale, manipulated, or if the strategy logic behaves unexpectedly.

Static analysis

No suspicious patterns detected.