T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/publish.py:17
- Finding
- Authenticated Browser Data Persisted in Unprotected Diagnostic Files## Vulnerability Details **File Location**: `scripts/publish.py:17-26, 83-85, 296-301, 327-332` **Vulnerability Type**: Plaintext storage of sensitive authenticated page data **Risk Level**: Medium ### Vulnerable Code ```python # Screenshot directory SCREENSHOT_DIR = get_subdir("screenshots") ``` ```python def save_shot(page, name: str) -> str: """Save screenshot""" timestamp = time.strftime("%Y%m%d_%H%M%S") path = SCREENSHOT_DIR / f"{timestamp}_{name}.png" page.screenshot(path=str(path)) print(f"[Screenshot] {path}") return str(path) ``` ```python page.goto("https://creator.xiaohongshu.com/publish/publish", timeout=30000) page.wait_for_timeout(3000) save_shot(page, "01_landing") ``` ```python if not editor_ready: save_shot(page, "03c_editor_not_ready") # Dump HTML for debugging try: html = page.content() debug_path = SCREENSHOT_DIR / f"{time.strftime('%Y%m%d_%H%M%S')}_page_debug.html" debug_path.write_text(html, encoding="utf-8") print(f"[Debug] Page HTML saved to: {debug_path}") except Exception: pass ``` ```python if not editor_found: print("[ERROR] Content editor not found!") save_shot(page, "04_editor_not_found") # Dump page HTML for debugging try: html = page.content() debug_path = SCREENSHOT_DIR / f"{time.strftime('%Y%m%d_%H%M%S')}_page_debug.html" debug_path.write_text(html, encoding="utf-8") print(f"[Debug] Page HTML saved to: {debug_path}") except Exception: pass raise Exception("Content editor not found") ``` ### Technical Analysis The publishing workflow runs inside an authenticated Xiaohongshu creator session. It automatically captures screenshots at multiple stages and writes the complete authenticated page DOM to disk when editor detection fails. These diagnostic artifacts may contain account identifiers, unpublished post content, uploaded media previews, creator-page state, or other private info ...[truncated 1965 chars]
- Remediation
- ## Remediation Suggestions 1. Make all screenshots and HTML dumps opt-in through an explicit option such as `--debug`. 2. Disable full authenticated DOM dumps by default. Prefer narrowly scoped diagnostic metadata, such as selector states and sanitized error messages. 3. Redact account identifiers, post text, image previews, tokens, URLs containing sensitive parameters, and hidden fields before saving diagnostics. 4. Create diagnostic directories and files with owner-only permissions, such as `0700` for directories and `0600` for files where supported. 5. Add retention controls and automatically delete diagnostics after a short configurable period. 6. Warn users before capturing authenticated content and clearly identify the storage location. 7. Ensure `.local/`, browser profiles, screenshots, and HTML dumps are excluded from version control, cloud synchronization, and routine backups where appropriate. 8. Provide a cleanup command that securely removes retained screenshots, DOM dumps, and temporary browser data. 9. Separate routine operational screenshots from failure diagnostics and avoid capturing pages unless the image is necessary to diagnose a specific error.
