Skip to content

docs(ai): spec binding the II delegation guard to the derivation origin - #13956

Draft
AntonioVentilii wants to merge 1 commit into
mainfrom
av/oisy-3154-fix-5f46cd
Draft

docs(ai): spec binding the II delegation guard to the derivation origin#13956
AntonioVentilii wants to merge 1 commit into
mainfrom
av/oisy-3154-fix-5f46cd

Conversation

@AntonioVentilii

Copy link
Copy Markdown
Collaborator

Motivation

The backend's II delegation guard (src/backend/src/delegation.rs) proves that a caller holds a delegation issued by the configured Internet Identity canister, but it never checks which frontend origin that delegation was derived for. The backend already stores a canonical derivation_origin in its config; read_ii_verification_config never reads it.

II folds a caller-supplied frontend origin into the seed it derives the user identity from, so one ordinary anchor can obtain many valid chains, one per origin string, each authenticating as a different principal. Because allowances and rate limits are keyed by principal, a single anchor multiplies its quota: a fresh signer allowance over the shared patron per origin, and a fresh per-caller Bitcoin bucket per origin. This was reported through the bug-bounty programme and accepted as a defence-in-depth hardening; the blast radius is OISY's own operational cycles, not user funds or keys.

The reason this is a spec and not a one-line guard change: the origin is not recoverable from the delegation chain. II derives the seed as SHA256(salt ‖ anchor ‖ frontend) with a canister-private salt, and the signed delegation message is ("ic-request-auth-delegation", pubkey, expiration, targets) with no origin in it. No extra check on the existing payload can recover it, and a caller-supplied plaintext origin would be forgeable. The binding has to come from a second signed artifact.

Changes

Adds docs/ai/spec-driven-development/specs/2026-09-07-impr-bind-ii-delegation-guard-to-derivation-origin.md. Docs only, no code.

The spec proposes II certified attributes (prepare_icrc3_attributes / get_icrc3_attributes) as the binding. Their signature is made under the same origin-derived user key already carried in IIDelegationChain.public_key, and the signed message contains implicit:origin, implicit:nonce and implicit:issued_at_timestamp_ns. Since the guard already ties that key to the caller, verifying this second signature binds caller to origin transitively, using only the IC root key and verify_canister_sig, which the guard already uses. An empty attribute list is supported, so the proof carries no personal data.

It also covers:

  • the allowlist (canonical derivation origin plus alternative origins, since signer domains and beta sign in with derivationOrigin set while other deployments do not), which needs a new alternative_origins config field and therefore a breaking-interface PR;
  • what the fix does not achieve (it does not stop many-anchor Sybil, which belongs to II);
  • that dfx.json pins II release-2026-03-06, which predates these methods; they land in release-2026-07-31;
  • a six-PR rollout that keeps enforcement last so no current client is signed out;
  • open questions, chiefly whether a dapp session identity can obtain the proof directly or whether it must come back through the authorize flow, and which origin II certifies when derivationOrigin is set.

Tests

None. Docs-only change; the format gate covers it. The verification steps, unit-test table and integration-test helper are specified for the implementation PRs.

The guard proves a delegation came from Internet Identity but never checks
which frontend origin it was derived for, so one anchor can mint a distinct
principal per origin and multiply its signer allowance and rate-limit buckets.

The origin cannot be recovered from the chain: II hashes it into the seed with
a canister-private salt, and the signed delegation message omits it. The spec
uses II certified attributes instead, whose signature is made under the same
origin-derived user key and whose message carries implicit:origin.
@AntonioVentilii
AntonioVentilii marked this pull request as ready for review September 7, 2026 12:35
Copilot AI lite review requested due to automatic review settings September 7, 2026 12:35
@AntonioVentilii
AntonioVentilii requested a review from a team as a code owner September 7, 2026 12:35
@zeropath-ai

zeropath-ai Bot commented Sep 7, 2026

Copy link
Copy Markdown

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

Security Overview
Detected Code Changes
Change Type Relevant files
New documentation ► docs/ai/spec-driven-development/specs/2026-09-07-impr-bind-ii-delegation-guard-to-derivation-origin.md
    Add spec for binding II delegation guard to derivation origin

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.

🟢 Approval recommended

It is a docs-only change that adds a well-scoped implementation spec and does not modify runtime behavior.

Pull request overview

Adds a new spec document describing a defense-in-depth design to bind the backend’s Internet Identity (II) delegation guard to the configured derivation origin, addressing a quota-multiplication vector where a single II anchor can mint multiple principals by varying the frontend origin. The spec proposes using II’s ICRC-3 certified attributes (implicit:origin + canister-signature verification) as a second signed artifact to cryptographically bind the caller to an allowed origin, and outlines a staged rollout across several PRs.

Changes:

  • Added a spec detailing the threat model, constraints (origin not recoverable from delegation chain), and proposed origin-proof mechanism.
  • Defined the expected backend/frontend/config changes and a multi-PR rollout plan (with enforcement last).
  • Captured open questions and pending decisions to resolve before implementation.
File summaries
File Description
docs/ai/spec-driven-development/specs/2026-09-07-impr-bind-ii-delegation-guard-to-derivation-origin.md New spec documenting the origin-binding approach and rollout plan for the II delegation guard.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@AntonioVentilii
AntonioVentilii marked this pull request as draft September 8, 2026 11:37
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.

3 participants