While writing a Nessus plugin to detect the issues in HP's HPSBMU03546 advisory, Tenable discovered a vulnerability in the X.509 certificate handling within the
AddCertsToTrustCfgList() function. Within
mod_smh_config.so, the code tries to extract the common name in the subject of a certificate being processed. When a certificate is processed, the
apr_strtok() function (included from Apache APR) tries to access address 0x3 if the subject common name is not present. The common name is used to derive the file name of the certificate to be stored in
<SMH_INSTALLATION_DIR>/certs/. For example, if the subject common name is "echidna",
echidna.pem is stored. In addition, certificates added for Trusted Management Servers are displayed as "
common_name(common_name.pem)" on the Trusted Management Servers page in the SMH web GUI. To exploit this vulnerability, the 'Trust Mode' setting must be configured with 'Trust All', the 'IP Restricted login' setting must allow the attacker to access SMH, and the 'Kerberos Authorization' (Windows only) setting must be disabled. As such, the access complexity for this attack is rated 'High'.
According to HP, the
AddCertsToTrustCfgList() function was reworked to better handle subject common name has '&' characters in it. The
AddCertsToTrustCfgList() function in SMH 7.5.3 had problems extracting common names that contain a & character. We believe this is because the '&' character is used to separate the common name and email address in the subject line. SMH 7.5.3 searches for the first '&' character using
apr_strtok() and uses the text up to (but not including) the '&' character as the certificate file name. If the common name contains a '&' character, only portion of the common name is extracted. In addition to the problem handling subject common name with '&' characters, the
AddCertsToTrustCfgList() function in SMH 7.5.3 has the vulnerability that can be exploited when processing a user-supplied certificate that doesn't have a subject common name. For example, imagine a certificate with a subject line "
Subject: C=XX, L=Default City, O=Echidna Company Ltd". The code sXEName = strstr(x509->name,"CN=") will return NULL, and
apr_strtok() is passed with an address of 3 in the
sXEName parameter, leading to an address access violation. The same crash does not happen in 184.108.40.206, so at some point HP's enhancements to SMH fixed this issue as well. Based on the analysis, this is a flaw in the AddCertsToTrustCfgList() function which doesn't check for presence of a subject common name and passes an invalid address to the Apache APR function
Tenable generated a NASL PoC against SMH 220.127.116.11, that we will not be sharing, running under the following configuration:
- SMH 18.104.22.168 running on a 32-bit Windows 2008 Server SP2
Trusted By All" is configured
- IP Restricted Login is not configured
- Kerberos Authorization is not configured
The DoS attack can be produced in two ways to demonstrate the issue:
$ nasl -WaXt hpsmh_7_5_3_1_null_cn.dos.nasl
- Import cert_null_cn.pem under Settings -> SMH -> Security -> Trusted Management Server -> Add Certificate -> Import Certificate Data