fix(selfhost): authenticate the browserless readiness probe so it can pass on a healthy backend (#9487 follow-up) - #9784
Merged
Conversation
…llow-up) browserEndpointReadinessProbe dropped the endpoint's `?token=` and fetched /json/version unauthenticated, on the stated assumption that it needs no auth. It does. A browserless started with a TOKEN -- the documented way, and how the ORB runs it -- answers 401, so browser_endpoint reported false forever: readiness permanently not-ready and the container permanently unhealthy, while screenshot capture worked perfectly the whole time. Verified on the live ORB (browserless v2, Chrome 149): 401 without credentials, 200 with `Authorization: Bearer <token>`. Send the token as a header rather than restoring it to the query string, which keeps the original privacy intent -- the token still never appears in a URL that could reach an access log or an echoed error -- while actually authenticating. The call site in server.ts dropped the init argument, so it also had to forward it; without that the header would have been built and silently discarded.
Contributor
|
Important 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏳ LoopOver is waiting…LoopOver has seen this pull request and is waiting on CI checks to finish before reviewing it. This comment will update once the review runs. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟨 Waiting |
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9784 +/- ##
==========================================
- Coverage 90.30% 89.48% -0.82%
==========================================
Files 913 913
Lines 113586 113591 +5
Branches 26961 26962 +1
==========================================
- Hits 102575 101650 -925
- Misses 9682 10851 +1169
+ Partials 1329 1090 -239
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
The bug
browserEndpointReadinessProbedrops the endpoint's?token=and fetches/json/versionunauthenticated:The first half of that is wrong. A browserless started with a
TOKEN— the documented way, and how the ORB runs it — requires auth on/json/versiontoo.Verified against the live ORB (browserless v2 / Chrome 149):
So
browser_endpointreportedfalsepermanently on any deployment running browserless the recommended way — readiness never ready, container never healthy — while screenshot capture worked perfectly throughout. A probe that cannot pass when the thing it probes is healthy is worse than no probe: it trains operators to ignore readiness.Found by deploying
orb-v3.6.0-beta.1to the ORB, where it was the only failing readiness check.The fix
Send the token as
Authorization: Bearer <token>instead of restoring it to the query string. That keeps the original comment's privacy intent fully intact — the token still never appears in a URL, so it can't leak via a request line, a proxy access log, or an error that echoes the URL — while actually authenticating.The call site in
src/server.tsdiscarded the probe'sinitargument, so it needed fixing too; without that the header would have been constructed and silently thrown away. Worth noting the unit tests alone would not have caught that half — they exercise the probe with an injectedfetchImpl, so a call site that ignoresinitstill passes them. The test asserting the exact header, plus this call-site change, are what make it real.Tests
5 new cases in
test/unit/selfhost-health.test.ts, including a regression that models the real server (401 unless credentials are presented) and an invariant asserting the token appears in the header and never in the probe URL. 49 pass.Note
Deploying beta.1 also surfaced a separate config issue on the ORB itself:
docker-compose.ymldefaultsGITHUB_APP_PRIVATE_KEY_FILEto a 0-byte placeholder.pem, which #9487's (correct) empty-secret check turns into a boot crash for any operator who has that placeholder and no GitHub App. Fixed on the box via the local override; the default may deserve a follow-up so self-hosters don't hit the same wall.