fix(security): remove internal infra hostnames from published package#18
Open
andrei-hasna wants to merge 1 commit into
Open
fix(security): remove internal infra hostnames from published package#18andrei-hasna wants to merge 1 commit into
andrei-hasna wants to merge 1 commit into
Conversation
3 tasks
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.
Summary — ADDITIONAL FINDING beyond the originally scoped repo list
While fixing
hasna/identities,hasna/sessions, andhasna/logs, I traced their client-transport code to this shared package (@hasna/contracts, imported as@hasna/contracts/client/storage//transport). This is the actual root cause of the*.hasna.xyzdefault-hostname leak for those repos (and independently duplicated in@hasna/machines, fixed separately in hasna/machines#17).Confirmed by downloading the currently published tarball:
The published
@hasna/contracts@0.5.2bundle bakes in a real internal-infra hostname template used by every downstream@hasna/*client (identities, sessions, logs, loops, and more) wheneverHASNA_<APP>_API_KEYis set but no explicitHASNA_<APP>_API_URLis provided.What changed
src/client/transport.ts:defaultCloudBaseUrl(name)now buildshttps://<app>.<domain>where<domain>comes from a newHASNA_FLEET_API_DOMAINenv var (REQUIRED for a real deployment) — new exported helperfleetApiDomain(). Absent that env var, it falls back to a neutral, non-resolving placeholder (your-deployment.example) instead of guessing a real internal hostname.src/client/transport.test.ts,src/client/storage.test.ts: updated fixtures/expectations to the new placeholder domain.src/client/conformance.live.test.ts: this AWS-creds-gated live test against a real deployment now resolves its target host via the samedefaultCloudBaseUrl()(so it still works for whoever setsHASNA_FLEET_API_DOMAINfor a real live run) instead of hardcoding the internal domain; it fails closed totest.skip(never a hard failure) when the domain isn't configured, since the existingreachable()health-check guard treats an unresolvable/placeholder host as "unreachable."dist/locally and confirmed zerohasna.xyzmatches in the built output (not committed —dist/is gitignored).Why this matters
This is the actual shipped default that downstream packages (
@hasna/identities,@hasna/sessions,@hasna/logs,@hasna/loops, and others) inherit viaresolveClientTransport()when only an API key (no URL) is configured. Fixing only the downstream repos' own comments/tests (see hasna/identities#11, hasna/sessions PR, hasna/logs PR) does not remove this from their built/published artifacts — those packages bundle this function directly. This package needs a patched republish, and each downstream package that depends on it needs to bump to the patched@hasna/contractsversion and republish too, for the fix to actually reach consumers.Behavior change / rollout note
Any real self-hosted deployment relying on the URL-guessing default now needs
HASNA_FLEET_API_DOMAINset to the operator's real root domain (or an explicit per-appHASNA_<APP>_API_URL) — previously this was silently guessed as<app>.hasna.xyz.Test plan
bun run typecheck— cleanbun test src/client/transport.test.ts src/client/storage.test.ts— 33/33 passbun test src/client/conformance.live.test.ts— skips cleanly (no AWS creds in this environment; confirmed skip path, not failure)bun test(full suite) — 216 pass / 0 fail / 8 pre-existing skipsbun run buildthengrep -rn "hasna.xyz" dist/— zero matches