T09 · Insecure Skill Coding Practices
Warning
- Location
- trader.py:24
- Finding
- Declared Minimum-Volume Safeguard Is Not Enforced<![CDATA[ ## Vulnerability Details **File Location**: `trader.py:24`, `trader.py:185-229` **Vulnerability Type**: Missing liquidity validation before financial transactions **Risk Level**: Medium ### Vulnerable Code ```python MIN_VOLUME = float(os.environ.get("SIMMER_MIN_VOLUME", "3000")) ``` The signal validation applies spread and resolution-time checks but never validates market volume: ```python def compute_signal(market, fade_direction: str, streak_len: int) -> tuple[str | None, float, str]: """ Returns (side, size, reasoning) or (None, 0, skip_reason). Conviction-based sizing per CLAUDE.md. Fades strong directional moves: - After strong-UP streak -> expect mean reversion DOWN -> buy NO if p >= NO_THRESHOLD (i.e. the next interval is still priced Up, so we fade it) - After strong-DOWN streak -> expect mean reversion UP -> buy YES if p <= YES_THRESHOLD (i.e. the next interval is still priced Down, so we fade it) """ p = market.current_probability q = getattr(market, "question", "") # Spread gate if market.spread_cents is not None and market.spread_cents / 100 > MAX_SPREAD: return None, 0, f"Spread {market.spread_cents/100:.1%} > {MAX_SPREAD:.1%}" # Days-to-resolution gate if market.resolves_at: try: resolves = datetime.fromisoformat(market.resolves_at.replace("Z", "+00:00")) days = (resolves - datetime.now(timezone.utc)).days if days < MIN_DAYS: return None, 0, f"Only {days} days to resolve" except Exception: pass ``` ### Technical Analysis The project declares `SIMMER_MIN_VOLUME` as a risk parameter and documents it as a minimum market-volume filter. However, neither market discovery nor signal validation reads a market's volume or compares it with `MIN_VOLUME`. Consequently, the configured control has no effect. A matching market may progress to trade execution based only on probability, spread, resol ...[truncated 1378 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Determine the canonical volume field exposed by `simmer-sdk`. 2. Validate volume before calculating or submitting any signal: ```python volume = getattr(market, "volume", None) if volume is None: return None, 0, "Market volume unavailable" if float(volume) < MIN_VOLUME: return None, 0, f"Volume ${float(volume):,.2f} below minimum ${MIN_VOLUME:,.2f}" ``` 3. Fail closed when volume is absent, malformed, negative, or non-finite. 4. Prefer executable liquidity or order-book depth over aggregate historical volume where the SDK supports it. 5. Revalidate liquidity immediately before trade submission because discovery data may be stale. 6. Add tests covering unavailable volume, malformed values, boundary values, and markets below and above the configured minimum. ]]>
