Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing URL normalization for HTTP_PROXY and HTTPS_PROXY #16182

Open
LorenzoLeonardini opened this issue Jan 6, 2025 · 0 comments
Open

Missing URL normalization for HTTP_PROXY and HTTPS_PROXY #16182

LorenzoLeonardini opened this issue Jan 6, 2025 · 0 comments

Comments

@LorenzoLeonardini
Copy link

LorenzoLeonardini commented Jan 6, 2025

What version of Bun is running?

1.1.43-debug (f0cb1b7)

The bug

When loading HTTP and HTTPS proxy configurations from the environment, Bun fails to normalize the URLs with WebKit's parser.

Every other occurency of Bun's custom URL parser normalizes the URL with WebKit's parser first (example from response.zig).

This is extremely important, as Bun's URL parser is extremely naive and subject to many parsing errors. More info about this in the dedicated issue #16183 (this is kept separate, as with proper URL normalization it's not something that really needs fixing, at least until some other bug is found).

Impact

The impact of this is quite limited, as one would need to inject badly formatted URLs in the environment variable, and would only be useful to bypass whitelist URL checks performed with another parser (or with normalized URLs). What I mean is that something like this could be bypassed:

if (process.env.HTTP_PROXY) {
  const u = new URL(process.env.HTTP_PROXY);
  if (u.hostname !== "example.com" && u.hostname !== "bun.sh") {
    throw new Error("Invalid proxy");
  }
}

As you can see, the scenario is very specific.

However, it's important to add the normalization in order to make URLs consistent everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant