T09 · Insecure Skill Coding Practices
Error
- Location
- patch_lnk.py:18
- Finding
- Persistent Unauthenticated CDP Access to the User's Authenticated Browser Profile<![CDATA[ ## Vulnerability Details **File Location**: `patch_lnk.py:18-26`, `patch_lnk.py:91-103`, `qw.cjs:47-48`, `qw.cjs:168-172` **Vulnerability Type**: Persistent exposure of a privileged browser debugging interface **Risk Level**: High ### Vulnerable Code ```python PORT_ARG = "--remote-debugging-port=9666" # Four Qianwen shortcuts: Start Menu, Desktop, Taskbar, and Quick Launch LNK_PATHS = [ os.path.expandvars(r"%APPDATA%\Microsoft\Windows\Start Menu\Programs\千问.lnk"), os.path.expandvars(r"%USERPROFILE%\Desktop\常用软件\千问.lnk"), os.path.expandvars(r"%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\千问.lnk"), os.path.expandvars(r"%APPDATA%\Microsoft\Internet Explorer\Quick Launch\千问.lnk"), ] ``` ```python new_args = (old_args + " " + PORT_ARG).strip() new_length = len(new_args) + 1 # includes null new_bytes = struct.pack("<H", new_length) + (new_args + "\x00").encode("utf-16-le") info = {"path": path, "old_args": old_args, "new_args": new_args, "old_len": a_end - a_start, "new_len": len(new_bytes)} if apply: new_data = data[:a_start] + new_bytes + data[a_end:] with open(path, "wb") as f: f.write(new_data) info["status"] = "PATCHED" ``` ```javascript const QW_PROFILE = process.env.QW_PROFILE || path.join(HOME, 'AppData', 'Local', 'Qianwen', 'User Data'); const CDP_PORT = Number(process.env.QW_CDP_PORT) || 9666; ``` ```javascript const child = spawn(QW_EXE, [ '--remote-debugging-port=' + CDP_PORT, '--user-data-dir=' + QW_PROFILE, '--no-first-run', '--no-default-browser-check', ], { detached: true, stdio: 'ignore' }); child.unref(); ``` ### Technical Analysis The shortcut patcher persistently adds `--remote-debugging-port=9666` to four user launch entries. Consequently, subsequent browser launches expose Chrome DevTools Protocol even when no active automation task requires it. The browser is also configured to use the user's real Qianwen profile. This profile may contain authentica ...[truncated 2070 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not modify persistent browser shortcuts by default. 2. Enable CDP only after explicit user authorization for a specific automation session. 3. Use a dedicated automation profile that does not contain the user's general-purpose authenticated sessions. 4. Select a random ephemeral port for each session instead of a fixed, predictable port. 5. Start the browser only for the duration of the requested operation and terminate it cleanly afterward. 6. Verify that the debugging port is closed when automation completes. 7. If the real profile is strictly required, display a clear warning that local processes can access the debugging interface. 8. Provide an automatic rollback mechanism that removes the debugging argument from every modified shortcut. 9. Restrict filesystem permissions on launch entries and relevant profile directories where possible. 10. Consider a broker process that authenticates and authorizes a limited set of browser operations instead of exposing unrestricted CDP. ]]>
