Security #6286
closedlua/tls: null dereference in GetCertInfo
20fa5d773fd8ccebaa58294f59fb6cd50f55c4d5
Description
I'm currently detecting the use of self-signed certificates using a rule similar to https://www.stamus-networks.com/blog/2015/07/24/finding-self-signed-tls-certificates-suricata-and-luajit-scripting
In certain scenarios -- I'm still not sure which -- it appears that certain members of SSLStateConnp are not populated, and instead contain null pointers. More specifically, in my case, `connp->cert0_issuerdn`. When this is the case and the rule I mentioned is processed, it results in a strlen(NULL) call and thus a segfault as a result of dereferencing a null pointer.
In other parts of the code (e.g. https://github.com/OISF/suricata/blob/becb8cefccc10c352184a9e8e930fd5fa9652651/src/detect-tls-cert-issuer.c#L138 ) these struct members are checked for NULL before usage. This should probably be the case here too.
I'm running 6.0.9, but the same code has appeared in a much wider set of releases -- seemingly since this code was first added in https://github.com/OISF/suricata/commit/371648a8c61e93b42f74263bcedb9d1b8b1af354#diff-5e8f4c32849c58cd5e3fe9786a3b2e818c8a3567211029b8dcbae48bb2fcd0b7