T09 · Insecure Skill Coding Practices
- Location
scripts/trade-executor.py:328- Finding
Live Trades Can Explicitly Bypass All Risk Controls
- Content
View full analysis
Vulnerability Details
File Location:
scripts/trade-executor.py, lines 328-332 and 398-411
Vulnerability Type: User-accessible risk-control bypass
Risk Level: HighVulnerable Code
python # 1. Risk check (unless explicitly skipped) if not skip_risk_check and not dry_run: print("\n🛡️ Running risk check...") if not run_risk_check(symbol, amount, config_path, trades_dir): print("\n❌ Trade rejected by risk manager") return Falsepython parser.add_argument('--skip-risk-check', action='store_true', help='Skip risk manager check (dangerous!)') args = parser.parse_args() # Load config config = load_config(args.config) # Execute trade success = execute_trade( symbol=args.symbol, action=args.action, amount=args.amount, config=config, dry_run=args.dry_run, skip_risk_check=args.skip_risk_check, config_path=args.config, trades_dir=args.trades_dir )Technical Analysis
The publicly exposed
--skip-risk-checkcommand-line option bypasses the risk manager before a live transaction. This disables all checks implemented by the risk manager, including maximum position size, active-position limits, daily trade limits, cooldown enforcement, maximum drawdown, and correlated-position limits.This behavior directly contradicts the executor's documented claim that it always performs a risk check before executing a trade. The bypass does not require authentication, separate authorization, interactive confirmation, or an auditable emergency-override procedure.
Attack Path
- An attacker, compromised automation process, or operator with access to invoke the script selects a token, action, and amount.
- The caller adds
--skip-risk-checkto the command:bash python3 scripts/trade-executor.py \ --symbol TOKEN \ --action buy \ --amount 5000 \ --skip-ri
...[truncated 949 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove
--skip-risk-checkfrom the production command-line interface. - Make the risk check mandatory for every live transaction.
- If an emergency override is operationally necessary, place it in a separate administrative workflow requiring:
- Explicit authenticated authorization.
- Interactive confirmation displaying the complete transaction.
- A short-lived approval token.
- Immutable audit logging.
- A hard-coded maximum emergency transaction size.
- Ensure the executor fails closed if the risk-manager script is unavailable, times out, returns malformed output, or cannot load configuration.
- Add integration tests proving that no live execution path can reach
execute_bankr_swap()without successful risk approval.
- Remove
