T09 · Insecure Skill Coding Practices
Error
- Location
- references/setup.md:27
- Finding
- Unsafe Live-First Brokerage Profile Selection<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:31-32`; `references/setup.md:27-29` **Vulnerability Type**: Unsafe default configuration for real-money trading **Risk Level**: High ### Vulnerable Code Snippet From `SKILL.md:31-32`: ```markdown - **Connection priority**: Unless the user explicitly mentions "paper" or a paper account, prefer live profiles over paper, and gateway over TWS. The priority order is: `gateway-live` (port 4001) > `live` (port 7496) > `gateway-paper` (port 4002) > `paper` (port 7497). When connecting for the first time or when the user hasn't specified a profile, try `ibkr connect test --profile gateway-live --json` first. If it fails, try the next profile in the priority list. Once a working profile is found, use it for subsequent commands. - **Profile flag**: Most commands accept `--profile`. Always be explicit about which profile to use. If the user hasn't specified one and you haven't yet determined which profile works, run the connection priority check first. ``` From `references/setup.md:27-29`: ```markdown ### Choosing a profile When the user hasn't specified whether they want paper or live trading, verify connectivity in priority order: `gateway-live` (4001) > `live` (7496) > `gateway-paper` (4002) > `paper` (7497). Use `ibkr connect test --profile <name> --json` to check each. The first successful connection is the one to use. Only default to paper if the user explicitly says they want paper trading, or if no live connection is available. ``` ### Technical Analysis The Skill directs the Agent to probe and select live brokerage profiles before paper profiles when the user has not explicitly selected an environment. This violates the fail-safe-default principle because an ambiguous request is resolved in favor of the environment capable of executing real-money transactions. The trading guide does require either `--preview` or `--submit` and recommends previewing orders first. That control reduces accident ...[truncated 1943 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Make paper trading the default whenever the user has not explicitly selected an environment: ```text gateway-paper > paper ``` 2. Do not automatically fall back from paper to live. Treat live selection as a separate, explicit user decision. 3. Before connecting to a live profile, obtain contemporaneous confirmation that clearly states: - The profile name. - Whether the environment is live. - The target account or masked account identifier. 4. Before every live `--submit`, show and reconfirm: - Account and profile. - Symbol and exchange. - Buy or sell side. - Quantity. - Order type and prices. - Time in force. - Estimated order value, commission, and margin effect. 5. Require the user to provide an explicit confirmation phrase for live submission rather than inferring consent from an earlier request. 6. Prefer limit orders over market orders in examples involving live trading, unless the user deliberately requests a market order. 7. Add a persistent visual warning to every documented live-profile example, while keeping paper-profile examples as the primary onboarding workflow. 8. For multi-account setups, require an explicit `--account` value and confirmation before live submission. ]]>
