Skip to content

feat(be): verify a browser's key and its announced successor - #4264

Open
sea-snake wants to merge 38 commits into
feat/session-devices-registryfrom
feat/session-device-key-proof
Open

feat(be): verify a browser's key and its announced successor#4264
sea-snake wants to merge 38 commits into
feat/session-devices-registryfrom
feat/session-device-key-proof

Conversation

@sea-snake

@sea-snake sea-snake commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Design: #4224. Overview: #4230. The verifier only — its caller is the sign-in ceremony in #4268, which also removes the #[allow(dead_code)] this carries.

A session records which browser created it, so the user can see where they are signed in and end one browser's access everywhere at once. That is only worth anything if the browser named in a sign-in is the browser that made it; otherwise an attacker holding an access method could attribute their session to a browser the user recognises, and the settings list would lie. Ingress messages are public, so a key presented in one sign-in can be read off the wire by anyone.

verify_device_keys checks two signatures before a sign-in may name a browser: the current key over the session key and the announced successor, and the successor over the session key and the current key. Each is made under its own domain separator, ii-session-device-key and ii-session-device-successor, so neither can be replayed in the other's role.

Requiring possession of the successor is what closes the wire-reading attack: announcing a key you do not hold is impossible without its private half, so a key read off the wire cannot be claimed when its owner next presents one.

P-256 only, no fallback. A key that does not parse, a signature of the wrong length, and an empty signature are each refused rather than skipped.

Tests: device_key::tests (10), one accepting case and nine refusals — including a successor signature replayed as the current one, a signature over another session key, and one paired with a substituted successor.

@zeropath-ai

zeropath-ai Bot commented Aug 22, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to a7b0d9e.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► src/internet_identity/src/sessions.rs
      Add new module for sessions
► src/internet_identity/src/sessions/browser_key.rs
      Add browser key verification implementation and tests
Enhancement ► src/internet_identity/src/main.rs
      Register new module sessions (mod sessions)
Enhancement ► src/canister_tests/Cargo.toml
      Enable p256 workspace for tests
Enhancement ► Cargo.toml
      Update p256 dependency to include pkcs8 feature

@sea-snake
sea-snake force-pushed the feat/session-device-key-proof branch from b3521fc to 52cdad9 Compare August 22, 2026 18:44
A sign-in that names a browser has to prove the browser holds the key it
names, and the successor it announces for its next sign-in.

Two signatures, under two domains: the current key over the session key and
the successor, and the successor over the session key and the current key.
Separate domains are what stop either signature being replayed in the other's
role. Ingress messages are public, so a key read off the wire could otherwise
be announced by someone who does not hold it, and claimed when its browser
next presents one.

P-256 only, and no fallback: a key that does not parse, a signature of the
wrong length and an empty signature are each refused rather than skipped.

The module is annotated `allow(dead_code)` because its caller is the sign-in
ceremony, which lands two PRs up.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
sea-snake and others added 20 commits September 5, 2026 10:49
`Device` is taken — it is the passkey credential that authenticates the anchor,
and `DeviceData` is in the candid interface. The word this wants is the one its
own doc comment already used, and the one the frontend uses throughout.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LVi99RYo2jyi2kCurgovNJ
The module, its function, its parameters and both signature domains said
device. The domain strings are what the browser signs over, so they change
with the frontend that produces them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LVi99RYo2jyi2kCurgovNJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:revocable-app-sessions Design: revocable app sessions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant