Back to skill

Security audit

Kalshi Trading

Security checks for vulnerabilities and agentic risk

Overview

The skill is openly for Kalshi trading, but it can place real-money production orders through a CLI without an enforced confirmation or strict order limits.

Install only if you are comfortable giving the skill access to Kalshi credentials that can trade with real money. Use demo credentials first where possible, keep the private key locked down, and require manual review of ticker, side, count, price, total cost, and environment before any order or cancellation.

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/kalshi-cli.mjs:355
Finding

Production Trade Execution Lacks Enforced Confirmation and Strict Order Validation

Content
View full analysis
`); process.exit(1); } if (side !== "yes" && side !== "no") { console.error('Side must be "yes" or "no"'); process.exit(1); } result = await createOrder(creds, ticker, command, side, count, price); break; } ``` The documented safeguard is present only as an instruction in `SKILL.md`: ```markdown **Critical:** ALWAYS confirm with the user before placing any buy or sell order. Before executing a trade, show the user: - Ticker - Side (YES or NO) - Count (number of contracts) - Price (in cents) - Total cost = count × price cents = $X.XX ``` ### Technical Analysis The CLI sends an authenticated order to the production Kalshi API as soon as the `buy` or `sell` command is invoked. It does not require evidence that the user reviewed and approved the final ticker, side, quantity, price, and total notional value. The confirmation requirement therefore exists only in Agent-facing documentation and can be bypassed by direct CLI invocation, Agent error, or any caller that does not follow the prose instructions. Order v ...[truncated 2546 chars]
Remediation
View remediation
max) { throw new Error(`${name} must be between ${min} and ${max}`); } return parsed; } ``` - Validate price as an integer from 1 through 99. - Validate count as a positive safe integer with a conservative configurable maximum. - Reject malformed values rather than accepting numeric prefixes. 3. **Enforce risk limits** - Calculate the maximum order cost before submission. - Add configurable per-order and daily notional limits. - Require stronger confirmation or a separate override for orders exceeding conservative thresholds. - Verify the available balance before buy orders. 4. **Harden sell operations** - Query the portfolio before submission. - Verify that the requested sale is consistent with the intended position-management policy. - If short or offsetting behavior is supported, require an explicit, separately confirmed override instead of silently assuming it. 5. **Validate identifiers and market state** - Validate ticker syntax and canonicalize it to uppercase. - Retrieve market details before ordering and verify that the market is open and tradeab ...[truncated 350 chars]
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (6)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill exposes access to sensitive environment variables and performs network-backed trading actions, but it does not declare an explicit tool scope such as permissions or allowed-tools. That creates ambiguity about what execution capabilities the agent may use and weakens least-privilege controls, which is especially risky here because the skill can access trading credentials and initiate real financial transactions.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% 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 · references/api-notes.md (reported line 22)May include surrounding context.

md
## Base URLs

- **Production**: `https://api.elections.kalshi.com/trade-api/v2`
- **Demo**: `https://demo-api.kalshi.co/trade-api/v2`

The CLI uses production by default.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% 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 · scripts/kalshi-cli.mjs (reported line 33)May include surrounding context.

js
## Base URLs

- **Production**: `https://api.elections.kalshi.com/trade-api/v2`
- **Demo**: `https://demo-api.kalshi.co/trade-api/v2`

The CLI uses production by default.

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 · references/setup-guide.md (reported line 19)May include surrounding context.

bash
   # Move the downloaded key to a secure location
   mv ~/Downloads/kalshi_private_key.pem ~/.openclaw/kalshi_private_key.pem
   chmod 600 ~/.openclaw/kalshi_private_key.pem
  1. Set environment variables:

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 · references/setup-guide.md (reported line 55)May include surrounding context.

md
- **Never commit your private key** to git or share it publicly
- The private key is your authentication - treat it like a password
- API keys can be revoked from the Kalshi settings page
- Use file permissions to restrict access: `chmod 600 kalshi_private_key.pem`

## Demo vs Production

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The CLI directly executes live buy, sell, and cancel operations based solely on command-line arguments, with no confirmation prompt, dry-run mode, or other user-facing safety barrier. In a trading skill, this materially increases the chance of accidental or unintended real-money transactions if an agent, script, or user issues the wrong command or passes malformed parameters.

Content

No source excerpt is available for this finding.

Static analysis

Detected: suspicious.dangerous_exec, suspicious.exposed_secret_literal

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
scripts/quick-analysis.mjs:15

File appears to expose a hardcoded API secret or token.

Critical
Code
suspicious.exposed_secret_literal
Location
scripts/kalshi-cli.mjs:43