T09 · Insecure Skill Coding Practices
- Location
scripts/video_fetcher.py:51- Finding
Weak URL and Redirect Validation Permits Server-Side Request Forgery
- Content
View full analysis
str: """识别链接平台:bilibili / douyin / youtube / xiaohongshu / unknown""" t = text.lower() if "bilibili.com" in t or re.search(r"(BV[0-9A-Za-z]{10})", t, re.IGNORECASE): return "bilibili" if "douyin.com" in t or "tiktok.com" in t: return "douyin" if "youtube.com" in t or "youtu.be" in t: return "youtube" if "xiaohongshu.com" in t or "xhslink.com" in t or "xhs.cn" in t: return "xiaohongshu" return "unknown" ``` From `scripts/video_fetcher.py:196-226`: ```python def resolve_douyin_url(short_url: str) -> str: """解析抖音短链接,获取重定向后的实际 URL""" try: req = urllib.request.Request(short_url, headers={ "User-Agent": HEADERS["User-Agent"], }) opener = urllib.request.build_opener(urllib.request.HTTPRedirectHandler) resp = opener.open(req, timeout=10) return resp.url except Exception as e: print(f"[!] 解析短链接失败: {e}", file=sys.stderr) return short_url def fetch_douyin_info(url: str) -> dict: """获取抖音视频基本信息(通过网页解析,无需API Key)""" if "v.douyin.com" in url: url = resolve_douyin_url(url) print(f"[*] 抖音实际链接: {url}", file=sys.stderr) video_id = "" m = re.search(r"/video/(\d+)", url) if m: video_id = m.group(1) try: req = urllib.request.Request(url, headers={ "User-Agent": HEADERS["User-Agent"], "Referer": "https://www.douyin.com/", ...[truncated 3789 chars]- Remediation
View remediation
