T09 · Insecure Skill Coding Practices
- Location
src/subtitle.py:140- Finding
Authenticated Bilibili session cookies can be disclosed to an unvalidated subtitle URL
- Content
View full analysis
httpx.AsyncClient: """Create an authenticated async HTTP client. Returns: httpx.AsyncClient configured with credentials. """ return httpx.AsyncClient( headers=self.get_headers(), cookies=self.cookies, timeout=30.0, follow_redirects=True, ) ``` ```python # src/subtitle.py:79-87 for sub in subtitles_info.get("subtitles", []): subtitles.append({ "id": sub.get("id"), "language": sub.get("lan"), "language_name": sub.get("lan_doc"), "url": sub.get("subtitle_url"), "ai_type": sub.get("ai_type", 0), "ai_status": sub.get("ai_status", 0), }) ``` ```python # src/subtitle.py:140-146 # Download subtitle JSON sub_url = target_sub["url"] if sub_url.startswith("//"): sub_url = "https:" + sub_url async with self._get_client() as client: resp = await client.get(sub_url) sub_data = resp.json() ``` ### Technical Analysis The subtitle URL originates in a Bilibili API response and is used as an outbound request destination without validating its scheme or hostname. When a `BilibiliAuth` object is present, `SubtitleDownloader._get_client()` returns the generic authenticated client produced by `BilibiliAuth.get_client()`. That client contains the following sensitive cookies: - `SESSDATA` - `bili_jct` - `buvid3` The client is also configured with `follow_redirects=True`. Consequently, subtitle content is fetched using a client holding account credentials even though downloading the subtitle body does not require authenticated cookies. The implementation does not enforce the domain allowlist declared in ` ...[truncated 1720 chars]- Remediation
View remediation
