Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2061923

Summary: --subject-alt-name IP:127.0.0.1/255.255.255.255 causes "ERROR: Cannot allocate memory"
Product: Red Hat Enterprise Linux 9 Reporter: Marius Vollmer <mvollmer>
Component: sscgAssignee: Stephen Gallagher <sgallagh>
Status: CLOSED ERRATA QA Contact: Branislav NĂ¡ter <bnater>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: pvlasin
Target Milestone: rcKeywords: AutoVerified, Regression, ZStream
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sscg-3.0.0-5.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2075546 (view as bug list) Environment:
Last Closed: 2022-11-15 09:50:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2075546    

Description Marius Vollmer 2022-03-08 17:49:57 UTC
Description of problem:

Running this:

    sscg --subject-alt-name "IP:127.0.0.1/255.255.255.255"

causes this error:

    ERROR: Cannot allocate memory

Version-Release number of selected component (if applicable):
sscg-3.0.0-4.el9.x86_64
openssl-libs-3.0.1-14.el9.x86_64

How reproducible:
Always

Additional info:
strace shows no failed memory allocation.  This only happens with this specific --subject-alt-name syntax, things like "--subject-alt-name localhost" is fine.

sscg-3.0.0-1.fc35.x86_64 / openssl-libs-1.1.1l-2.fc35.x86_64 on Fedora 35 is fine.

Comment 1 Marius Vollmer 2022-03-08 17:59:13 UTC
Fedora 36 has the same problem with:
sscg-3.0.2-1.fc36.x86_64
openssl-libs-3.0.0-1.fc36.x86_64

Comment 2 Stephen Gallagher 2022-03-08 20:13:09 UTC
I'll take a look at this. My guess is that it's an OpenSSL 3.0 behavior-change that I need to adapt to. Thanks for reporting it!

Comment 3 Stephen Gallagher 2022-03-08 21:20:58 UTC
So, I just did a deep-dive into RFC 5280(1) and it looks like this is actually a case of OpenSSL 3.0 just being stricter than previous versions. According to RFC 5280, the subjectAltName for IPaddresses 'MUST be stored in the octet string in "network byte order"'. However, the name-constraint extension must be stored in the "x.x.x.x/y.y.y.y" format(2), which makes things a bit complicated.

In OpenSSL 1.1, the API appears to have automatically truncated the mask portion of the IP address when it was added as a SAN, but in 3.0 it throws an error. (The "Cannot allocate memory" message was erroneous).

I'm inclined to solve this by just explicitly chopping off the mask before I insert it as a SAN.


(1) https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.6
(2) https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.10

Comment 4 Stephen Gallagher 2022-03-08 21:38:42 UTC
Pull request available now at https://github.com/sgallagher/sscg/pull/56

Marius, would you mind doing a basic code-review?

Comment 5 Marius Vollmer 2022-03-09 06:40:18 UTC
(In reply to Stephen Gallagher from comment #3)
> In OpenSSL 1.1, the API appears to have automatically truncated the mask
> portion of the IP address when it was added as a SAN,

Yes, that's what I see as well.  The certificates ended up having just "IP:127.0.0.1" in them.

Comment 17 errata-xmlrpc 2022-11-15 09:50:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (sscg bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7946