T09 · Insecure Skill Coding Practices
- Location
src/subtitle.py:158- Finding
Full Session Cookies Sent to an Unvalidated API-Provided 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, ) ``` `main.py:52-61` supplies this authentication object to the subtitle module even though public subtitle operations do not normally require authentication: ```python # Initialize all modules self.hot_monitor = HotMonitor(auth=self.auth) self.downloader = BilibiliDownloader(auth=self.auth) self.watcher = BilibiliWatcher(auth=self.auth) self.player = BilibiliPlayer(auth=self.auth) self.subtitle = SubtitleDownloader( auth=self.auth, downloader=self.downloader, player=self.player, ) ``` `src/subtitle.py:158-164` takes a URL returned by the remote API and requests it through the authenticated client without validating the destination: ```python # 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 authentication client is initialized with the complete cookie set returned by `self.cookies`, including `SESSDATA`, `bili_jct`, and `buvid3`. These are full browser-session credentials rather than narrowly scoped API tokens. The subtitle URL originates in the Bilibili subtitle metadata response and is not checked against an HTTPS ho ...[truncated 2242 chars]- Remediation
View remediation
