You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(npm): cap redirect following in the npm postinstall downloader #213
install.sh now caps its chain at 3 hops (#165). This path has no cap at all, so a server that returns a redirect loop keeps the postinstall recursing until the process runs out of stack or the 120s socket timeout fires on some hop, whichever lands first. Real release assets take exactly one hop.
The scheme half of #165 is already covered here by accident rather than by intent: the function is hardcoded to https.get, which throws ERR_INVALID_PROTOCOL on an http: location. Worth making that explicit at the same time so it cannot regress into a generic get.
There is no TLS-version floor either, but Node negotiates TLS 1.2+ by default on every version the package supports, so that half needs nothing.
Acceptance Criteria
httpsGet follows at most 3 redirects and rejects with a clear error beyond that
a redirect to a non-https location is rejected explicitly, not by relying on https.get throwing
a relative Location header still resolves correctly against the current URL
npm/scripts/postinstall.test.ts covers the cap, the non-https rejection, and a single normal redirect
Checked against current main (ad95fb2): STILL TRUE. httpsGet in npm/scripts/postinstall.js:39-44 still recurses on res.headers.location with no depth limit and no explicit scheme check.
One addition for criterion 3: a relative Location does not resolve today either. The raw header value goes straight to https.get, and a path-only string like /foo is not a valid URL to it. Criterion 3 therefore needs new code, not just a test. Resolving with new URL(location, url) before the scheme check covers both.
Activity
nc9 commentedon Oct 11, 2026
Checked against current main (ad95fb2): STILL TRUE.
httpsGetinnpm/scripts/postinstall.js:39-44still recurses onres.headers.locationwith no depth limit and no explicit scheme check.One addition for criterion 3: a relative
Locationdoes not resolve today either. The raw header value goes straight tohttps.get, and a path-only string like/foois not a valid URL to it. Criterion 3 therefore needs new code, not just a test. Resolving withnew URL(location, url)before the scheme check covers both.fix(npm): bound postinstall redirects to three, HTTPS only squirrelsc…