T09 · Insecure Skill Coding Practices
Error
- Location
- trader.py:266
- Finding
- Minimum Market-Volume Safeguard Is Not Enforced<![CDATA[ ## Vulnerability Details **File Location**: `trader.py:45-51`, `trader.py:79-85`, and `trader.py:266-280` **Vulnerability Type**: Declared financial-risk control is not enforced **Risk Level**: High The `SIMMER_MIN_VOLUME` parameter is loaded into `MIN_VOLUME`: ```python # Risk parameters MAX_POSITION = float(os.environ.get("SIMMER_MAX_POSITION", "40")) MIN_VOLUME = float(os.environ.get("SIMMER_MIN_VOLUME", "1000")) MAX_SPREAD = float(os.environ.get("SIMMER_MAX_SPREAD", "0.10")) MIN_DAYS = int(os.environ.get( "SIMMER_MIN_DAYS", "0")) MAX_POSITIONS = int(os.environ.get( "SIMMER_MAX_POSITIONS", "8")) YES_THRESHOLD = float(os.environ.get("SIMMER_YES_THRESHOLD", "0.38")) NO_THRESHOLD = float(os.environ.get("SIMMER_NO_THRESHOLD", "0.62")) MIN_TRADE = float(os.environ.get("SIMMER_MIN_TRADE", "5")) ``` It is loaded again after applying the Skill configuration: ```python MAX_POSITION = float(os.environ.get("SIMMER_MAX_POSITION", str(MAX_POSITION))) MIN_VOLUME = float(os.environ.get("SIMMER_MIN_VOLUME", str(MIN_VOLUME))) MAX_SPREAD = float(os.environ.get("SIMMER_MAX_SPREAD", str(MAX_SPREAD))) MIN_DAYS = int(os.environ.get( "SIMMER_MIN_DAYS", str(MIN_DAYS))) MAX_POSITIONS = int(os.environ.get( "SIMMER_MAX_POSITIONS", str(MAX_POSITIONS))) YES_THRESHOLD = float(os.environ.get("SIMMER_YES_THRESHOLD", str(YES_THRESHOLD))) NO_THRESHOLD = float(os.environ.get("SIMMER_NO_THRESHOLD", str(NO_THRESHOLD))) MIN_TRADE = float(os.environ.get("SIMMER_MIN_TRADE", str(MIN_TRADE))) ``` However, the trading loop proceeds directly from signal generation to context validation and order submission without checking market volume: ```python placed = 0 for m in markets: if placed >= MAX_POSITIONS: break side, size, reasoning = compute_signal(m) if not side: safe_print(f" [skip] {reasoning}") continue ok, why = context_ok(client, m.id) if not ok: ...[truncated 1549 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Retrieve the market's authoritative volume value before computing or executing a trade. - Reject markets whose volume is missing, malformed, non-finite, or below `MIN_VOLUME`. - Use a fail-closed policy when volume data cannot be obtained. - Ensure the volume field and `MIN_VOLUME` use the same currency and measurement period. - Add a second validation immediately before `client.trade()` to reduce time-of-check/time-of-use risk. - Add automated tests proving that zero-volume, missing-volume, and sub-threshold markets cannot reach the trading API. - Update logging to record the observed volume and applicable threshold for every rejection. ]]>
