Skip to content

Send attestation tokens on login-server requests - #736

Merged
paullinator merged 1 commit into
masterfrom
paul/attestedCaptcha
Aug 20, 2026
Merged

Send attestation tokens on login-server requests#736
paullinator merged 1 commit into
masterfrom
paul/attestedCaptcha

Conversation

@paullinator

@paullinator paullinator commented Aug 14, 2026

Copy link
Copy Markdown
Member

Summary

  • Add EdgeContext.setAttestationToken and attach x-attestation-token on login-server /api/ requests so attested clients can receive CAPTCHA rate overrides.
  • Treat empty-string tokens as cleared (header omitted).
  • Allow private LAN IPv4 hosts for http/ws server overrides (still reject them for https/wss).

Test plan

  • attestation-header tests: set / clear / empty-string token behavior
  • validateServer tests: LAN http accepted; public IPs and https LAN rejected
  • Login-server requests include x-attestation-token only when a token is set

Note

Medium Risk
Touches login-server request headers and server URL validation used at context init; mistakes could weaken override rules or break local dev server configs.

Overview
Adds EdgeContext.setAttestationToken so apps can supply a device attestation JWT that is sent as x-attestation-token on subsequent login-server /api/ requests (for CAPTCHA rate overrides). Empty or cleared tokens omit the header.

validateServer now allows RFC1918 and loopback IPv4 hostnames for http/ws overrides only; https/wss still require localhost or *.edge(test)?.app, with tests for spoofed DNS names like 10.evil.com.

Fake-world allowNetworkAccess no longer routes all non-Edge URLs through real io.fetch via validateServer; only login, info, and sync *.edge.app hosts stay on the in-memory fake server—change servers and private LAN use real fetch.

Reviewed by Cursor Bugbot for commit 552ba21. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor

cursor Bot commented Aug 14, 2026

Copy link
Copy Markdown

Current version of PR was reviewed by /review-bugbot with additional instructions on Aug 13, 21:44 PDT. It flagged 0 findings.

Bugbot on commit 095bbe2 is skipped.


if (url.protocol === 'http:' || url.protocol === 'ws:') {
if (url.hostname === 'localhost') return
if (isPrivateHost(url.hostname)) return

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.

Side effect on fake-world routing: makeFakeWorld with allowNetworkAccess: true routes fetches by "passes validateServer -> fakeFetch, throws -> real network" (src/core/fake/fake-world.ts). Private-IP URIs now pass, so a fake-world test pointed at a real LAN dev server (the exact use case this PR enables) silently gets answered by the in-memory fake server instead of the network. If that is not intended, the fake-world path may want to keep the old localhost-only check.

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.

Fixed in 552ba21, and in a better place than I suggested: fake-world no longer consults validateServer at all, so test routing stops tracking a production policy function. The explicit isFakeAccountInfrastructure allowlist is the right decoupling.

I checked the regex against the hosts this repo actually ships: login1/login2, info1/info2, sync-us1 through sync-us6, sync-eu (root.ts) and the fake server's own info-fake1, sync-fake1..3 all match.

Two intentional behavior changes worth naming, both consistent with the updated doc comment: under allowNetworkAccess, localhost and non-account *.edge.app hosts (the cors1..4.edge.app proxies, for instance) now reach the real network instead of the fake server.

Comment thread src/util/validateServer.ts Outdated
/**
* We only accept *.edge.app or localhost as valid domain names.
* We only accept *.edge.app, localhost, or (for http/ws only) private LAN IPv4.
* https/wss still require localhost or *.edge(test)?.app — private IPs are not

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.

Nit: em-dash in the comment; repo convention is zero em-dashes in committed code (comma or semicolon instead). Full ruleset: https://github.com/EdgeApp/edge-dev-agents/blob/main/.cursor/skills/no-slop/SKILL.md

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.

Fixed in 552ba21.

Add setAttestationToken and attach x-attestation-token so attested
clients can skip CAPTCHA challenges from the login server.

Validate private LAN hosts via real IPv4 octets (not DNS prefix
matches), update the rejection message, and treat empty-string
attestation tokens as cleared.
@paullinator
paullinator force-pushed the paul/attestedCaptcha branch from 095bbe2 to 552ba21 Compare August 18, 2026 05:30
@paullinator
paullinator merged commit 4180a8e into master Aug 20, 2026
6 checks passed
@paullinator
paullinator deleted the paul/attestedCaptcha branch August 20, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants