T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/cdp_xhs_publish.py:436
- Finding
- Live Publishing Is Enabled by Default Despite the Documented Opt-In Safety Contract<![CDATA[ ## Vulnerability Details **File Location**: `scripts/cdp_xhs_publish.py:436-459` **Vulnerability Type**: Default-allow handling of a consequential external action **Risk Level**: Medium ### Vulnerable Code ```python no_publish = os.environ.get("XHS_NO_PUBLISH", "").strip() in ("1", "true", "yes") if no_publish: print("XHS: content filled. Skipping live Ops (XHS_NO_PUBLISH=1).") else: ``` The default branch eventually performs the live publication action: ```python js_eval(ws, "(function(){window.scrollTo(0,document.body.scrollHeight);return 'SCROLLED';})()") time.sleep(1) r3 = js_eval(ws, PUBLISH_JS) ``` ### Technical Analysis The script header states that the live publication action requires the explicit `XHS_AUTO_PUBLISH=1` opt-in. The implementation never checks that variable. Instead, it publishes unless the caller knows to set the inverse `XHS_NO_PUBLISH` variable. This is a fail-open design for a consequential external action. A caller following the documented interface can reasonably expect draft-only behavior when `XHS_AUTO_PUBLISH` is absent, but the implementation proceeds through formatting, navigation, publication, and confirmation. The script controls an already authenticated Xiaohongshu browser tab through CDP. Therefore, the publication occurs with the privileges of the user currently signed in to that browser profile. ### Attack Path 1. A user opens an authenticated Xiaohongshu creator session with CDP enabled. 2. The user or an automation workflow invokes `cdp_xhs_publish.py` with a title and body. 3. The caller does not set `XHS_AUTO_PUBLISH=1`, relying on the documented opt-in contract. 4. The caller also does not set the undocumented inverse safety flag `XHS_NO_PUBLISH=1`. 5. The script enters the default `else` branch. 6. It clicks the live publication control and subsequently attempts to confirm publication. 7. The supplied content is published or submitted for review without the documented opt-in. ### Impact Assess ...[truncated 458 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Make draft-only behavior the default. 2. Require the documented positive opt-in before any live publication action: ```python auto_publish = os.environ.get("XHS_AUTO_PUBLISH", "").strip().lower() in { "1", "true", "yes" } if not auto_publish: print("Content filled. Live publication was not requested.") return ``` 3. Remove or deprecate the inverse `XHS_NO_PUBLISH` control to avoid conflicting configuration semantics. 4. Require a separate final confirmation immediately before clicking the live publication control. 5. Display the target account, title, and a content preview before confirmation. 6. Add automated tests proving that publication cannot occur when the opt-in variable is absent, empty, malformed, or false. 7. Update the Skill documentation and wrapper scripts so all entry points use the same publication-consent policy. ]]>
