From 94f34d50f1c32dd66aefe32b9cec803f20d7bf46 Mon Sep 17 00:00:00 2001 From: "tinycloud-bot[bot]" <348376441+tinycloud-bot[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 00:25:31 +0000 Subject: [PATCH 1/2] fix(TC-3076): hold a child's expiry to its parent's signed expiry at full precision when no renewal applies --- CHANGELOG.md | 1 + tinycloud-core/src/models/delegation.rs | 108 +++++++++++++++++++++++- 2 files changed, 105 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 640e21d09..97c649766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] ### Changes +- `POST /delegate` accepts a child delegation that expires at its parent's exact expiry, milliseconds included, again. Since 1.26.0 the parent's end was read in whole seconds, so a child expiring in the parent's last partial second was refused with 401 "Child delegation expiry exceeds parent expiry". node-sdk's `useDelegation` asks for exactly that expiry, so every new activation failed. A child expiring even 1 ms after its parent is still refused, and a renewed parent's end is unchanged. Details: TC-3076. - SQLite stamp replay deadlines now use the same timestamp encoding as cleanup (TC-2920). - PostgreSQL database artifacts use uncompressed external storage for new writes to avoid repeated decompression during chunked reads (TC-2917). Existing large artifacts require an operator re-toast; verify both storage settings after rollout and follow `scripts/tc2917-README.md` if lock contention deferred the migration. - Encryption: v2 column format with key ids, per-purpose keys and recorded format metadata. Optional strict reads are off by default. Details: TC-2516, TC-2517. diff --git a/tinycloud-core/src/models/delegation.rs b/tinycloud-core/src/models/delegation.rs index 2decdf058..500e1578e 100644 --- a/tinycloud-core/src/models/delegation.rs +++ b/tinycloud-core/src/models/delegation.rs @@ -427,6 +427,24 @@ fn check_app_id_domain_binding(delegation: &util::DelegationInfo) -> Result<(), Ok(()) } +/// The end a child delegation's expiry is held to: the parent's effective end +/// from the authorization graph (renewals and ancestors applied), which the +/// graph keeps in whole seconds (TC-3076). When that end is the parent's own +/// signed expiry, use the signed expiry at full precision instead. Otherwise +/// a child expiring at the parent's exact instant, or anywhere in its last +/// partial second, would be refused. A renewed end (later than that second) +/// or an ancestor's cap (earlier) is used as it is. +fn parent_end_for_child( + effective_end: Option, + signed_expiry: Option, +) -> Option { + match (effective_end, signed_expiry) { + (Some(end), Some(signed)) if end == signed.unix_timestamp() => Some(signed), + (Some(end), signed) => OffsetDateTime::from_unix_timestamp(end).ok().or(signed), + (None, signed) => signed, + } +} + // verify parenthood and authorization #[cfg(test)] async fn validate( @@ -673,10 +691,8 @@ async fn validate_with( .filter(|p| { // valid time bounds: child's validity must be within parent's validity // expiry: child must expire at or before parent (None = no expiry) - let parent_effective_expiry = graph - .effective_expiry(&p.id) - .and_then(|expiry| OffsetDateTime::from_unix_timestamp(expiry).ok()) - .or(p.expiry); + let parent_effective_expiry = + parent_end_for_child(graph.effective_expiry(&p.id), p.expiry); let expiry_valid = match (parent_effective_expiry, delegation.expiry) { (None, _) => true, (Some(_), None) => false, @@ -2942,4 +2958,88 @@ mod tests { } assert_eq!((decided, skipped), (20, 3)); } + + /// TC-3076: a child may expire at its parent's exact instant, milliseconds + /// included, as node-sdk's useDelegation asks; one millisecond later is + /// refused. + #[tokio::test] + async fn a_child_may_expire_at_its_parents_millisecond_but_not_after() { + use sea_orm::sea_query::Expr; + use time::{format_description::well_known::Rfc3339, OffsetDateTime}; + let db = database().await; + let parent = crate::hash::hash(b"tc3076-parent"); + let prefix = "tinycloud:did:key:other:files/kv"; + insert_parent_grant( + &db, + parent, + "did:key:other", + "did:key:actor", + prefix, + "tinycloud.kv/get", + ) + .await; + let parent_expiry = OffsetDateTime::parse("2027-11-15T23:12:08.053Z", &Rfc3339).unwrap(); + Entity::update_many() + .col_expr(Column::Expiry, Expr::value(parent_expiry)) + .filter(Column::Id.eq(parent)) + .exec(&db) + .await + .unwrap(); + let child_at = |expiry: &str| { + let mut child = key_grant_info( + "did:key:actor", + "tinycloud:did:key:other:files/kv/doc", + "tinycloud.kv/get", + &[parent], + ); + child.expiry = Some(OffsetDateTime::parse(expiry, &Rfc3339).unwrap()); + child + }; + for accepted in ["2027-11-15T23:12:08.000Z", "2027-11-15T23:12:08.053Z"] { + validate(&db, &child_at(accepted)) + .await + .unwrap_or_else(|error| panic!("{accepted}: {error}")); + } + let refused = validate(&db, &child_at("2027-11-15T23:12:08.054Z")).await; + assert!( + matches!( + refused, + Err(Error::InvalidDelegation( + DelegationError::ExpiryExceedsParent + )) + ), + "{refused:?}" + ); + } + + /// TC-3076: only the parent's own signed second is read at full + /// precision; a renewed end and an ancestor's cap are used as the graph + /// computed them. + #[test] + fn the_parent_end_is_exact_only_where_it_is_the_signed_expiry() { + use time::{format_description::well_known::Rfc3339, OffsetDateTime}; + let signed = OffsetDateTime::parse("2027-11-15T23:12:08.053Z", &Rfc3339).unwrap(); + let second = signed.unix_timestamp(); + let at = |seconds: i64| OffsetDateTime::from_unix_timestamp(seconds).unwrap(); + // No renewal: the graph's end is the signed second; the signed instant counts. + assert_eq!( + parent_end_for_child(Some(second), Some(signed)), + Some(signed) + ); + // Renewed past the signed expiry: the renewed end, unchanged. + assert_eq!( + parent_end_for_child(Some(second + 600), Some(signed)), + Some(at(second + 600)) + ); + // Capped by an ancestor before it: the cap, unchanged. + assert_eq!( + parent_end_for_child(Some(second - 1), Some(signed)), + Some(at(second - 1)) + ); + // No graph end: the signed expiry; no expiry at all: none. + assert_eq!(parent_end_for_child(None, Some(signed)), Some(signed)); + assert_eq!(parent_end_for_child(None, None), None); + // No signed expiry and an unbounded graph end: no expiry, as before. + assert_eq!(parent_end_for_child(Some(i64::MAX), None), None); + } } From 7a435e9580e7ff9c4353b835023ca14e60ba2b2d Mon Sep 17 00:00:00 2001 From: "tinycloud-bot[bot]" <348376441+tinycloud-bot[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 00:29:35 +0000 Subject: [PATCH 2/2] chore: release 1.26.7 --- CHANGELOG.md | 7 ++++++- Cargo.lock | 2 +- test/m1-realdata-e2e/Cargo.lock | 2 +- tinycloud-node-server/Cargo.toml | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97c649766..dad82a9e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ ## [Unreleased] ### Changes -- `POST /delegate` accepts a child delegation that expires at its parent's exact expiry, milliseconds included, again. Since 1.26.0 the parent's end was read in whole seconds, so a child expiring in the parent's last partial second was refused with 401 "Child delegation expiry exceeds parent expiry". node-sdk's `useDelegation` asks for exactly that expiry, so every new activation failed. A child expiring even 1 ms after its parent is still refused, and a renewed parent's end is unchanged. Details: TC-3076. - SQLite stamp replay deadlines now use the same timestamp encoding as cleanup (TC-2920). - PostgreSQL database artifacts use uncompressed external storage for new writes to avoid repeated decompression during chunked reads (TC-2917). Existing large artifacts require an operator re-toast; verify both storage settings after rollout and follow `scripts/tc2917-README.md` if lock contention deferred the migration. - Encryption: v2 column format with key ids, per-purpose keys and recorded format metadata. Optional strict reads are off by default. Details: TC-2516, TC-2517. @@ -11,6 +10,12 @@ - A new Policy/v3 registration records the share key its content source names (`share/` on the owner's `default` network) in the registration's transaction, so publishing a share needs no `tinycloud.encryption/key.create` grant: the publisher encrypts to the key's public key and registers. A missing key is created at `keyVersion` 1 and counts toward the network's key limit; at the limit the registration answers 403 `key_limit_exceeded` and stores nothing. An existing key keeps its state. The registration now also requires the source's network to exist and be active. Docs: `docs/encryption-named-keys.md`. Details: TC-2525 - Share-email issuer trust bundles can pin one next key for the same issuer DID during an explicit UTC overlap window. The legacy key stops at `issuerNotAfter`; malformed, duplicate, unbounded or expired overlaps fail startup and `--validate-config`. Existing single-key bundles remain unchanged. This is node-side trust support only: the OpenCredentials witness and js-sdk policy contract must also support key rotation before activation. Older node images reject overlap fields; restore the previous single-key bundle before rollback. See `deploy/share-email/production-trust-bundle-contract.md`. +## [1.26.7] - 2026-11-16 + +### Changes + +- `POST /delegate` accepts a child delegation that expires at its parent's exact expiry, milliseconds included, again. Since 1.26.0 the parent's end was read in whole seconds, so a child expiring in the parent's last partial second was refused with 401 "Child delegation expiry exceeds parent expiry". node-sdk's `useDelegation` asks for exactly that expiry, so every new activation failed. A child expiring even 1 ms after its parent is still refused, and a renewed parent's end is unchanged. Details: TC-3076. + ## [1.26.5] - 2026-11-13 ### Changes diff --git a/Cargo.lock b/Cargo.lock index 3d8a081fe..c50f666bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9955,7 +9955,7 @@ dependencies = [ [[package]] name = "tinycloud-node" -version = "1.26.5" +version = "1.26.7" dependencies = [ "aes-gcm", "anyhow", diff --git a/test/m1-realdata-e2e/Cargo.lock b/test/m1-realdata-e2e/Cargo.lock index 7ddbc770d..e9f54b3f9 100644 --- a/test/m1-realdata-e2e/Cargo.lock +++ b/test/m1-realdata-e2e/Cargo.lock @@ -8021,7 +8021,7 @@ dependencies = [ [[package]] name = "tinycloud-node" -version = "1.26.5" +version = "1.26.7" dependencies = [ "aes-gcm", "anyhow", diff --git a/tinycloud-node-server/Cargo.toml b/tinycloud-node-server/Cargo.toml index 968be78cc..e6261b46d 100644 --- a/tinycloud-node-server/Cargo.toml +++ b/tinycloud-node-server/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tinycloud-node" build = "build.rs" -version = "1.26.5" +version = "1.26.7" authors = ["TinyCloud Protocol"] edition = "2021" description = "TinyCloud Protocol Node"