T09 · Insecure Skill Coding Practices
- Location
scripts/check-takeover.sh:103- Finding
Blind Server-Side Request Forgery Through Unvalidated Domain Resolution
- Content
View full analysis
Vulnerability Details
File Location:
scripts/check-takeover.sh, lines 103-114
Vulnerability Type: Blind Server-Side Request Forgery (SSRF)
Risk Level: Mediumbash # Check against vulnerable patterns for pattern_entry in "${VULN_PATTERNS[@]}"; do local pattern="${pattern_entry%%:*}" local service="${pattern_entry##*:}" if [[ "$cname" == *"$pattern"* ]]; then if [ "$PASSIVE" = "0" ]; then # Verify with HTTP check — NXDOMAIN or error page = vulnerable local http_code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://$domain" 2>/dev/null || echo "000") if [ "$http_code" = "404" ] || [ "$http_code" = "000" ]; then VULN_COUNT=$((VULN_COUNT + 1)) RESULTS+="⚠️ $domain → $cname ($service — potentially claimable)\n" return fiTechnical Analysis
The script accepts domains from a user-controlled command-line argument or input file and issues an HTTP request to each qualifying domain. Before invoking
curl, it does not resolve and reject loopback, private, link-local, reserved, multicast, or cloud metadata addresses.The CNAME allowlist check does not adequately mitigate this behavior because it performs loose substring matching:
bash if [[ "$cname" == *"$pattern"* ]]; thenConsequently, an attacker-controlled CNAME such as
github.io.attacker.examplecan satisfy thegithub.iopattern without being part of the legitimategithub.ioDNS namespace. The attacker can configure that hostname to resolve to an internal address. DNS rebinding can also change the resolved address between the script'sdigoperation and the subsequentcurlrequest.The response body is discarded, but the resulting HTTP status influences the reported result. The vulnerability therefore provides a blind SSRF and network-probing primitive rather than direct response-content dis ...[truncated 1583 chars]
- Remediation
View remediation
Remediation Suggestions
- Require users to provide an explicit, authorized domain scope and reject inputs outside that scope.
- Validate each input as a hostname before passing it to DNS tools or
curl. - Replace substring matching with DNS-label-aware suffix matching. A provider pattern should match only the exact provider domain or a genuine subdomain separated by a dot.
- Resolve the destination before making an HTTP request and reject every returned IPv4 and IPv6 address belonging to loopback, private, link-local, multicast, reserved, documentation, unspecified, carrier-grade NAT, and cloud metadata ranges.
- Protect against DNS rebinding by pinning
curlto the previously validated address, for example with an appropriately constructed--resolveentry. Revalidate every address in the DNS response and do not follow redirects to unvalidated destinations. - Disable redirects unless necessary. If redirects are enabled later, validate the scheme, hostname, port, and resolved addresses at every redirect.
- Permit only
httpandhttps, restrict destination ports to those genuinely required, and apply network-level egress controls so the process cannot access internal or metadata networks. - Treat HTTP status codes and transport failures only as signals for manual review. A
404or000response alone does not establish that a hosted resource is claimable.
