fix: keep TLS verification on by default behind a proxy#7
Open
enieuwy wants to merge 1 commit into
Open
Conversation
http_utils disabled certificate verification for *all* requests as soon as any HTTP(S)_PROXY env var was present. That silently exposed every request -- including authenticated institutional sessions and publisher traffic -- to interception, far beyond the self-signed local-connector case it was meant to support. Verification now stays on by default, even behind a proxy. To trust a self-signed connector CA, set REQUESTS_CA_BUNDLE (honoured natively by requests). Verification is disabled only via an explicit INSTSCI_INSECURE_TLS opt-in, which logs a loud warning. Adds tests: default-on, proxy-still-on, explicit opt-in, falsey values.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
instsci/http_utils.pydisabled TLS certificate verification for everyrequest as soon as any
HTTP_PROXY/HTTPS_PROXY(or lowercase) env var wasset:
The intent was to tolerate self-signed certs on local library connectors, but
the blast radius is the whole HTTP layer. Anyone who runs InstSci with a proxy
configured (common on university networks / VPNs — exactly the institutional
setting this tool targets) silently sends all traffic, including
authenticated institutional sessions and publisher requests, without
certificate verification, exposing them to interception.
Change
REQUESTS_CA_BUNDLE(honourednatively by
requests) — the standard, safe mechanism.INSTSCI_INSECURE_TLSopt-in, which logs a loud warning each load.No change to
request_with_retry's behaviour beyond the default it inherits.Testing
Added
tests/test_http_utils_tls.pycovering:Based on
main; does not touch files in flight oncodex/instsci-user-install-doctor.