carlos / platform Public

edge: asset fill window compares the signed skew against both bounds

Negating a saturated minimum Duration (an assertion signed centuries ahead)
left it negative and inside the window. Regression added for +-300 years.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev d00bbac9f9e0516f731711250347f566d4dc76b1 parent cdb8206
2 files changed, +21 −4
  • internal/edge/assetfill.go +4 −4
  • internal/edge/assetfill_test.go +17 −0

CI failed — run details

diff --git a/internal/edge/assetfill.go b/internal/edge/assetfill.go
index c2ab2dd4f..465a5b62f 100644
--- a/internal/edge/assetfill.go
+++ b/internal/edge/assetfill.go
@@ -94,11 +94,11 @@ func verifyAssetFill(current, next []byte, c assetFillClaims, header string, now
if err != nil {
return nil, false
}
+ // Compare the signed duration against both bounds. Negating it would
+ // leave a saturated minimum Duration (a timestamp centuries ahead)
+ // negative, and so inside the window.
skew := now.Sub(time.Unix(sec, 0))
- if skew < 0 {
- skew = -skew
- }
- if skew > hopSkew {
+ if skew < -hopSkew || skew > hopSkew {
return nil, false
}
got, err := hex.DecodeString(sig)
diff --git a/internal/edge/assetfill_test.go b/internal/edge/assetfill_test.go
index f377d949f..c4c90e1d5 100644
--- a/internal/edge/assetfill_test.go
+++ b/internal/edge/assetfill_test.go
@@ -210,3 +210,20 @@ func TestAckUsesTheKeyTheAssertionMatched(t *testing.T) {
t.Fatal("an acknowledgement under the other key verified at the far edge")
}
}
+
+// A genuinely signed assertion dated centuries ahead makes now.Sub saturate
+// at the minimum Duration, which negates to itself. The window must still
+// refuse it, in both directions.
+func TestAssetFillRefusesFarFutureAndFarPastTimestamps(t *testing.T) {
+ c := testFillClaims()
+ for _, years := range []int{300, -300} {
+ signedAt := fillNow.AddDate(years, 0, 0)
+ h := signAssetFill(fillKeyCurrent, c, signedAt)
+ if h == "" {
+ t.Fatalf("years=%d: could not sign", years)
+ }
+ if _, ok := verifyAssetFill(fillKeyCurrent, fillKeyNext, c, h, fillNow); ok {
+ t.Fatalf("assertion signed %d years from now verified", years)
+ }
+ }
+}