Skip to content

[BUG] getEventExpiration() accepts expiration timestamp 0 as valid and rejects valid year 2287+ timestamps #707

Description

@Priyanshubhartistm

Describe the bug

In src/utils/event.ts, getEventExpiration() validates the NIP-40 expiration tag with a Math.log10() bounds check:

if (Number.isSafeInteger(expirationTime) && Math.log10(expirationTime) < 10) {
  return expirationTime
}

To Reproduce

Steps to reproduce the behavior:

  1. Publish an event with an expiration tag of 0, e.g. ["expiration", "0"].
  2. Observe the relay treats it as a validing/ignoring it.
  3. Publish an event with an expiration tag > 9999999999, e.g. ["expiration", "10000000000"].
  4. Observe the expiration is silently drores.

Screenshots

N/A

System

  • OS: Linux
  • Platform: Docker
  • Version: 3.0.0

Logs

N/A — no error is logged; the timestamp ided.

Additional context

getEventExpiration() is at src/utils/evenis at src/utils/event.ts:256). Its result feeds addExpirationMetadata() in src/handlers/event-message-handler.ts, so discard-far-future cases affect real event expiry behavior.

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions