T09 · Insecure Skill Coding Practices
- Location
scripts/fetch_afad_earthquakes.py:37- Finding
Unrestricted Source URL Override Enables Server-Side Request Forgery
- Content
View full analysis
list[dict[str, Any]]: url = build_url(source_url=source_url, window=window) request = Request( url, headers={ "Accept": "application/json", "User-Agent": "turkiye-afad-deprem-skill/0.1", }, method="GET", ) try: with urlopen(request, timeout=timeout) as response: status = getattr(response, "status", 200) if int(status) >= 400: raise AppError( "HTTP_ERROR", f"AFAD servisi HTTP {status} dondu", exit_code=4, ) ``` ```python # scripts/fetch_afad_earthquakes.py:345-352 if args.fixture: raw_events = load_fixture(args.fixture) else: raw_events = fetch_events( source_url=args.source_url, timeout=args.timeout, window=window, ) ``` ### Technical Analysis The `--source-url` command-line argument is passed directly into `build_url()` and then to `urllib.request.urlopen()` without validating the URL scheme, destination hostname, port, or resolved IP address. The implementation does not restrict requests to the documented AFAD endpoint. Consequently, a caller who can influence invocation arguments can cause the process to issue HTTP GET requests to arbitrary reachable services. Potential destinations include loopback addresses, private network ranges, link-local a ...[truncated 2461 chars]- Remediation
View remediation
