T09 · Insecure Skill Coding Practices
- Location
scripts/route_message.py:59- Finding
Security-sensitive wallet requests can bypass high-stakes review
- Content
View full analysis
Vulnerability Details
File Location:
scripts/route_message.py:59-61, 70-87, 157-159
Vulnerability Type: Unsafe routing precedence and incomplete high-stakes detection
Risk Level: MediumVulnerable Code
python def detect_task_type(text: str, explicit: str | None) -> str: if explicit and explicit != "auto": return explicit if matches_any(text, ZERO_LLM_PATTERNS): return "deterministic" if matches_any(text, WALLET_PATTERNS): return "wallet" if matches_any(text, VISION_PATTERNS): return "vision" if matches_any(text, LONG_CONTEXT_PATTERNS): return "long-context" if matches_any(text, CODE_PATTERNS): return "code" return "chat"python def route_message(text: str, task_type: str, high_stakes: bool, allow_zero_llm: bool) -> RouteDecision: if task_type == "deterministic" and allow_zero_llm: return RouteDecision( route="zero-llm", fallback=None, risk="low", task_type=task_type, reason="Matched a deterministic workflow that should bypass LLM usage.", ) if high_stakes: return RouteDecision( route="bankr/claude-opus-4.6", fallback="bankr/claude-sonnet-4.5", risk="high", task_type=task_type, reason="Explicit high-stakes escalation; prioritize caution over cost.", )python parser.add_argument("--high-stakes", action="store_true", help="Force the high-stakes route") parser.add_argument("--allow-zero-llm", choices=["true", "false"], default="true", help="Allow deterministic zero-LLM routing") parser.add_argument("--json", action="store_true", help="Emit JSON") args = parser.parse_args() text = args.text.strip().lower() task_type = detect_task_type(text, args.task_type) decision = route_message(text, task_type, ar ...[truncated 3160 chars]- Remediation
View remediation
Remediation Suggestions
- Evaluate security-sensitive wallet indicators before deterministic indicators. Signing, approvals, credential handling, contract permissions, and ambiguous fund movements should automatically receive high-stakes classification.
- Move the high-stakes branch ahead of the deterministic branch so that a high-stakes decision cannot be overridden by zero-LLM routing.
- Replace broad deterministic keywords such as
scriptandcronwith an allowlist of known, named, and validated deterministic operations. - Do not unconditionally trust
--task-type deterministic. Treat explicit task types as hints, or reject deterministic routing when sensitive wallet terms are present. - Require deterministic handlers to be registered and associated with defined input validation, permitted actions, and risk levels before returning
zero-llm. - Add collision tests for messages containing both deterministic and wallet terms, including signing, token approvals, treasury transfers, and script-driven transactions.
- Ensure downstream consumers treat the result as a recommendation rather than transaction authorization and independently enforce wallet approval and signing controls.
