T09 · Insecure Skill Coding Practices
- Location
scripts/alarm_query.py:750- Finding
Bearer token disclosure through unvalidated snapshot URLs
- Content
View full analysis
str: """Normalize the snapshot address into an absolute downloadable URL.""" if not snapshot_url: return snapshot_url parsed = urlparse(snapshot_url) if parsed.scheme and parsed.netloc: return snapshot_url return urljoin( f"{self._build_service_base_url(self.config.media_service_port).rstrip('/')}/", snapshot_url.lstrip("/") ) ``` ```python def _materialize_snapshot_from_url(self, snapshot: Dict[str, Any]) -> Optional[str]: """Download a snapshot URL locally so the upper layer can send the image.""" local_path = snapshot.get("local_path") if local_path not in (None, ""): return None snapshot_url = snapshot.get("url") if snapshot_url in (None, ""): return None resolved_url = self._resolve_snapshot_url(str(snapshot_url)) headers = {} if self.token: headers["Authorization"] = f"Bearer {self.token}" try: response = self.session.get( resolved_url, headers=headers, timeout=self.config.timeout ) response.raise_for_status() except requests.exceptions.RequestException as exc: message = f"Snapshot URL download failed: {exc}" logger.warning(message) return message ``` ### Technical Analysis The media API can return a snapshot record containing a URL. When that URL is absolute, `_resolve_snapshot_url()` accepts it without validating its scheme, hostname, or port. `_materialize_snapshot_from_url()` then attaches the local VisPatrol bearer token to the resulting request regardless of its destination. Consequently, a compromised or malicious media service can cause the ...[truncated 1718 chars]- Remediation
View remediation
