PR evidence · RubberDuck · PR #136 → staging

PR #136: Teleport, a safe read-only way for support to see a learner's screen

A verified @rubberduckai.com admin can open a learner's account from Settings and see exactly what they see, without being able to change anything. Every view is audited and ends within 30 minutes. The PR also adds 12-month complimentary student grants that give full access with no Stripe subscription. Nothing in it deploys, merges or touches live D1.

REVIEW CLEAN  Three review rounds by a separate reviewer: a Cursor cloud agent on gpt-5.6-sol, high reasoning. Rounds 1 and 2 raised blockers, which were fixed. Round 3 (bc-dcb48599) approved head f489ccfd with one non-blocking note (below). CI is green, including the Teleport E2E job. Built by Claude Opus 5.5 (claude-opus-5-5), effort high, in a Cursor cloud agent. Only you merge to staging.

What Teleport does

  • Settings → Teleport: the admin proves their work mailbox, types a learner's email and sees the app as that learner.
  • A banner on every page reads Viewing as … · Read-only · Ends <time> · Teleport back.
  • Read-only everywhere: saves, progress, XP, voice sessions and other writes are refused in both the Next proxy and the backend. Analytics and replay are off during a view.
  • Default-deny pages: only listed learner pages load. Everything else, including all of /teachers/*, shows a 403 page.
  • Audit trail: each view writes a row (admin, target, start, expiry, end). Only a SHA-256 digest of the view token is stored.
  • Non-admins never see it. Forged requests get 403 and write nothing.

What changed in the last review rounds

  • Single-use signed requests. Each request Next signs for the backend now carries a random ID (a jti nonce). The backend records it once. Sending the same request again returns 409 teleport_assertion_replayed.
  • New migration 0027_teleport_assertion_nonces stores those IDs and clears them about a minute after they expire. It is safe to re-run. It is not applied to live D1.
  • Teacher targets now get 422 (was 409), so a refused teacher can't be confused with a replay. The screen says "Teleport opens learner accounts only".
  • Wider CI trigger. The Teleport E2E now runs whenever app code, dependencies, migrations, scripts/*.sql or the E2E itself changes (about 8 extra minutes on those PRs).
  • Earlier fixes: re-runnable migrations 0023–0025, no frontend D1 writes (the backend writes audit rows), and server-side expiry.

How a signed Teleport request is checked

Next signs request60 s life · random jti Backend checks callerWorkOS JWT + signature Record jti onceteleport_assertion_nonces (0027) Eligibility + live sessionadmin? learner target? already used 409 replay refusedno token, no audit row 422teacher target View opensread-only, audited 403non-admin / forged / bare JWT Reviewer's note: a replay still runs the WorkOS identity step before the jti is refused; it skips the later eligibility and session checks.

The videos

Three browser recordings of the real Next app and real FastAPI backend, recorded at head f489ccfd against a local D1 (migrations up to 0027) and a local WorkOS stand-in, so no real accounts, secrets or live data are involved. Each holds 3 seconds on the starting page and 3 seconds after the final check. Backend status codes and database checks appear as captions at the bottom left. The full step log is here (3 flows, 45 checks, all passed). Click a timestamp to jump there and pause.

(a) Admin Teleport, end to end · 1:15

PASS
What this checks
A support admin signs in, opens a learner read-only, tries to change things, leaves, and lets a second view expire.
Which part of the PR it proves
The new single-use rule (the replay returns 409 and the nonce is stored once), the 422 teacher refusal, the read-only banner, default-deny pages, writes refused with D1 unchanged, and the audit row closing on exit and on expiry.
What to watch for
  • 3-second hold on the sign-in page.
  • Admin signs in (one automatic retry), then proves the mailbox with a code at .
  • Settings → Teleport. Captions: the bare admin JWT is refused (403, no audit row); a signed request is accepted once (200); the identical replay is refused with 409; the nonce is recorded once.
  • A teacher's email is refused and the admin stays on Settings, with no audit row.
  • The learner opens with the Viewing as … · Read-only banner. Captions confirm the audit row and the hashed token.
  • /teachers/classes shows "This page is not available in Teleport", with a link back.
  • Editing the learner's name is refused ("Teleport is read-only. Nothing was saved."). The proxy and backend both return 403, and D1 is unchanged.
  • Teleport back: the banner is gone and the row is closed.
  • A second view runs out and shows "Teleport ended" at . History lists one Ended and one Expired at .
  • to the end: 3-second hold.
Speed:

(b) A non-admin can't use Teleport · 0:17

PASS
What this checks
A student signs in and tries to reach Teleport through the UI, a direct URL, a forged request to Next, and a direct backend call.
Which part of the PR it proves
Only verified admins can start a view. Every route refuses others with 403 and writes no audit row.
What to watch for
  • 3-second hold on the sign-in page.
  • The student lands on the dashboard.
  • Settings has no Teleport tab, and ?tab=teleport falls back to "About me".
  • Captions: forged POST /api/teleport → 403, history → 403, backend with a forged signature → 403, no audit row.
  • to the end: 3-second hold.
Speed:

(c) Complimentary grant access · 0:45

PASS
What this checks
One student with an active complimentary grant and one with an expired grant each try to start Study Ducky.
Which part of the PR it proves
A grant gives full access with no Stripe subscription, and an expired grant is gated in both the app and the API.
What to watch for
  • 3-second hold on the sign-in page.
  • The active-grant student reaches the dashboard, then the science path at .
  • The Study Ducky session page opens, and the backend creates a session (200).
  • The expired-grant student is sent to /subscribe, a deep link is gated too, and the backend refuses with 403.
  • to the end: 3-second hold.
Speed:

Other checks

CI at f489ccfdgreen: frontend, backend, new-code-check, critical-paths, both Docker builds, e2e-critical and Teleport E2E. Deploy jobs were skipped, as expected.
Frontendlint (0 errors), typecheck and build passed; 1157 tests passed, 5 skips were already there
Backend pytest1702 passed, 37 existing skips. The new tests cover replay → 409 for all four signed actions, missing or bad jti → 403, and nonce clean-up.
Migrations re-runnableThe rollout was applied twice to local D1 and SQLite. Each time the result was 4 tracked migrations and 3 indexes.
Reviewer's fresh rerun3/3 flows and 45 checks passed locally. No remote D1, deploy, secret or merge was used.
Reviewer's non-blocking noteA replay still runs the WorkOS identity step before the nonce is refused; it only skips the later eligibility and session checks. The result is still a 409 with no change, so this is a small efficiency point rather than a security gap.
Migration number clashThis PR's 0027_teleport_assertion_nonces uses the same number as a 0027 in #142. #142 will renumber, so this PR keeps 0027. (There are also two 0023_* files; renumbering is only safe before the remote apply.)

For you: three decisions

  1. Should teacher accounts be Teleport-able? Today a teacher target gets a 422 ("Teleport opens learner accounts only"), and /teachers/* is blocked during a view. The PR's "Why" mentioned teachers, but the review asked for learner-only. Allowing teachers would need its own reviewed page and API allowlist.
  2. Owner review of .github/workflows/teleport-e2e.yml. The checker flags this new workflow for your review. It runs on pull_request with contents: read, uses dummy values for a local D1 and WorkOS, and uses no secrets.*.
  3. Approve the live D1 runbook (docs/teleport-rollout.md). Staging and prod share this database. 0023, 0024, 0025 and 0027 are all unapplied remotely. Teleport fails closed until they exist. Each step can be re-run:
    npx wrangler d1 migrations list rubber_duck --remote
    npx wrangler d1 execute rubber_duck --remote --file cloudflare/migrations/0023_teleport_sessions.sql
    npx wrangler d1 execute rubber_duck --remote --file cloudflare/migrations/0024_teleport_session_authority.sql
    npx wrangler d1 execute rubber_duck --remote --file cloudflare/migrations/0025_complimentary_student_access.sql
    npx wrangler d1 execute rubber_duck --remote --file cloudflare/migrations/0027_teleport_assertion_nonces.sql
    npx wrangler d1 execute rubber_duck --remote --file scripts/d1_track_teleport_rollout.sql
    npx wrangler d1 migrations list rubber_duck --remote
    Do not use wrangler d1 migrations apply --remote. Live tracking is out of step, so it would also apply the unrelated 0022_coins_per_strength. No new secrets are needed. Then merge to staging.

Other open questions from the PR: should there be an org-wide audit view (today each admin sees only their own)? Is 30 minutes long enough for support calls? E2E_REQUIRED should be turned on once this ships.