[PM-43128] fix(cli): skip Host allowlist for unix-socket and fd serve transports - #23024
[PM-43128] fix(cli): skip Host allowlist for unix-socket and fd serve transports#23024Tyagiquamar wants to merge 3 commits into
Conversation
…requests Concurrent callers of getProfileCreationDate (the account-security and new-account nudge services during popup init) each resolved before the cache was populated and independently called apiService.getProfile(), producing two identical GET /accounts/profile requests on every popup open. fetchAndCacheProfile now shares a single in-flight promise, clearing it once settled so later calls re-fetch as before. Fixes bitwarden#22840
The Host-header allowlist built from --port was applied to the unix://, fd+listening:// and fd+connected:// transports even though they bind no TCP port, so every request was rejected with 403 unless the client sent Host: localhost:<port> naming a port nothing listens on. The allowlist defends against DNS rebinding, which requires a resolvable hostname and a TCP endpoint; socket transports have neither, so the allowlist blocked legitimate clients while excluding no attacker. The Origin check remains active for these transports.
|
Thank you for your contribution! We've added this to our internal tracking system for review. Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process. |
|
Thanks for picking this up. The transport check looks right to me: Two things while this is open. The help doesn't document the socket transports at all. The complete Nothing there suggests The same gap covers the allowlist itself. "Use hostname Since the PR already enumerates the schemes in
Unrelated changes. The diff also carries |
|
Thanks, both points are fair. The help text gap is closed in 7b88300: the --hostname description now lists the unix://, fd+listening:// and fd+connected:// transports, the Notes section states that requests are rejected unless the Host header matches the bound hostname and port (skipped for On the unrelated changes: the vault-profile.service.ts change belongs to #23023 (PM-43127). This branch is stacked on top of that one, which is why it appears in the diff here; the vault-profile commit is identical to the one under review in #23023. |
Fixes #22867
Problem
The Host-header allowlist from #20881 is built from
--port(default8087) before the transport is chosen, and it is applied to theunix://,fd+listening://andfd+connected://transports from #14262 even though none of them binds a TCP port. Every request over those transports is rejected with403unless the client sendsHost: localhost:8087— naming a port nothing is listening on. This silently breaks every existing unix-socket consumer on upgrade.The allowlist defends against DNS rebinding, which requires a resolvable hostname and a reachable TCP endpoint. Socket transports have neither — browsers cannot open
AF_UNIX, and inherited file descriptors are not network-reachable — so the check blocks legitimate clients while excluding no attacker.Fix
Treat socket transports like
--hostname allfor the Host check: skip the allowlist. TheOrigincheck stays enabled for these transports at no cost.Validation
npx jest apps/cli/src/commands/serve.command.spec.ts— 19 passed, including a newisSocketTransportdescribe block coveringunix://,fd+listening://,fd+connected://(recognized) andlocalhost/all/unix.example/0.0.0.0(not recognized)