Project

General

Profile

Bug #19974

Updated by hsbt (Hiroshi SHIBATA) 3 months ago

We ran into an instance of attempting to parse invalid PKCS7 certs that consistently causes a segfault in multiple versions of Ruby 3, on multiple platforms (Linux, Mac). 

 To reproduce: 

 ``` 
 ------- (within pry or irb or whatever ruby shell you prefer) ---------- 
 data = "-----BEGIN PKCS7-----\nMAsGCSqGSIb3DQEHAg==\n-----END PKCS7-----\n" 
 OpenSSL::PKCS7.new(data).certificates 
 ----------------- 
 ``` 

 This causes a segfault 100% of the time for me on both an M1 Mac as well as in docker containers running on both Mac as well as Linux hosts. 

 The issue appears to be attempting to parse empty signedData. https://lapo.it/asn1js/#MAsGCSqGSIb3DQEHAg shows that this data contains the necessary ASN1 sequence to look like a valid PKCS7 certificate. However, the signedData is empty. I assume this is the cause of the issue, but I surely don't know. 

 I've attached the info from the core dump inside a linux container running on an M1 Mac.

Back