T09 · Insecure Skill Coding Practices
- Location
scripts/book_fetch.py:103- Finding
Unvalidated Remote URLs and Redirects Permit Server-Side Request Forgery
- Content
View full analysis
str | None: """Fetch libgen.li ads page and extract the get.php direct link.""" try: resp = session.get(ads_url, timeout=15) resp.raise_for_status() soup = BeautifulSoup(resp.text, "lxml") for a in soup.select("a[href]"): href = a.get("href", "") if "get.php" in href and "md5=" in href and "key=" in href: return urljoin("https://libgen.li/", href) except Exception as e: print(f" libgen.li resolve failed: {e}") return None ``` ```python def download_file(url: str, dest_dir: Path, filename: str) -> Path | None: """Download file with progress bar.""" dest_dir.mkdir(parents=True, exist_ok=True) dest = dest_dir / filename print(f"⬇️ Downloading -> {dest}") try: resp = session.get(url, stream=True, timeout=60, allow_redirects=True) resp.raise_for_status() ``` ### Technical Analysis The application extracts links from remotely supplied H ...[truncated 2607 chars]- Remediation
View remediation
