T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/download_tiktok.sh:20
- Finding
- Persistent Browser Profile Exposed to Cookie-Assisted Downloader<![CDATA[ ## Vulnerability Details **File Location**: `scripts/download_tiktok.sh`, lines 8 and 20-21; supporting instructions in `SKILL.md`, lines 19-21 and 29 **Vulnerability Type**: Excessive access to persistent browser session data **Risk Level**: Medium ### Vulnerable Code ```bash COOKIES_DIR="/home/ubuntu/.browser_data_dir" ``` ```bash # Try with cookies and custom user-agent yt-dlp --no-warnings \ --cookies-from-browser "chromium:$COOKIES_DIR" \ --user-agent "$USER_AGENT" \ --add-header "Referer:https://www.tiktok.com/" \ -o "$OUTPUT_DIR/%(uploader)s - %(title).80s.%(ext)s" \ "$URL" ``` The associated instructions explicitly recommend populating and reusing this browser profile: ```markdown 1. **Navigate to the URL** using the browser tool to establish a session and cookies. 2. **Run the script again**. It is pre-configured to extract cookies from the browser's data directory (`/home/ubuntu/.browser_data_dir`). ``` ### Technical Analysis The script grants `yt-dlp` access to the persistent Chromium profile at `/home/ubuntu/.browser_data_dir`. A general browser profile can contain authentication cookies and other session information for services beyond the public TikTok download operation. This violates least-privilege principles because the task requires, at most, narrowly scoped TikTok authentication data. The implementation does not use a dedicated TikTok-only profile, request explicit consent before accessing authenticated browser state, or validate that the supplied URL belongs to an approved TikTok hostname. Browser cookie domain restrictions normally prevent unrelated cookies from being attached to arbitrary domains, and the reviewed code contains no explicit cookie-exfiltration routine. Nevertheless, `yt-dlp` receives read access to the broader cookie database, and the arbitrary URL input expands processing beyond the Skill's declared TikTok scope. A compromised, malicious, or unexpectedly behaving downloader could inspect sessi ...[truncated 1840 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Use a dedicated browser profile** - Create a separate Chromium profile used exclusively for TikTok. - Do not point the downloader at a general-purpose or shared browser profile. 2. **Make cookie access opt-in** - Attempt an unauthenticated download first. - Require explicit user approval before reading authenticated browser cookies. - Clearly state which profile and account data will be accessed. 3. **Restrict accepted URLs** - Require HTTPS. - Parse and validate the hostname against an explicit allowlist of supported TikTok domains. - Reject malformed URLs, user-information components, unsupported schemes, and unrelated domains. - Revalidate destinations after redirects where feasible. 4. **Minimize cookie scope** - Prefer a restrictive TikTok-only cookie file instead of the full Chromium profile. - Store the file with owner-only permissions, such as mode `0600`. - Remove temporary cookie exports immediately after use. - Avoid collecting cookies for unrelated services. 5. **Constrain the downloader** - Use a trusted, pinned, and regularly patched `yt-dlp` installation. - Verify the executable path and package provenance. - Run the downloader under a dedicated low-privilege account or sandbox with access only to the output directory and narrowly scoped cookie material. 6. **Improve failure handling** - If cookie extraction is unavailable, fail safely or continue without cookies. - Do not silently broaden access to another browser profile. ]]>
