Repository navigation
Harden native HTTP Host and Origin validation - #66
Merged
Merged
Conversation
j2msReginaldBot
approved these changes
Nov 21, 2026
j2msReginaldBot
left a comment
There was a problem hiding this comment.
Reviewed at d1dd6bd (base 7a541b9) against the acceptance criteria in #51. No blocking findings.
Issue #51 acceptance
- No default origins:
allowedOriginsnow defaults to empty. Unconfiguredhttp://localhost:3000andhttp://127.0.0.1:3000are rejected with no ACAO header. The CLI passes origins only from--origin. - Attacker Host rejected:
allowed_hostrequires a single Host whose port equals the accepted socket's port. The host must be one of: an IP literal equal to the concrete local interface (canonicalised, so IPv4-mapped addresses on a dual-stack wildcard bind still match), the configured hostname, orlocalhoston a loopback connection. A rebinding page's Host (attacker:port) therefore fails before any dispatch.X-Forwarded-Hostis ignored. The following are all rejected: duplicate Host headers, comma-joined values, userinfo,+80, a trailing-colon port, a missing port, and absolute-form targets. - Same-origin acceptance: Without explicit config, an Origin passes only when it is
http, has the same host as the already-validated Host, and has the same port. This does not widen the rebinding surface. - Checks run before the body is read: Host, Origin and media type are all checked before
to_bytes. The new node test leaves a declared 20-byte body outstanding, so it would time out if the server read the body. - Error responses: Origin rejection no longer echoes the caller's origin. The 413 response and dispatched replies still carry the CORS headers.
Verification (local, Linux, at d1dd6bd)
cargo build --lockedandcargo test --lockedpassed (51 tests).- The native-boundary audit, lint,
tsc --noEmitandnode --test tests/*.test.tsall passed: 513 tests, 505 pass, 0 fail.smoke.tsalso passed. - CI
Validatepassed.
Non-blocking observations
- HTTP/2 prior-knowledge (h2c) requests carry no
Host, so they are always rejected with 403. This fails closed and browsers don't use h2c, so no change is needed. It may be worth a line in the docs if a proxy ever speaks h2c upstream. - Configured origins are compared as exact strings, as documented. A mixed-case
--originvalue would never match a browser-serialised origin. Optional: normalise or validate--originat startup.
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.
Closes #51.
Changes
Windows DSH verification
Passed the repository's workspace browser test in Windows DSH desktop mode with the rebuilt native API, a scripted model provider through DSH's model service, and native Reverie 0.3.0. The test covered workspace activation, inline authoring, dated episodes, compact routing, scene headings, manual and generated turns, memorization and continued play, workspace export and import, and reopening after a host restart. It exercised four viewport sizes.
Other checks