Commit Graph
4 Commits
Author SHA1 Message Date
illusia 275e27c4ac fix(security): address PR 48 findings with bounded concurrent authentication
Classify IPv6 subnets numerically, reserve login capacity before hashing, bind authentication to credential revisions, revoke other sessions on password rotation, reuse trusted proxy client keys and bound PCM encoding by monotonic time. Credit ph1gros for the findings and proposed regression cases.
2026-10-26 10:28:45 +08:00
LainHE 96f7fd6783 fix(acceleration-poc): align the relay's target guard with the gateway policy
The PoC relay carried its own copy of the restricted-address check and had
drifted well behind src/security/open-target-policy.ts: it missed multicast,
192.0.0.0/24 and the other special-use ranges, 198.18.0.0/15, the TEST-NET
blocks, fec0::/10, ff00::/8 and 2001:db8::/32. A relay started without
allowPrivate would therefore forward to addresses the gateway refuses, and
nothing exercised the guard, so the gap could not be noticed.

The relay must stay a plain .mjs file that the README documents copying to a
remote host without a build step, so it cannot import the TypeScript policy. The
predicate is mirrored instead and pinned by a parity test that fails the moment
the two classifications disagree.

The parity test lives beside the PoC rather than under src/: .dockerignore
excludes scripts/acceleration-poc from the Docker build context while the
Dockerfile runs `tsc` over src/**, so a copy in src/ would resolve locally and
still break the image build with TS2307.

- mirror isRestrictedAddress() exactly, including fail-closed handling of any
  input that is not a literal public address
- add scripts/acceleration-poc/target-guard-parity.test.mjs comparing both
  implementations across private, loopback, link-local, carrier-grade NAT,
  special-use, IPv6 and IPv4-mapped cases
- assert the guard in the PoC smoke run: a relay without allowPrivate must
  reject loopback, private and IPv4-mapped targets while still serving a public
  one, and the run now fails with the offending target instead of passing
  silently

Verified: tsc clean; `npm run build` and `npm run web:build` succeed with
scripts/acceleration-poc moved aside to reproduce the Docker build context; the
parity test fails when either side drifts; the smoke run reports ssrf_guard_ok
and ACCELERATION_POC_OK after the fix, and fails with a LEAK line per unblocked
target once the guard is weakened; the IPv6 smoke run still reports
IPV6_ACCELERATION_POC_OK.
2026-10-15 21:26:22 +08:00
LainHE 4816c7ea62 fix(acceleration-relay): validate resolved targets to close SSRF
The relay's private-target guard ran on the caller-supplied hostname while the
connection was made to the DNS-resolved address, so any hostname could reach
loopback or an internal host even with allowPrivate=false. IPv4-mapped IPv6
literals such as ::ffff:127.0.0.1 slipped through the IPv6 branch as well.

- reuse isRestrictedAddress() instead of the weaker local isPrivateAddress()
- resolve first, then reject when any resolved address is restricted, so a
  mixed public/private DNS answer cannot be used to reach an internal host
- release the freshly created session before rejecting a blocked target
- add an injectable lookupAddresses option for deterministic tests
- mirror the same resolve-then-validate ordering in the acceleration PoC relay
- add src/server/acceleration-relay.test.ts (6 tests) to the test script

Verified: tsc clean; the 6 new tests fail 4/6 before the fix and pass 6/6 after;
the acceleration PoC still reports ACCELERATION_POC_OK.
2026-10-15 16:34:07 +08:00
illusia bfefd053a0 feat: add acceleration tunnel proof of concept 2026-09-10 11:29:18 +08:00