Repository navigation
fix: gate the incremental-lane marker divert to loopback and stop forging the caller socket - #3350
Closed
ranxianglei wants to merge 1 commit into
Closed
ranxianglei wants to merge 1 commit into
ranxianglei wants to merge 1 commit into
Conversation
…ging the caller socket (#3343) The #3248 marker divert accepted any client that could reach the listening port (trust = the plugin marker headers alone), and the lane's synthetic re-entry carried a hardcoded remoteAddress of 127.0.0.1 plus the caller's Host header — exactly the two facts the /__acp//__bili/ admin gate trusts. A LAN peer could therefore drive applyTurn for ANY conversationId: overwrite canonical history via resync, persist a sticky system prompt into a foreign session (empty delta + systemUpdate is a legal turn), and ride the diverted request onto the management prefixes with a forged loopback identity. - divert entry now applies adminGateDenial (loopback + anti-tunnel + trusted origin) on incremental-SHAPED turns, same trust class as the direct /__bili/plugin/turn entry; full-resend marker'd bodies keep riding the normal pipeline from any source (shape is the final word) - management prefixes (/__bili/, /__acp/) never ride the divert at all (shared isManagementPath predicate, single definition) - the synthetic forward carries the REAL req.socket instead of a forged loopback one — every downstream gate judges the actual peer; loopback topology is byte-identical - regression tests: unix-socket peers simulate non-loopback callers deterministically (remoteAddress undefined); pre-fix code fails the three security assertions, post-fix passes
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.3951-pr.3350.4799cc4This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3350.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Owner
Author
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 #3343
What
The #3248 marker divert trusted the plugin marker headers alone: any client that could reach the listening port could POST an incremental-shaped body with
x-bili-plugin+x-bili-plugin-turnand land inapplyTurn— which writes canonical session state under a caller-chosenconversationId. The lane's synthetic re-entry made it worse: it carried a hardcodedremoteAddress: "127.0.0.1"plus the caller's ownHostheader — exactly the two facts the/__acp//__bili/admin gate trusts (isLoopbackAddress(socket.remoteAddress)+isTrustedAdminOriginwith no Origin). A LAN peer on a--host 0.0.0.0deployment could therefore:systemUpdateis a legal turn shape —inc:systemsurvives into every later assembled turn);Exposure pre-fix: rollout
pluginIncrementalTurnsenabled (default 0%, forceable via env/config) AND proxy listening on a non-loopback address.Changes
adminGateDenial(loopback + anti-tunnel + trusted-origin — the same checks as the direct/__bili/plugin/turnentry) on incremental-SHAPED turns. Denial → 403 before the lane runs.isManagementPath()predicate (single definition, used by bothhandleAdminRouteand the divert condition) excludes/__bili/* and/__acp/* from marker handling entirely.req.socketinstead of a forged loopback one — every downstream gate (admin plane, tunnel admission, provenance) judges the actual peer.tests/issue3343-marker-divert-gate.test.ts): non-loopback peers simulated deterministically via unix sockets (remoteAddress === undefined⇒ non-loopback byisLoopbackAddress, no network-topology luck). Verified against the pre-fix code: the three security assertions fail there and pass here.Behavior changes (old → new)
{ localPort, remoteAddress: "127.0.0.1", destroy }/__acp/*//__bili/*pathsNo config surface change. Rollout stays at its default 0% — this fix is what makes enabling
pluginIncrementalTurnssafe (GA precondition from the issue).Local: typecheck clean; targeted suites green (
issue3343-marker-divert-gate,incremental-lane,admin-probe). Full-suite verdict: CI.