{"record":{"id":"fe07cb6827570762","repo":"peass-ng/PEASS-ng","slug":"invalid-url-too-many-http-redirects","errorCode":null,"errorMessage":"Invalid URL, too many HTTP redirects","messagePattern":"Invalid URL, too many HTTP redirects","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"metasploit/peass.rb","lineNumber":252,"sourceCode":"      print_good(\"PEASS output saved to: #{command_log}\")\n    \n    rescue ::Exception => e\n      print_bad(\"Error Running PEASS: #{e.class} #{e}\")\n    end\n    \n    # Close and delete the temporary file\n    file.close\n    file.unlink\n  end\n\n  def on_request_uri(cli, request)\n    print_status(\"HTTP request received\")\n    send_response(cli, File.read(@temp_file_path), {'Content-Type'=>'text/plain'})\n    print_good(\"PEASS script sent\")\n  end\n\n  def fetch(uri_str, limit = 10)\n    raise 'Invalid URL, too many HTTP redirects' if limit == 0\n    response = Net::HTTP.get_response(URI(uri_str))\n    case response\n    when Net::HTTPSuccess then\n      response\n    when Net::HTTPRedirection then\n      location = response['location']\n      fetch(location, limit - 1)\n    else\n      response.value\n    end\n  end\n \n  def load_peass\n    # Load the PEASS script from a local file or from Internet\n    peass_script = \"\"\n    url_peass = \"\"\n    # If no URL is set, use the default one\n    if datastore['CUSTOM_URL'] != \"\"","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/peass-ng/PEASS-ng/blob/53fb989abc2219826385683a6fee826bd6cd38d6/metasploit/peass.rb#L234-L270","documentation":"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.","triggerScenarios":"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.","commonSituations":"Self-hosted mirror with a redirect loop (http->https->http), shortener services chaining many hops, stale DNS/proxy setups.","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"],"exampleFix":"# before\nres = fetch('http://my-mirror.local/peass')\n# after\nres = fetch('https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh')","handlingStrategy":"retry","validationCode":"# inspect redirect chain before fetching\ncurl -sIL --max-redirs 10 https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh > /dev/null && echo OK","typeGuard":null,"tryCatchPattern":"begin\n  res = fetch(target)\nrescue RuntimeError => e\n  raise unless e.message.include?('too many HTTP redirects')\n  print_warning(\"Redirect loop at #{uri_str}; trying canonical release URL\")\n  res = fetch('https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh', 15)\nend","preventionTips":["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"],"tags":["http","redirect","network"],"backgroundTag":"too-many-http-redirects","analyzedSha":"53fb989abc2219826385683a6fee826bd6cd38d6","analyzedAt":"2026-09-02T04:25:09.259Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}