peass-ng/PEASS-ng · error · RuntimeError
Invalid URL, too many HTTP redirects
Error message
Invalid URL, too many HTTP redirects
What it means
peass.rb's fetch() follows HTTP redirects recursively with a limit of 10; when the limit hits 0 it raises this error. It means the PEASS URL caused too many (or infinite) redirects, so a valid response could never be retrieved.
Source
Thrown at metasploit/peass.rb:252
print_good("PEASS output saved to: #{command_log}")
rescue ::Exception => e
print_bad("Error Running PEASS: #{e.class} #{e}")
end
# Close and delete the temporary file
file.close
file.unlink
end
def on_request_uri(cli, request)
print_status("HTTP request received")
send_response(cli, File.read(@temp_file_path), {'Content-Type'=>'text/plain'})
print_good("PEASS script sent")
end
def fetch(uri_str, limit = 10)
raise 'Invalid URL, too many HTTP redirects' if limit == 0
response = Net::HTTP.get_response(URI(uri_str))
case response
when Net::HTTPSuccess then
response
when Net::HTTPRedirection then
location = response['location']
fetch(location, limit - 1)
else
response.value
end
end
def load_peass
# Load the PEASS script from a local file or from Internet
peass_script = ""
url_peass = ""
# If no URL is set, use the default one
if datastore['CUSTOM_URL'] != ""View on GitHub (pinned to 53fb989abc)
Solutions
- Fix the target URL so it points directly at the PEASS release (avoid redirect loops)
- Use the canonical GitHub release URL (https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh)
- Increase the limit argument if the chain is legitimately long: fetch(uri, 20)
- Test the URL with curl -IL to inspect the redirect chain
Example fix
# before
res = fetch('http://my-mirror.local/peass')
# after
res = fetch('https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh') Defensive patterns
Strategy: retry
Validate before calling
# inspect redirect chain before fetching curl -sIL --max-redirs 10 https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh > /dev/null && echo OK
Try / catch
begin
res = fetch(target)
rescue RuntimeError => e
raise unless e.message.include?('too many HTTP redirects')
print_warning("Redirect loop at #{uri_str}; trying canonical release URL")
res = fetch('https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh', 15)
end Prevention
- Use the official GitHub release URL to avoid redirect chains
- Trace redirects with curl -IL when using custom mirrors
- Avoid http->https->http redirect loops on self-hosted mirrors
When it happens
Trigger: Calling fetch(uri) (directly or via load_peass) with a URI that redirects more than 10 times, e.g. a redirect loop or a misconfigured custom WINPEASS/PEASS URL.
Common situations: Self-hosted mirror with a redirect loop (http->https->http), shortener services chaining many hops, stale DNS/proxy setups.
Related errors
- Something failed downloading PEASS script from #{url_peass}
- Neither curl nor wget were found in victim, unset the SRVHOS
- Invalid URL
- Network path is not allowed for directory junction: [{0}]
- MoveOptions.DelayUntilReboot is not allowed when using a net
AI-assisted analysis of peass-ng/PEASS-ng@53fb989abc (2026-09-02).
Data as JSON: /api/errors/fe07cb6827570762.
Report an issue: GitHub.