T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/quality_gate.py:68
- Finding
- Failed Quality Gates Return a Successful Process Exit Status<![CDATA[ ## Vulnerability Details **File Location**: `scripts/quality_gate.py`, lines 68-77 **Vulnerability Type**: Release-gate fail-open behavior **Risk Level**: High ### Vulnerable Code ```python print(f"质量门禁:{base}\n" + "=" * 40) passed = 0 for name, ok, fix in results: print(f" [{'PASS' if ok else 'FAIL'}] {name}" + (f" → {fix}" if fix and not ok else "")) passed += ok print("=" * 40) print(f"结果:{passed}/{len(results)} → {'✅ 放行' if passed == len(results) else '🔒 拦截发布'}") if __name__ == "__main__": main() ``` ### Technical Analysis The validator visually reports failed checks but does not return or raise a nonzero process status. Because `main()` completes normally, the Python interpreter exits with status `0`, regardless of whether any quality check failed. This contradicts the documented behavior in `SKILL.md`, which states that the program returns `0` on success, `1` when issues are detected, and `2` for usage or environmental errors. Automated release systems normally rely on process exit status rather than parsing human-readable output. Consequently, this implementation is fail-open when integrated into CI/CD or marketplace publication workflows. ### Attack Path 1. An attacker or contributor prepares a Skill containing prohibited or noncompliant content. 2. The release pipeline invokes: ```bash python scripts/quality_gate.py --dir ./submitted-skill ``` 3. One or more checks print `FAIL`, and the summary claims that publication is blocked. 4. The script reaches the end of `main()` without raising `SystemExit` or returning a status to the interpreter. 5. The operating system records exit status `0`. 6. The release pipeline interprets the validator as successful and continues publishing the submitted Skill. ### Impact Assessment This issue can bypass every quality rule implemented by the validator, including the plaintext-secret check. It does not directly grant operating-system privileges, ...[truncated 253 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Return an explicit status from `main()` and propagate it to the operating system: ```python def main(): # Existing validation logic return 0 if passed == len(results) else 1 if __name__ == "__main__": raise SystemExit(main()) ``` Handle argument, filesystem, decoding, and environmental errors separately with exit status `2`. Add automated tests asserting that: - All checks passing produces exit status `0`. - Any individual check failing produces exit status `1`. - Missing or invalid arguments produce exit status `2`. - CI publication is halted on every nonzero status. Release automation should also treat an absent, terminated, or malformed validator result as failure rather than success. ]]>
