T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/rights_guard.py:6
- Finding
- Rights validation fails open and can approve restricted training data## Vulnerability Details **File Location**: `scripts/rights_guard.py`, lines 6-21 **Vulnerability Type**: Fail-open authorization and license validation **Risk Level**: High ### Vulnerable Code ```python def rate(entry): lic = (entry.get("license") or "").strip().lower() commercial = entry.get("commercial", True) attr = entry.get("attribution", False) source = (entry.get("source") or "").strip() problems = [] if not lic: problems.append("无许可证(高危)") if commercial is False or "non-commercial" in lic or "nc" == lic: problems.append("非商用锁(不可商用)") if attr is True and not entry.get("attributed", False): problems.append("需署名但未标") if not source: problems.append("来源不可溯(隔离待核)") if any("高危" in p or "非商用" in p for p in problems): return "排除", problems if problems: return "需处理", problems return "可训练", problems ``` ### Technical Analysis The commercial-use field defaults to `True` when it is absent. Consequently, an entry with no affirmative evidence of commercial authorization is treated as commercially permitted. The lexical license check only rejects licenses containing the exact substring `non-commercial` or whose complete normalized value is `nc`. Common non-commercial identifiers such as `CC-BY-NC-4.0` do not satisfy either condition. Unknown but nonempty license strings are also accepted without review. Attribution restrictions are trusted from the caller-supplied `attribution` Boolean rather than being inferred from recognized license terms. A manifest producer can therefore omit that field even when the declared license requires attribution. These conditions collectively create a fail-open gate: unsupported, ambiguous, or incompletely described licensing information can receive the final trainable status. ### Attack Path 1. A dataset supplier creates an entry with `license` set to `CC-BY-NC-4.0`. 2. ...[truncated 817 chars]
- Remediation
- ## Remediation Suggestions - Default missing commercial authorization to unknown or denied rather than `True`. - Maintain an explicit, normalized mapping of recognized license identifiers and their commercial-use, attribution, redistribution, and derivative-work requirements. - Recognize standard identifiers such as SPDX expressions and Creative Commons variants. - Route unknown, malformed, custom, or ambiguous licenses to manual review. - Infer restrictions from the recognized license instead of relying solely on caller-supplied Boolean fields. - Require affirmative evidence of commercial rights before assigning a trainable status. - Add regression tests for `CC-BY-NC-4.0`, `CC-BY-4.0`, custom licenses, missing fields, mixed-case identifiers, and whitespace variations.
