Repository navigation
fix: refuse DIDs the node cannot verify offline (TC-1500) - #677
Merged
Merged
Conversation
- Accept did:key Ed25519/secp256k1/P-256 (48/49-char ids, length checked before decoding), did:jwk with the same key types (<=256-char ids) and did:pkh eip155/solana/bip122. - Refuse malformed or unverifiable issuers (did_unverifiable:) and new grants to such holders (did_holder_unverifiable:); did:tinycloud:policy:<64 hex> holders stay exempt. - Holder check runs last in check_capability_rules and in save_owner_renewal_lease. - Remove did_resolution.network_methods via REMOVED_SETTINGS; /info keeps it as false. - did:key parsers accept only the Ed25519 multicodec; eip191 needs an eip155 issuer. Supersedes #392. Details: TC-1500
… (TC-1500) - Review N1: did:key, did:jwk, did:pkh:solana and the shared did_key_public_key parser refuse Ed25519 keys that do not decompress or are of small order (VerifyingKey::is_weak); ssi verifies with dalek's non-strict verify, so anyone could sign for such a key. - Review N3: process_with answers Existing for a stored grant whose only refusal is its holder, as the single /delegate path already does. - Review N2: CHANGELOG wording; the encryption-network and share-email parsers accepted the one-byte 0xed form before this change. Details: TC-1500
…ile (TC-1500) The m1-realdata e2e workspace builds tinycloud-auth by path; its separate lockfile needs the new direct ed25519-dalek dependency or `cargo --locked` refuses it. Details: TC-1500
…lockfile (TC-1500) The third separately locked workspace that builds tinycloud-auth by path. All three CI-checked lockfiles now resolve with --locked. Details: TC-1500
samgbafa
pushed a commit
that referenced
this pull request
Nov 21, 2026
Conflicts resolved: - delegation::process_with keeps both Existing arms: a stored delegation refused as SessionRetired (TC-3443) or UnverifiableHolder (TC-1500) answers Existing on resubmit. - delegation::save_owner_renewal_lease runs check_holder, then the retire check. - CHANGELOG/README keep both entries; tinycloud.toml drops the removed did_resolution block and keeps session_retire. Details: TC-3443
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #392. Security card item 11, approved by Sam with every recommended choice. Details: TC-1500.
What changes
The node verifies a UCAN signature only when it can derive the signer's key offline. Any other DID is refused before it is decoded or resolved. The same rule now applies to the holder (
aud) of every new grant posted to/delegate.did_unverifiable:/did_holder_unverifiable:)did:key0xed 0x01), secp256k1 (0xe7 0x01), P-256 (0x80 0x24), compressed, base58btc. The id must be exactly 48 or 49 chars, checked before the base58 decode (M1)0xedprefix (z2D…), P-384, private-key codecs, off-curve points, small-order Ed25519 keys, uncompressed keysdid:jwkd, other curves (P-384, X25519), off-curve points, small-order Ed25519 keys, oversized idsdid:pkheip155(0x+40 hex),solana(32-byte base58 Ed25519 key),bip122(Bitcoin or Dogecoin mainnet genesis); id at most 96 charstezos, the legacyeth/sol/btc/… forms, other chain references, malformed accounts, small-order solana keysdid_method_disabled:(unchanged), before resolution and without any network connectiondid:tinycloud:policy:<64 lowercase hex>did:tinycloud:policy:formPoints are validated through
JWK::from_multicodec(did:key) and ato_multicodecround trip (did:jwk). Ed25519 keys (did:key, did:jwk, solana) must also decompress and must not be of small order (VerifyingKey::is_weak). ssi verifies with dalek's non-strictverify, so anyone could sign for a small-order key, and a grant to one would be a grant to everyone (review N1).Status codes are unchanged: 401 on
/delegateand/invoke, 403 on/revoke. Refusals incrementtinycloud_did_resolution_refused_total{method,reason}with the new reasonsunverifiableandholder_unverifiable.Other changes:
check_holderis the last ofdelegation::check_capability_rules, which runs in the pre-lockprecheck(TC-3000) and again invalidate_with, so it covers/delegate, the Policy/v3 batch paths andprocess. It also runs insave_owner_renewal_lease. Refusals specific to the capabilities (key-delete-not-delegable, named keys, SQL caveats) keep their codes, and so do issuer refusals. Stored grants and invocations are not re-checked. Renewal-original verification (renewal.rs) is unchanged, so an existing grant still renews. Resubmitting a grant already stored still answers as already registered, on both paths: the single path already did, andprocess_withnow does too when the only refusal is the holder (review N3).did:keyparsers now use one function,tinycloud_auth::share_email_evidence::did_key_public_key. It accepts Ed255190xed 0x01only, checks the length before decoding, and refuses keys that do not decompress or are of small order.eip191authority artifact must name aneip155did:pkhissuer before key recovery.did_resolution.network_methodsremoved. It goes through the existingREMOVED_SETTINGSpath (the TC-2961 pattern): a node that still sets it starts and warns that it is ignored./info did_resolution.network_methodsstays as a constantfalsefor existing readers. Use the documented DID method policy for UCAN verification #392's opt-in mechanism is not carried forward.01, and bip122 does not check the base58check checksum. Such a holder can never sign an invocation the node verifies, so refusing it adds no protection.The 247
did:key:z2D…grants this refuses, and why they are inert (for Bobbie)Production holds 247 live grants (135 distinct holders) whose holder is a
did:key:z2D…. After this PR, a new grant to such a holder is refused withdid_holder_unverifiable:. The stored ones are untouched.Census, from Amos's GO read of the BC replica on 11-19 at about 21:00Z (Linear TC-1500 comment cf4201f8):
did:keyEd25519did:pkheip155did:key:z2D…did:tinycloud:policyWhy the z2D grants are inert:
GET /peer/generate/<space>. Until a767302 (2026-06-05, "feat: add encryption network module",tinycloud-core/src/keys.rs), the node encoded them as[0xed] + key, a one-byte varint, instead of the0xed 0x01Ed25519 multicodec. Base58 of that prefix givesz2D….0xeddid:key, so no UCAN delegation, invocation or revocation signed by a z2D DID could verify. The replica shows that no z2D DID ever issued one. The holder can't use the grant, and nobody can re-delegate from it. Before this PR, two other parsers did accept the one-byte form: the encryption-network request signer (encryption_network/service.rs) and the share-email data-plane signer (share_email/data_plane.rs). Both now use the shared0xed 0x01parser. Whether any z2D-signed request ever reached those two paths is a production log question (review N2), and Amos is asked to check it before deploy.z6Mk…, so no current client produces z2D holders.Holder formats produced by every grant-creating client (for Naomi's GO)
The new intake rule accepts these holders:
did:keywith Ed25519, secp256k1 or P-256 keys, id 48–49 chars;did:jwk, id ≤256 chars;did:pkhaccountseip155:<digits>:0x<40 hex>, solana and bip122 (BTC, DOGE);did:tinycloud:policy:<64 lowercase hex>.A
#fragmentis stripped before the check (tinycloud-core/src/util.rs:217,:247).Refs below are js-sdk
origin/mastercb3edeab4, openkeyorigin/main05edebab, secret-managerorigin/mainc21daa9, and this PR.did:key:z6Mk…(0xed 0x01+ 32 bytes, 48 chars), from the WASM session managersrc/session/manager.rs:209(JWK::generate_ed25519),:281(DIDKey::generate); web-sdksrc/adapters/BrowserWasmBindings.ts:105,:110createSessionKey("cli")src/auth/local-key.ts:23-27--deviceapproval0xed 0x01apps/api/src/services/device-authorization.ts:337-344; CLI sendspublicJwk(...)at clisrc/auth/browser-auth.ts:109createSessionKey('courier')/('courier-relay'); peerdid:keyrebuilt as0xed 0x01+ x; named recipients must be an exact Ed25519 Courierdid:keysrc/commands.ts:59-62,src/invitation.ts:264-265,:316-317,src/state.ts:395,src/did-key.ts:17-18createSessionKey("hosted-mcp")src/remote-store.ts:1367-1370URIthe app supplies (any URI shape) for authorize-sign; device as above; renewal lease to the node's renewerapps/api/src/services/signed-subset.ts:136,:332;renewal-lease.ts:211did:keyURI is now refused at/delegate(see the note after the table)aud)did:keyviapublic_key_to_did_key(0xed 0x01)tinycloud-core/src/renewal.rs:438-444,tinycloud-core/src/keys.rs:19-27; served at/.well-known/tinycloud/node-keys, read by openkeyrenewal-lease.ts:168-176and node-sdksrc/TinyCloudNode.ts:2685owner_lease_registrationexercises it throughsave_owner_renewal_leasedid:tinycloud:policy:<sha256 hex>, lowercase (hex()of a sha256)src/addressed-publish.ts:139-140,:196,:421did:key(activeNode.nodeDid)src/addressed-publish.ts:422; clisrc/share/adapters.ts:942,:1017; couriersrc/email-invitation.ts:136audis the DID without its fragmentsrc/delegations/SharingService.ts:738-741,:778src/addressed-publish.ts:114,:368,:421-422/requestTinyCloudWeb.signIn(): the web-sdk session keysrc/lib/request/session.ts:238,:249No client produces a holder that fails the rule.
One behaviour change for hand-typed holders:
tc delegation create --to <did>(clisrc/commands/delegation.ts:142,:167), node-sdkcreateDelegation, and a third-party OpenKey caller.did:webholder used to be stored, and that grant was unusable: since TC-1080, no such DID can sign an invocation the node verifies. It is now refused at intake withdid_holder_unverifiable.did:pkh:eth/did:pkh:tezosholder is now refused the same way. In the replica census, the live holder classes are only Ed25519did:key,did:pkh:eip155, policy, and the 247 z2D grants, so no live grant uses these forms.Renewal end-to-end suites
renewal_scheduler_e2eandrenewal_stop_all_e2eare gated by#![cfg(feature = "renewal-test-clock")], so a plain--test '*'run compiles them to 0 tests.CI runs them in
.github/workflows/renewal-scheduler.yml, on every pull request, with--features renewal-test-clockagainst SQLite and PostgreSQL 16.On this head, with the feature, both pass locally on SQLite:
scheduler_renews_over_http_then_lease_expiresok;stop_all_pauses_renewals_until_resumedok.Tests
tinycloud-coreunit tests (did_resolution::tests):accepts_every_offline_key_type_and_account_namespacerefuses_unverifiable_did_keys_with_lengths_checked_before_decoding(a decode counter proves the oversized, z2D, P-384 and base64 cases are refused with 0 decodes)refuses_unverifiable_did_jwks_with_length_checked_before_decodingrefuses_unverifiable_did_pkh_accountsrefuses_network_methods_and_exempts_only_policy_holdersrefuses_small_order_ed25519_keys: identity, order-2 and order-4 keys as did:key, did:jwk and solana, as issuers and holders (review N1)models::delegation::tests::new_grant_holder_must_be_verifiable: accepted and refused holders throughcheck_capability_rulesandprocess; a stored z2D-holder grant resubmitted throughprocessanswersExisting(review N3); a malformed issuer keeps its issuer code.routes::tests::key_delete::an_owner_delete_credential_is_not_a_delegation(existing) still getskey-delete-not-delegablefor a credential whoseaudis a URN.tests/did_resolution_policy.rs:every_offline_key_type_verifies_and_forgery_is_refused: key Ed/k1/P-256, jwk Ed/k1/P-256, pkh eip155/solana/bip122; checks a forged control and a revocation.unverifiable_offline_identifiers_are_refused: z2D, tezos, legacy eth.tinycloud-nodetests/did_resolution_routes.rs:/invoke(401),/delegate(401),/revoke(403);delegate_refuses_unverifiable_holder_with_401;tests/did_resolution_app_startup.rs: the app starts with the removed setting set, and still refuses network methods.removed_settings_tests: true, false and["web"].share_email_evidence::did_key_public_key_refuses_wrong_lengths_without_decoding,share_email_evidence::did_key_public_key_refuses_small_order_keys,data_plane::did_key_signer_is_the_ed25519_multicodec_only,verifier::eip191_issuer_must_be_an_eip155_pkh_before_recovery.Release
Merges only on Naomi's GO naming the head SHA. It ships in the next node release through Amos.
test-ruling: TC-1500 tinycloud-node removes the did_resolution.network_methods tests with the removed setting (tests/did_resolution_app_startup.rs, tests/did_resolution_policy.rs, main.rs/lib.rs/runtime.rs/control.rs config tests; replaced by removed_settings_tests and check_verifiable tests), changes tests/did_resolution_routes.rs from did_method_disabled: to did_unverifiable: on the same three routes and statuses, and replaces non-DID placeholder holders with real Ed25519 did:keys; no assertion loosened (2026-11-21)