Skip to content

Let auth login reach a beta preview on a private network - #1054

Merged
robzolkos merged 5 commits into
mainfrom
auth-login-private-preview
Nov 22, 2026
Merged

robzolkos merged 5 commits into
mainfrom
auth-login-private-preview

Conversation

@robzolkos

@robzolkos robzolkos commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

basecamp auth login can't sign in to a beta preview. A preview serves its API at <name>-api.3.bc4-beta.com, and that name resolves to the previews load balancer at a private address on the VPN. OAuth requests refuse private addresses, so discovery failed and login quietly fell back to Launchpad without saying why.

This adds an explicit opt-in: BASECAMP_OAUTH_ALLOW_PRIVATE=1.

  • It admits RFC 1918 addresses, over HTTPS, on the BC5 OAuth lane of a non-production base URL, and only for the base URL's host and hosts under its parent domain (*.3.bc4-beta.com for a preview). The scope never extends to a public suffix (co.uk, github.io), so a discovery document or a redirect can't send the CLI anywhere else on the private network.
  • The lane's strict policy still judges every other address. Loopback, link-local, cloud metadata, IPv6 private space (which holds GCP's, OCI's and AWS's IPv6 metadata services) and the rest of the IANA special-use space stay refused. Each dial is checked again when it connects.
  • The default deny is unchanged. The Launchpad lane never takes the opt-in, and for Basecamp's own hosts it is ignored with a warning.
  • Without the opt-in, a failed discovery against a base URL that resolves only to private addresses now prints a hint that names the variable.
  • On the opted-in path, legacy numeric hosts (0x0a1405e5) are refused, and URL shape is checked without a DNS lookup.

Verification

Run against the live main beta preview over the VPN (main-api.3.bc4-beta.com resolves to 10.20.5.229):

$ BASECAMP_BASE_URL=https://main-api.3.bc4-beta.com basecamp auth login --device-code
warning: OAuth discovery failed for https://main-api.3.bc4-beta.com, using Launchpad fallback
hint: the base URL resolves to a private network address, which OAuth refuses by default; if you trust it (a beta preview on the VPN), set BASECAMP_OAUTH_ALLOW_PRIVATE=1

$ BASECAMP_OAUTH_ALLOW_PRIVATE=1 BASECAMP_BASE_URL=https://main-api.3.bc4-beta.com basecamp auth login --device-code
Authenticating via https://main.3.bc4-beta.com (device flow)
  1. Open this link on any device
     https://main.3.bc4-beta.com/oauth/device_verification?user_code=…

$ BASECAMP_OAUTH_ALLOW_PRIVATE=1 basecamp auth login --device-code     # production
warning: BASECAMP_OAUTH_ALLOW_PRIVATE=1 is ignored for a production base URL; OAuth requests keep the SSRF address policy
Authenticating via https://app.basecamp.com (device flow)

With the opt-in on, discovery, the issuer's metadata and the device-authorization POST all reach the preview, which hands back a code. I didn't approve the code in a browser, so the token exchange at the end wasn't run live. Polling uses the same lane as the device POST.

Unit tests pin what the opt-in admits and refuses, the dial check, the production and malformed-value cases, the Launchpad lane, numeric hosts and the hint. None of them depend on the surrounding network. bin/ci is green. A security review over two rounds found four gaps: the IPv6 metadata services, a lane-wide scope, the public-suffix boundary and plain-HTTP redirects. All four are fixed in this PR, and the second round found nothing further.


Summary by cubic

basecamp auth login can now reach a beta preview whose API host resolves to a private address on the VPN, which OAuth requests previously refused and silently fell back to Launchpad for. BASECAMP_OAUTH_ALLOW_PRIVATE=1 opts the BC5 OAuth lane into private addresses for a non-production base URL.

  • Admits only RFC 1918 space, over HTTPS, for the base URL's host and hosts under its parent domain; loopback, link-local, cloud metadata, CGNAT, IPv6 unique local space, and public suffixes stay refused, and each dial is checked again at connect time.
  • The pre-dial shape check no longer resolves the host, so requests (each device-code poll included) don't wait on DNS before dialing.
  • The Launchpad lane never takes the opt-in, and it is ignored with a warning for Basecamp's own hosts, so production discovery can't be steered to an internal address.
  • Without the opt-in, a failed discovery against a private-only base URL now prints a hint naming the variable.
  • On the opted-in lane, legacy numeric hosts (like 0x0a1405e5) are refused.

Written for commit 11d27f4. Summary will update on new commits.

View guided diff Turn on auto-fix

A beta preview serves its API at <name>-api.3.bc4-beta.com, which resolves
to the previews load balancer on the VPN. OAuth requests refuse private
addresses, so discovery failed and login fell back to Launchpad with no
word of why.

BASECAMP_OAUTH_ALLOW_PRIVATE=1 now admits RFC 1918 and IPv6 unique local
addresses on the BC5 lane of a non-production base URL. The Launchpad lane
and Basecamp's own hosts keep the default deny, as do loopback, link-local,
cloud metadata and CGNAT space. Without it, a failed discovery against a
base URL that resolves to a private address names the variable.
@robzolkos
robzolkos requested a review from a team as a code owner November 22, 2026 20:46
Copilot AI balanced review requested due to automatic review settings November 22, 2026 20:46
@github-actions github-actions Bot added tests Tests (unit and e2e) auth OAuth authentication docs labels Nov 22, 2026

Copilot AI 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.

🟡 Changes recommended

The new URL check adds DNS lookups before every opted-in OAuth request, allowing a stalled resolver to exhaust timeouts and break device-code polling even when an existing connection remains usable.

1 open issue
What changed in this PR

This PR adds an explicit private-network opt-in for OAuth, allowing the CLI to authenticate against VPN-hosted beta previews while preserving default restrictions and production safeguards.

Changes:

  • Adds BASECAMP_OAUTH_ALLOW_PRIVATE=1 for non-production BC5 OAuth requests, with connect-time address checks.
  • Adds warnings and a discovery-failure hint explaining the opt-in.
  • Documents usage and tests address restrictions, lane isolation, and legacy numeric-host rejection.

[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

File Description
README.md Documents preview authentication and opt-in limits.
internal/​auth/​revoke.go Applies the opt-in policy to profile-specific revocation clients.
internal/​auth/​client.go Implements private-network transport checks, opt-in handling, and diagnostics.
internal/​auth/​client_test.go Tests permitted addresses, safeguards, hints, and numeric-host rejection.
internal/​auth/​auth.go Stores opt-in state and displays the discovery-failure hint.

Review effort: Balanced

Comment thread internal/auth/client.go Resolved
The pre-dial check called CheckURL, which resolves the host, so every
opted-in request (each device-code poll included) waited on DNS before it
dialed. It now judges the URL with a resolver that answers nothing, which
keeps surfguard's host-shape checks and leaves addresses to the dial.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 20:59

Copilot AI 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.

🔵 Needs a closer look

The custom OAuth dialer changes a credential-bearing SSRF trust boundary that requires human security review against unavailable surfguard v0.1.0, while the live check stopped before token exchange, leaving the end-to-end flow unverified.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

A security review of the opt-in found two gaps. IPv6 unique local space
holds several clouds' metadata services (GCP's fd20:ce::254, OCI's
fd00:c1::a9fe:a9fe, AWS's fd00:ec2:: DNS and NTP), and only EC2's
metadata address was denied. The previews answer on IPv4, so the opt-in
now admits RFC 1918 space alone.

And the allowance covered every host on the lane, so a preview's
discovery document or a redirect could point the CLI at any address on
the private network. A request now reaches a private address only for
the base URL's host and hosts under its parent domain
(*.3.bc4-beta.com for a preview); every other host keeps the strict
policy.
A second review found that a base URL directly under a public suffix
(customer.co.uk) gave the whole suffix the private allowance, and that a
GET redirect could reach an in-scope private host over plain HTTP. The
scope now stops at the public suffix list, and a private address is
admitted only over HTTPS, where a certificate vouches for the host.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 21:28

Copilot AI 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.

🟡 Changes recommended

The opt-in hostname checks precede IDNA normalization, enabling private-address access across public-suffix and production boundaries, while request-level tests miss the affected HTTPS validation.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

High severity Normalize hostnames before opt-in and production-boundary checks

internal/​auth/​client.go:291

The opt-in checks hostnames before IDNA normalization: https://someone.github.io permits sibling tenants even though the HTTP transport uses github.io, and https://api.basecamp.com bypasses the production check at line 279. With the opt-in enabled, these spellings can grant private-address access across the public-suffix or production boundary. Reject non-ASCII anchors before enabling the opt-in (as below), or normalize anchor and request hosts to IDNA ASCII consistently before both checks, and add regressions for these spellings.

Review effort: Balanced

Comment thread internal/auth/client_test.go Resolved
Since the private allowance became HTTPS-only, the malformed-host tests
used HTTP and took the strict path, so removing the private path's own
checks left them passing. The new tests send HTTPS with a sentinel in
place of the strict transport, and fail when either check is removed.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 21:46

Copilot AI 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.

🟢 Approved

No active review issues block the scoped private-network OAuth opt-in.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@robzolkos
robzolkos merged commit db45e0a into main Nov 22, 2026
33 checks passed
@robzolkos
robzolkos deleted the auth-login-private-preview branch November 22, 2026 21:56
robzolkos added a commit that referenced this pull request Nov 22, 2026
* origin/main:
  Let auth login reach a beta preview on a private network (#1054)
  Resubscribe the feed when its socket stays connected and stops delivering (#1056)
  Open pin-comment repair PRs as the org PR bot (#1052)
jeremy added a commit that referenced this pull request Nov 23, 2026
…950575

* origin/main:
  Keep a person's client flag when it is false (#1055)
  Filter gauge listings by chosen projects (#1049)
  Say how to recover a broken connect.json, and keep reporting around it (#1053)
  Support schedule entry drafts, highlights, and join links (#1019)
  Let auth login reach a beta preview on a private network (#1054)
  Resubscribe the feed when its socket stays connected and stops delivering (#1056)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth OAuth authentication docs tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants