T09 · Insecure Skill Coding Practices
- Location
scripts/profile.py:125- Finding
Server-Side Request Forgery Through an Unvalidated User-Controlled Domain
- Content
View full analysis
Optional[str]: """获取网页内容""" if not REQUESTS_AVAILABLE: return None try: resp = requests.get(url, headers=DEFAULT_HEADERS, timeout=timeout) resp.raise_for_status() return resp.text except Exception as e: return None ``` The user-controlled domain is inserted directly into request URLs: ```python def analyze_company(company: str, domain: str = None, deep: bool = False) -> dict: """分析公司技术栈""" if domain is None: # 从公司名推断域名 domain = company.lower().replace(" ", "").replace(",", "") + ".com" # ... urls_to_check = [f"https://{domain}"] if deep: urls_to_check.extend([ f"https://{domain}/careers", f"https://{domain}/about", f"https://{domain}/technology", ]) # ... for url in urls_to_check: html = fetch_url(url) ``` The domain originates from an unrestricted command-line argument: ```python parser.add_argument("--company", type=str, help="公司名称 (二选一)") parser.add_argument("--domain", type=str, help="公司域名 (二选一)") # ... if not args.company and not args.domain: parser.error("必须提供 --company 或 --domain") company = args.company or args.domain.split(".")[0].capitalize() domain = args.domain or None # ... profile = analyze_company(company, domain, args.deep) ``` ### Technical Analysis The `--domain` value is not validated as a conventional public DNS hostname before it is interpolated into an HTTPS URL and passed to `requests.get`. The implementation does not resolve the destination and reject loopbac ...[truncated 2543 chars]- Remediation
View remediation
