question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Requests that follow a redirect are not passing via the proxy

See original GitHub issue

Describe the bug

In cases where axios is used by servers to perform http requests to user-supplied urls, a proxy is commonly used to protect internal networks from unauthorized access and SSRF. This bug enables an attacker to bypass the proxy by providing a url that responds with a redirect to a restricted host/ip.

To Reproduce

The following code spawns a proxy server that always responds with a 302 redirect, so requests should never reach the target url, however, axios is only reaching the proxy once, and bypassing the proxy after the redirect response.

https://runkit.com/embed/1df5qy8lbgnc

const axios = require('axios')
const http = require('http')

const PROXY_PORT = 8080

// A fake proxy server
http.createServer(function (req, res) { 
    res.writeHead(302, {location: 'http://example.com'})
    res.end()
  }).listen(PROXY_PORT)

axios({
  method: "get",
  url: "http://www.google.com/",
  proxy: {
    host: "localhost",
    port: PROXY_PORT,
  },
})
.then((r) => console.log(r.data))
.catch(console.error)

The response is the rendered html of http://example.com

Expected behavior

All the requests should pass via the proxy. In the provided scenario, there should be a redirect loop.

Environment

  • Axios Version [0.21.0]
  • Node.js Version [v12.18.2]

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:32
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

39reactions
mdeknowiscommented, Dec 3, 2020

Hallo, is there any schedule to release 0.21.1, so the vulnerability is fixed and all dependent projects can fix their vulnerabilities?

5reactions
timemachine3030commented, Nov 15, 2020

Anyone listening on this issue, Code review of #3410 is needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python requests with proxy can't follow redirects - Stack Overflow
I made a python request to netflix with a proxy and the results could not but if not using a proxy he could...
Read more >
Reverse Proxy and HTTP Redirects - Apache Traffic Server
As a reverse proxy cache, Traffic Server serves requests on behalf of origin servers. Traffic Server is configured in such a way that...
Read more >
IE does not follow a 302 redirect properly from a proxy over SSL
I have a proxy that produces a progress page when a download is initiated from a client browsing through it. When the request...
Read more >
Proxy (or redirect?) request per location - Server Fault
First, the ProxyPass is not a redirection i.e. location doesn't change. It is a reverse proxy that obtains the content from external source....
Read more >
Request Options - Guzzle Documentation
You can also pass an associative array containing the following key value pairs: ... This option has no effect when making requests using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found