Skip to content

fix(evp): two bugs in this module that may lead to crash#73

Open
spacewander wants to merge 2 commits into
cdbattags:masterfrom
spacewander:fix-null
Open

fix(evp): two bugs in this module that may lead to crash#73
spacewander wants to merge 2 commits into
cdbattags:masterfrom
spacewander:fix-null

Conversation

@spacewander

@spacewander spacewander commented Jul 8, 2026

Copy link
Copy Markdown

Summary

Type of Change

  • feat — new feature or capability
  • fix — bug fix
  • chore — maintenance (deps, config, CI)
  • docs — documentation only
  • ci — CI/workflow changes
  • refactor — code change that neither fixes a bug nor adds a feature

Checklist

  • Tests pass (prove -r t via the Docker testsuite image)
  • Commit messages follow Conventional Commits

LuaJIT cdata values are always truthy, including null pointers.
'if not key then' silently skips the nil check when
PEM_read_bio_RSAPrivateKey returns NULL for a malformed key,
leading to EVP_PKEY_set1_RSA(evp_pkey, NULL) and a worker SIGSEGV.
'if key == nil' is the correct LuaJIT idiom for null cdata detection.
EVP_PKEY_get0_EC_KEY returns NULL when the EVP_PKEY holds a non-EC key
(e.g., RSA). Passing NULL to EC_KEY_get0_group on the next line causes
SIGSEGV.

This is reachable via jwt:verify when a caller provides an RSA public
key to verify a token whose header claims alg=ES256/ES384/ES512.
@spacewander spacewander changed the title fix(evp): use == nil for C null pointer check in _new_key fix(evp): two bugs in this module that may lead to crash Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant