T09 · Insecure Skill Coding Practices
- 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]
