T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/check_prohibited.py:17
- Finding
- Documented P0 Rules Are Not Fully Enforced by the Mandatory Publication Gate<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/check_prohibited.py:17-44` - `scripts/check_prohibited.py:121-129` - `references/prohibited-words.md:45,52-55,79-83` - `SKILL.md:14,37` **Vulnerability Type**: Security-control enforcement mismatch caused by duplicated and divergent rule sources **Risk Level**: Medium ### Vulnerable Code The scanner maintains an internal P0 rule list that does not include all terms identified as prohibited in the documented canonical list: ```python # ============ 离线词库(与 references/prohibited-words.md 同步维护)============ # 每个词条: (正则, 级别, 说明, 替代建议) P0_HARD = [ (r"白嫖", "P0", "9/12 两次实测触发'仅自己可见'软限流", "直接删,靠结果感钩子"), (r"0\s*元|¥\s*0|零元", "P0", "价格诱导词,封面OCR尤其敏感", "删,免费靠'登录就能学'暗示"), (r"免费(领取|白拿|白送|获得|获取)", "P0", "价格诱导组合", "删或改'登录就能学'"), (r"官方.{0,6}(免费|白嫖).{0,6}(拿证|证书|徽章)", "P0", "'免费+官方+拿证'三词连用触发营销标签", "三词拆开"), (r"答案.{0,4}(合集|PDF|文档).{0,4}(主页群|群|自取)", "P0", "答案+资料+主页群 导流诱导高危", "改'攻略整理成文档,主页可看'"), (r"免费证书|AI证书|免费课程|白嫖快乐", "P0", "营销诱导敏感标签/词", "删,保留中性词"), (r"LinkedIn|领英学习|领英", "P0", "外部平台名,导流站外", "只写出品方"), (r"微信号|vx|卫星|加V|私我|私信我", "P0", "站外导流", "不写,转化走主页简介"), ] ``` The documented P0 threshold for two or more occurrences of the relevant term is calculated only as an informational message. It does not add a P0 hit or affect the exit status: ```python # 免费出现次数统计 free_count = len(re.findall(r"免费", all_text)) print(f"\n[提示] 「免费」全文出现 {free_count} 次(≥2 次建议削减到 1 次)") print("\n" + "=" * 50) if hits_p0: print("结论:❌ 有 P0 硬词,需修改后再发布") return 1 else: print("结论:✅ 无 P0 硬词,可发布(P1/P2 若命中建议顺手改)") return 0 ``` The canonical documentation identifies additional external-platform terms and the occurrence threshold as prohibited rules: ```markdown | 免费(全文≥2次) | P0 | 「免费+官方+拿证」组合触发营销标签 | 全篇最多留 1 次,其余删或改"不用付费→登录就能学" | 2026-09-13 | ``` ```markdown | GitHub / ClawHub / 公众号 | 不写平台名,只写工具/作品名 | ``` ### Technical Analysis The Skill describes `references/prohibited-words.md` as its single source of t ...[truncated 2222 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Establish one machine-readable source of truth** - Move every rule into a structured format such as JSON, YAML, TOML, or a Python data module. - Include the pattern, severity, context, explanation, replacement guidance, and admission date. - Generate the human-readable Markdown documentation from this source. 2. **Eliminate manual duplication** - Load the canonical rules directly at runtime or generate the scanner's rule module during the build process. - Fail closed if the canonical rule file is missing, malformed, or contains unsupported entries. 3. **Enforce the documented occurrence threshold** - Add a P0 finding whenever the count reaches the documented threshold: ```python free_count = len(re.findall(r"免费", all_text)) if free_count >= 2: hits_p0.append( ("免费×2+", "P0", "The documented occurrence threshold was reached", "Reduce usage to at most one occurrence") ) ``` 4. **Synchronize all documented prohibited terms** - Add or explicitly reclassify `GitHub`, `ClawHub`, `公众号`, plain `微信`, and every other documented term absent from the executable rules. - Record intentional differences explicitly instead of relying on implicit omissions. 5. **Add rule-parity regression tests** - Verify that every canonical P0 rule produces exit status `1`. - Test exact boundary conditions, including zero, one, and two occurrences. - Test each external-platform term independently. - Verify that malformed rule data produces exit status `2`, not a PASS. 6. **Add consistency validation** - Include a CI check that compares documented rules with executable rules. - Reject releases when a documented P0 rule lacks an executable test or implementation. ]]>
