Skip to content

sec: ValidateAtSignatureTime panics on nil Data (regression from d2666063) #217

Open

Description

@Harsh23Kashyap

Describe the bug

d266606 ("sec: improved certcache, certlist and expired cert validation") dropped the nil-Data branch from the exported ValidateAtSignatureTime expiry policy:

// before
if args.Data == nil || ValidateSigTime(args.Data, args.Cert) {
// after
if ValidateSigTime(args.Data, args.Cert) {

A nil Data is the documented case where the certificate itself is the object being validated and the signature-time check is deferred until the certificate is used to validate another packet. With the branch gone, the nil Data reaches ValidateSigTime, which dereferences it (data.Signature()) and the process dies with a nil pointer panic - a crash, not a validation result, for any consumer that registered this stock policy and hits the deferred path.

To Reproduce

Add the test file from the linked PR, then: go test ./std/security/ -run NilData -v

=== RUN   TestValidateAtSignatureTimeNilData
    Panic value: runtime error: invalid memory address or nil pointer dereference
--- FAIL: TestValidateAtSignatureTimeNilData (0.00s)
=== RUN   TestValidateSigTimeNilData
    Panic value: runtime error: invalid memory address or nil pointer dereference
--- FAIL: TestValidateSigTimeNilData (0.00s)
FAIL

Expected behavior

ValidateAtSignatureTime with a nil Data defers (accepts) as documented, and ValidateSigTime rejects nil input instead of panicking.

Environment

ndnd @ d51682b (main), Go 1.26, linux/amd64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions