T09 · Insecure Skill Coding Practices
- Location
simmer_momentum_trader.py:111- Finding
Market safeguards fail open when context retrieval fails
- Content
View full analysis
Vulnerability Details
File Location:
simmer_momentum_trader.py, lines 111-119
Vulnerability Type: Fail-open financial safety control
Risk Level: HighVulnerable Code
python client = get_client() try: params = {} if my_probability is not None: params["my_probability"] = my_probability context = client.get_market_context(market_id, **params) except Exception: return None # Can't check context, proceed with cautionThe caller interprets
Noneas approval to continue:python skip_reason = should_skip_market(market_id) if skip_reason: print(f" SKIPPED: {skip_reason}") print() continueTechnical Analysis
should_skip_market()is intended to prevent trades when severe flip-flop warnings, excessive slippage, or an unfavorable edge recommendation are present. However, every exception raised while retrieving market context is converted intoNone.The function also uses
Noneto mean that no reason exists to skip the market. Consequently, authentication errors, network timeouts, rate limiting, malformed responses, SDK failures, and service outages all bypass the advertised safety checks.This is a fail-open design. It also contradicts the documented hard rule in
SKILL.mdthat market context is always checked before trading. Althoughcalculate_signal()performs another context request, the two requests are independent: the safety request can fail while the later signal request succeeds.Attack Path
- The trader is invoked with
--live, enabling real orders. - An attacker or infrastructure failure disrupts the context request made by
should_skip_market(). get_market_context()raises an exception.- The broad exception handler returns
None. - The caller treats this value as approval to proceed.
- A subsequent context request in
calculate_signal()succeeds and generates a signal. - `execute_tra ...[truncated 561 chars]
- The trader is invoked with
- Remediation
View remediation
Remediation Suggestions
Fail closed whenever safety context cannot be obtained:
python except Exception as exc: return f"Unable to verify market safeguards: {exc}"Additional hardening should include:
- Catch only expected SDK or network exceptions rather than all
Exceptionsubclasses. - Log the failure type without exposing credentials or sensitive response data.
- Add bounded retries with exponential backoff for transient failures.
- Require successful validation of flip-flop status, slippage, and edge analysis before every live order.
- Use a structured result that distinguishes
SAFE,UNSAFE, andCHECK_FAILED, rather than overloadingNone. - If fail-open behavior is operationally necessary, place it behind an explicit unsafe command-line option that is disabled by default and emits a prominent warning.
- Add automated tests proving that context exceptions prevent
client.trade()from being called.
- Catch only expected SDK or network exceptions rather than all
