T09 · Insecure Skill Coding Practices
- Location
scripts/link-fix.sh.txt:114- Finding
Unrestricted URL Validation Permits Blind SSRF and Sensitive URL Disclosure
- Content
View full analysis
/dev/null } ``` The variation logic also constructs and requests alternate destinations, including an HTTPS-to-HTTP downgrade: ```bash find_variation() { local url="$1" scheme rest host path cand scheme="${url%%://*}" rest="${url#*://}" host="${rest%%/*}" if [ "$rest" = "$host" ]; then path=""; else path="/${rest#*/}"; fi local cands=() case "$scheme" in http) cands+=("https://${host}${path}") ;; https) cands+=("http://${host}${path}") ;; esac if [[ "$host" == www.* ]]; then cands+=("${scheme}://${host#www.}${path}") else cands+=("${scheme}://www.${host}${path}") fi if [ -n "$path" ] && [[ "$path" != */ ]] && [[ "${path##*/}" != *.* ]]; then cands+=("${url%/}/") fi for cand in "${cands[@]}"; do [ "$cand" = "$url" ] && continue [ "$(http_status "$cand")" = "200" ] && { printf '%s' "$cand"; return 0; } done return 1 } ``` Extracted URLs are automatically passed to the network request function: ```bash for url in "${urls[@]}"; do status="$(http_status "$url")" [ "$status" = "200" ] && continue printf ' BROKEN (%s) %s\n' "$status" "$url" alts="" [ "$HAVE_PARAMS" = "1" ] && alts="$(suggest_alts "$url" 6)" B_FILE+=("$file"); B_URL+=("$url"); B_STATUS+=("$status"); B_ALT+=("$alts") done ``` #### PowerShell implementation ```powershell function Get-HttpStatus { param([string]$Url) try { $resp = Invoke-WebRequest -Uri $Url -MaximumRedirection 5 -TimeoutSec $TIMEOUT ` -UserAgent $UA -ErrorA ...[truncated 4865 chars]- Remediation
View remediation
