Fix corrupted events with zero-filled IDs/pubkeys/sigs (v0.47.1)
Some checks failed
Go / build-and-release (push) Has been cancelled
Some checks failed
Go / build-and-release (push) Has been cancelled
- Add validation in GetEventIdBySerial to ensure sei value is 32 bytes - Fix fallback-to-legacy bug: return error instead of attempting legacy unmarshal on compact format data when event ID lookup fails - Add upfront validation in UnmarshalCompactEvent for eventId length - Prevents events with all-zero IDs from being returned to clients Files modified: - pkg/database/serial_cache.go: Validate sei value is exactly 32 bytes - pkg/database/fetch-events-by-serials.go: Return error for compact format when eventId missing instead of falling back to legacy unmarshal - pkg/database/fetch-event-by-serial.go: Same fix for single event fetch - pkg/database/compact_event.go: Validate eventId is 32 bytes upfront - pkg/version/version: Bump to v0.47.1 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -251,7 +251,11 @@ func (d *D) GetEventIdBySerial(ser *types.Uint40) (eventId []byte, err error) {
|
||||
}
|
||||
|
||||
return item.Value(func(val []byte) error {
|
||||
eventId = make([]byte, len(val))
|
||||
// Validate that the stored value is exactly 32 bytes
|
||||
if len(val) != 32 {
|
||||
return errors.New("corrupted event ID: expected 32 bytes")
|
||||
}
|
||||
eventId = make([]byte, 32)
|
||||
copy(eventId, val)
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user