Skip to content

fix(client): refuse insecure credential transport - #5299

Merged
thymikee merged 3 commits into
0.22from
fix/daybreak-credential-transport-refusal
Dec 2, 2026
Merged

thymikee merged 3 commits into
0.22from
fix/daybreak-credential-transport-refusal

Conversation

@thymikee

@thymikee thymikee commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Complete ADR 0041 credential admission on 0.22 (#5182), which already includes refusal through #5191. This four-file port checks the Metro companion's environment before registration, awaits default proxy admission before preparing upstream credentials, and masks the configured origin in public errors. The 0.21.x warning remains on its release line.

Before / after

  • Metro companion startup now checks admission using the worker's own environment before bridge registration.
  • The default proxy now refuses before building upstream credentials. /health retains HTTP 400, INVALID_ARGS, the nested details.reason, and the hint. The public message masks the configured origin. /rpc applies the same masking within its existing JSON-RPC envelope.

Validation

At dddd87b9c34714daaa0d1ae000704abbe070144a, all 16 focused tests passed in daemon-proxy-credential-transport.test.ts and client-companion-tunnel-worker.test.ts. Focused oxlint and oxfmt passed for daemon-proxy.ts. The earlier CI job rejected the proxy file at 1,001 lines. The follow-up simplifies the default fetch declaration to meet the 1,000-line limit while preserving behavior. Hosted lint passed at that head.

Coverage failed in an inherited daemon-client test. A local probe confirmed that the fixture's released port could be rebound. CI did not establish port reuse. A separate test commit keeps the port bound and closes HTTP requests before responding.

At 1fc668992eb59e0ed611e093f20c78b2d83aecc4, all 13 tests in daemon-client-ensuring.test.ts passed locally with loopback required. Hosted CI and review are pending.

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.28 MB 5.28 MB +374 B
Package (unpacked) 5.28 MB 5.28 MB +374 B
Package (download) 1.62 MB 1.62 MB +61 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 17.3 ms 20.2 ms +2.9 ms
CLI --help 29.8 ms 33.4 ms +3.6 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 16 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread website/docs/docs/security-trust.md Resolved
Comment thread website/docs/docs/error-reasons.md Resolved
@apex-sentinel-staging

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from 114df0f to 7214c93 Compare December 1, 2026 08:03
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on a93da8c. The verdict and the full list are in the summary comment.

Comment thread packages/proxy/src/daemon-proxy.ts Resolved
@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch 2 times, most recently from 278fdec to 65f4412 Compare December 1, 2026 08:34
@thymikee
thymikee force-pushed the fix/daybreak-credential-transport-refusal branch from 36119a3 to 2c6e9f7 Compare December 1, 2026 08:35
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from be122c3 to ac0eadf Compare December 1, 2026 09:06
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from ac0eadf to b6e9bb3 Compare December 1, 2026 09:10
@thymikee
thymikee force-pushed the fix/daybreak-credential-transport-refusal branch from 51c56f0 to 3ca55c8 Compare December 1, 2026 09:12
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from b6e9bb3 to ee8075e Compare December 1, 2026 09:40
@thymikee
thymikee force-pushed the fix/daybreak-credential-transport-refusal branch from 3ca55c8 to 1dfc70a Compare December 1, 2026 09:42
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

At 1dfc70a, this change would make the next 0.21.x release refuse requests that 0.21.x should only warn about. Two credential paths also need fixes.

credential-admission.ts:11 changes the admission result from a warning to a throw on a stack based on main, which still publishes 0.21.x (0.21.46-dev). A CLI, Node SDK, Metro companion or proxy caller that uses a non-loopback http URL without the override works with a warning today. On the next patch it would fail with INVALID_ARGS. ADR 0041 and #5182 require 0.21.x to warn and 0.22 to refuse, and the open item to publish a stable 0.21.x containing #5179 could no longer be met from main. The docs and contract comment at this head still say 0.21.x warns. origin/0.22 already refuses through #5191, with an identical credential-admission.ts. The rule is that main keeps warning, so the refusal and its test and doc changes should stay out of this stack. Only what #5191 lacks, the origin masking in publicProxyError, should go to origin/0.22. If main is now meant to be the 0.22 line, the version line, ADR status and docs need to say so first.

A second independent pass found a likely gap in the Metro companion. prepareMetroRuntime can be called with a non-loopback http proxyBaseUrl, a Metro or daemon bearer, the override set in the SDK process, and an options.env that omits it. The parent admits its own bridge request with host.env (client-metro.ts:685, client-metro.ts:706). After a retryable failure, it starts the companion with settings.env (client-metro.ts:879, client-companion-tunnel.ts:365). The companion then sends its registration POST without an admission check (client-companion-tunnel-worker.ts:84, client-companion-tunnel-worker.ts:700), so the bearer can be read on the network. Every process that sends a credential must pass the shared admission check with its own environment before its first send. For the companion, that means at process entry, before the registration loop, with the parent check kept. A test should start it with that environment and show the refusal with no request sent.

A second independent pass found that the proxy can likely skip the masked refusal. With the default transport, a non-loopback http upstream URL with userinfo is accepted (daemon-proxy.ts:643). Health and forwarding build the upstream Request (daemon-proxy.ts:373, daemon-proxy.ts:395) before the admission waits (daemon-proxy.ts:607, daemon-proxy.ts:637). On Node 26.11.1 on macOS, building a Request from a synthetic userinfo URL throws a TypeError that quotes the full URL. The sanitizer masks only the typed refusal (daemon-proxy.ts:987), so a health or forwarding caller could receive the private host, username and password. An upstream credential with an interior newline could likewise be echoed by Headers.set (daemon-proxy.ts:760). Default upstream admission must finish before any upstream header or Request is built, on both health and ordinary forwarding. The public sanitizer and the custom upstreamFetch exemption should stay. Tests for both inputs should show a masked INVALID_ARGS response.

Would it be simpler to keep main on the 0.21.x warning and add only publicProxyError to origin/0.22, where the refusal already exists? That means masking the origin in /health and /rpc refusals while keeping details.reason and an origin-free hint, in about 10 production lines. This depends on a maintainer decision about which branch carries 0.22 enforcement.

Not blocking: these can be taken or left: /health could return the masked refusal as details: { reason: 'insecure_credential_transport' } from publicProxyError, matching /rpc and what the 0.22 client reads, instead of a top-level reason (daemon-proxy.ts:980), the public error could keep the origin-free hint while still masking the message and origin (daemon-proxy.ts:990), and the warning-era test title and stderr capture could be replaced with "is admitted" cases (daemon-proxy-credential-transport.test.ts:75).

These earlier threads are addressed at this head and can be resolved: the /health refusal no longer names the upstream origin (#5299 (comment)); the /health body now carries reason, though at the top level as noted above (#5299 (comment)); the ticket fallback in the security doc is now limited to non-loopback http (#5299 (comment)); the 0.21.x/0.22 note is restored, though it would be false for a 0.21.x release built from this code (#5299 (comment)); the JSDoc names the sender's override (#5299 (comment)); and /rpc errors now go through publicProxyError (#5299 (comment)).

The cancelled Body rules check only reads the PR body and was superseded by a body edit, so it looks unrelated to the code. One other check is still queued. An earlier failure in test/repo-guards/reason-tables.test.ts did involve this change, and the reason text in the contract comment and error docs now matches.

Not verified here: no tests were run, and the expectation that the new admission and proxy tests fail on the base comes from reading the code. Not verified here: whether a CLI client behind an https proxy with a plain http upstream surfaces details.reason; at this head the client appears to treat a 400 from /health as reachable and meet the refusal at /rpc. Not verified here: whether main is intended to become the 0.22 line, or whether other cloud credential sends outside the changed admission points, such as logout or revoke, are covered.

Before merge, the release line needs a decision: keep the refusal off main and port only the origin masking to origin/0.22, or record that main is now 0.22 and update the version line, ADR and docs.

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

At 525847e, the companion entry check, proxy admission ordering and origin masking address parts of the earlier review, but the release-line refusal remains unresolved. The static review found no conflicts.

The shared admission boundary now refuses configured off-loopback HTTP destinations without the override, so existing 0.21.x deployments can fail before the announced 0.22 cutoff; the embedded default proxy also stops forwarding its daemon token. Please preserve the warning on 0.21.x and port the companion check, proxy ordering and origin masking to 0.22, which already carries #5191. Preserve the existing 0.22 health refusal wire contract when porting the mask. Admission boundary

A second independent pass found that the earlier refusal finding still applies: the unchanged 0.21.x base now returns INVALID_ARGS for CLI, SDK, Metro and proxy callers that previously sent credentials with a warning. Could the release target be resolved before merge, either by keeping the warning on 0.21.x and porting the remaining changes to 0.22, or by moving the stack to 0.22 and aligning the package versions, ADR status, contract comment and docs? Release guidance

Body rules was cancelled without a failure excerpt; the check grades PR metadata and its cancellation cause is not established, so it appears unrelated to the source change. Not verified here: tests or live sessions; the focused run was reported by the author without a captured receipt. The changed routes are host-side proxy forwarding and Metro registration admission before device dispatch, so this delta does not require live device evidence. Resolve the release target and obtain a passing Body rules check on the resulting head before merge.

@thymikee
thymikee changed the base branch from fix/daybreak-android-helper-boundaries to 0.22 December 2, 2026 09:52
@thymikee
thymikee force-pushed the fix/daybreak-credential-transport-refusal branch from 525847e to 5a70105 Compare December 2, 2026 09:53
@thymikee

thymikee commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

Following up on the release-line review. This PR now targets 0.22 at 1d5e04b65d7527a93a5d68410a353d9ea38559c1. The four-file port at 5a701051d11075dd9766165bf053c3159be866e5 keeps the 0.21.x warning on its existing release line and builds on the refusal already in #5191. It checks the Metro companion's environment before registration and awaits default proxy admission before building upstream credentials. /health retains HTTP 400, INVALID_ARGS, details.reason, and the hint. The configured origin is masked in public /health and /rpc errors.

The prepared port passed all 16 focused proxy and companion tests. The published diff matches that port, and GitHub reports it mergeable. Body rules and hosted review are pending on the new head.

@blacksmith-sh

This comment has been minimized.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 1fc6689

Since the review of 525847e: 1 new · 0 still open · 0 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
packages/react-native/src/companion/client-companion-tunnel-worker.test.ts:675 🆕 Companion admission test stubs the insecure-transport override to "1"

Reviewed with this repository's own Sentinel configuration (86188448f4b0).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 1fc6689. The verdict and the full list are in the summary comment.

@thymikee

thymikee commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

At 1fc6689, the earlier review findings on credential transport are addressed, and no new code issues were found.

The ambient override thread does not apply: the override intentionally checks that the injected environment controls admission.

Body rules was cancelled; the check grades the PR title and body, which this patch does not change, so the cancellation appears unrelated. No conflicts are known. Obtain a passing Body rules check at 1fc6689 before merge; the release-line issue is resolved.

Not verified here: tests and devices were not run during this static review. Not verified here: the author-reported local runs and the suspected historical cause of the Coverage failure were not supported by captured receipts.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Dec 2, 2026
@thymikee
thymikee merged commit a23c532 into 0.22 Dec 2, 2026
17 of 18 checks passed
@thymikee
thymikee deleted the fix/daybreak-credential-transport-refusal branch December 2, 2026 12:34
thymikee added a commit that referenced this pull request Dec 3, 2026
* fix(security): complete credential admission on 0.22

* fix(proxy): keep upstream fetch within the file line limit

* test(daemon-client): keep the unreachable fixture port bound
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant