T09 · Insecure Skill Coding Practices
Warning
- Location
- model_failover_doctor.py:287
- Finding
- Unvalidated provider reassignment can corrupt or redirect model routing<![CDATA[ ## Vulnerability Details **File Location**: `model_failover_doctor.py:287-288`, `model_failover_doctor.py:341-347`, and `model_failover_doctor.py:379-380` **Vulnerability Type**: Unsafe configuration repair using unvalidated, hard-coded provider and model mappings **Risk Level**: Medium ### Vulnerable Code At `model_failover_doctor.py:287-288`, an unknown provider reference is reassigned to a hard-coded provider without verifying that the resulting provider/model pair exists: ```python # 3) 最后兜底:挂到 lovbrowser if new_val is None: new_val = f'{lb}/{model_path}' ``` At `model_failover_doctor.py:341-347`, a static fallback chain is installed when the generated chain is too short: ```python # 兜底:Intelligence 池的常见配置 if len(chain) <= 1: chain = [ 'custom-llmapi-lovbrowser-com/anthropic/claude-sonnet-4.6', 'custom-llmapi-lovbrowser-com/anthropic/claude-opus-4.6', 'custom-llmapi-lovbrowser-com/openai/gpt-5.3-codex', 'kimi-coding/k2p5', 'zai/glm-5', ] ``` At `model_failover_doctor.py:379-380`, invalid session entries are similarly reassigned to the hard-coded provider: ```python if new_entry is None: new_entry = f'{lb}/{model_path}' ``` ### Technical Analysis The repair routines detect provider prefixes that are absent from `openclaw.json`, but their final fallback behavior does not resolve the entry against an authoritative list of configured provider/model pairs. Instead, an unknown model path is attached to the hard-coded `custom-llmapi-lovbrowser-com` provider. The fallback-chain repair has the same validation weakness: when no adequate chain can be constructed, it inserts five static provider/model references without confirming that those providers are configured, that the listed models are supported, or that the operator trusts those routing destinations. Consequently, the automatic repair can replace an invalid configuration with another invalid configuration. More importantly, if the har ...[truncated 2341 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Build an authoritative set of valid provider/model pairs from `openclaw.json`, rather than validating only the provider prefix. 2. Permit an automatic replacement only when the complete target pair is explicitly present in that authoritative set. 3. Remove the fallback behavior that blindly prepends `custom-llmapi-lovbrowser-com` to an unresolved model path. 4. Remove the static fallback-chain list, or filter every entry against the active configuration before use. 5. If no verified mapping exists, leave the original entry unchanged, report that automatic repair is unsafe, and require an explicit operator selection. 6. Before writing any file, validate the complete proposed configuration and present the exact before-and-after mapping. 7. After writing, reload the files and perform a second validation pass. Do not restart the gateway if any provider/model pair remains unresolved. 8. Preserve the existing backup mechanism, but use collision-resistant backup names, such as timestamps with microseconds or random suffixes, to avoid overwriting backups created within the same second. 9. Add tests covering unknown providers, unknown models, absent hard-coded providers, unsupported model/provider combinations, and configurations with only one valid fallback. ]]>
