T09 · Insecure Skill Coding Practices
- Location
dispatcher.py:145- Finding
Partial-String Flag Matching Can Unintentionally Authorize Claude Routing
- Content
View full analysis
Vulnerability Details
File Location:
dispatcher.py, lines 145-157; related flag declaration and standard-route check at lines 19 and 132
Vulnerability Type: Improper authorization-token parsing
Risk Level: MediumVulnerable Code
python _FORCE_CLAUDE_FLAG = "--force-claude"python def _tradeoff_route(self, prompt: str) -> RoutePlan: if _FORCE_CLAUDE_FLAG in prompt: parallel = ( self._run(ModelCatalog.SONNET, role="proposal"), self._run(ModelCatalog.OPUS, role="proposal"), ) return RoutePlan( mode="tradeoff-force-claude", parallel=parallel, judge=self._run(ModelCatalog.CODE_ARCH, role="judge"), reason="tradeoff route with Claude forced only for proposal generation", used_force_claude=True, )The same substring test also appears in the standard routing path:
python if _FORCE_CLAUDE_FLAG in prompt: return RoutePlan( mode="standard", primary=self._run(model, role="primary"), reason=( "standard routing; --force-claude applies only to tradeoff proposal generation" ), used_force_claude=True, )Technical Analysis
The dispatcher treats the presence of
--force-claudeanywhere within the prompt as authorization to use Anthropic models. The expression:python _FORCE_CLAUDE_FLAG in promptperforms unrestricted substring matching rather than validating an exact control token. Consequently, larger or unrelated strings such as
--force-claude-disabled,example--force-claude, or documentation containing the flag text satisfy the authorization check.For a prompt also recognized as a tradeoff request, this causes the dispatcher to produce a route containing:
anthropic/claude-sonnet-4-6anthropic/claude-opus-4-6
Although this module only cons ...[truncated 1753 chars]
- Remediation
View remediation
Remediation Suggestions
-
Replace substring matching with explicit flag parsing. Prefer a structured API argument that separates routing controls from user-supplied prompt text:
python def route( self, prompt: str, *, domain: str, force_claude: bool = False, ) -> RoutePlan: ... -
If compatibility requires prompt-embedded flags, tokenize the control portion and require exact equality rather than substring containment. Reject malformed variants such as
--force-claude-disabled. -
Remove recognized routing flags from the content passed to downstream models so control tokens are not treated as task data.
-
Centralize flag parsing so standard and tradeoff routing use the same validated result rather than independently searching the raw prompt.
-
Add negative unit tests covering:
--force-claude-disabledprefix--force-claude--force-claude=something- documentation or quoted examples containing the flag
- case variants, with an explicitly documented case-sensitivity policy
- multiple conflicting or malformed flags
-
Preserve the existing invariant test confirming that Claude never appears in build pipelines, including when malformed force-flag strings are present.
-
