Skip to content

fix: respect NO_PROXY CIDR notation in Vault CLI HTTP client#31976

Open
RoySerbi wants to merge 1 commit into
hashicorp:mainfrom
RoySerbi:fix/no-proxy-cidr
Open

fix: respect NO_PROXY CIDR notation in Vault CLI HTTP client#31976
RoySerbi wants to merge 1 commit into
hashicorp:mainfrom
RoySerbi:fix/no-proxy-cidr

Conversation

@RoySerbi
Copy link
Copy Markdown

What this does

Fixes #31954

When VAULT_HTTP_PROXY or VAULT_PROXY_ADDR is set, the Vault CLI uses http.ProxyURL() which always routes through the proxy regardless of NO_PROXY entries. This means CIDR notation in NO_PROXY (e.g., 10.66.0.0/16) is ignored.

Root cause

In api/client.go, the proxy is configured with:

transport.Proxy = http.ProxyURL(u)

http.ProxyURL returns a function that always returns the given proxy URL, completely ignoring the NO_PROXY environment variable.

Fix

Replace http.ProxyURL() with a custom proxy function that checks NO_PROXY entries before routing through the proxy, supporting:

  • Exact hostname matching (localhost)
  • Domain suffix matching (.mycompany.tld)
  • CIDR subnet matching (10.66.0.0/16)

When a host matches a NO_PROXY entry, the proxy is bypassed (returns nil, nil).

When VAULT_HTTP_PROXY or VAULT_PROXY_ADDR is set, the Vault CLI uses
http.ProxyURL() which always routes through the proxy regardless of
NO_PROXY entries. This means CIDR notation in NO_PROXY (e.g.,
10.66.0.0/16) is ignored.

This fix replaces http.ProxyURL() with a custom proxy function that
checks NO_PROXY entries before routing through the proxy, supporting:
- Exact hostname matching
- Domain suffix matching (.example.com)
- CIDR subnet matching (10.66.0.0/16)

Fixes hashicorp#31954

Signed-off-by: RoySerbi <roy676564@gmail.com>
@RoySerbi RoySerbi requested a review from a team as a code owner May 31, 2026 10:15
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

@RoySerbi is attempting to deploy a commit to the HashiCorp Team on Vercel.

A member of the Team first needs to authorize it.

@RoySerbi RoySerbi requested a review from sukanya-prakash May 31, 2026 10:15
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Used to indicate a potential bug core/client labels May 31, 2026
@hashicorp-cla-app
Copy link
Copy Markdown

hashicorp-cla-app Bot commented May 31, 2026

CLA assistant check
All committers have signed the CLA.

@hashicorp-cla-app
Copy link
Copy Markdown

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Used to indicate a potential bug core/client size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CIDR notation in NO_PROXY is not evaluated

1 participant