{"id":823,"cve":"CVE-2018-1000808","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2018-1000808","cwe":"CWE-404 Improper Resource Shutdown or Release","cwe_number":404,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/404","cvss_score":5.9,"published":"2018-10-08","owasp":"A06 Vulnerable and Outdated Components","odc":"Function","cdc":"Incorrect Functionality","category":"Resource Management","subcategory":"Memory Leaks","scope":"Remote","impact":"Denial of Service (DoS)","summary":"CWE-401 in pyOpenSSL < 17.5.0: Memory Release Issue","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2018-1000808\/","description":"Python Cryptographic Authority pyopenssl version Before 17.5.0 contains a CWE - 401 : Failure to Release Memory Before Removing Last Reference vulnerability in PKCS #12 Store that can result in Denial of service if memory runs low or is exhausted. This attack appear to be exploitable via Depends upon calling application, however it could be as simple as initiating a TLS connection. Anything that would cause the calling application to reload certificates from a PKCS #12 store.. This vulnerability appears to have been fixed in 17.5.0.","solution":"Update pyopenssl to version 17.5.0 or higher.","affected_component":"pyopenssl","fixed_by_upgrading":true,"vulnerable_code":"from OpenSSL import crypto\n\ndef load_pkcs12(p12_file, password):\n    with open(p12_file, 'rb') as f:\n        p12_data = f.read()\n    \n    p12 = crypto.load_pkcs12(p12_data, password)\n    \n    private_key = p12.get_privatekey()\n    certificate = p12.get_certificate()\n    \n    return p12","patched_code":"from OpenSSL import crypto\n\ndef load_pkcs12(p12_file, password):\n    with open(p12_file, 'rb') as f:\n        p12_data = f.read()\n\n    try:\n        p12 = crypto.load_pkcs12(p12_data, password)\n    except crypto.Error as e:\n        raise ValueError(\"Failed to load PKCS12 file: \" + str(e))\n    \n    private_key = p12.get_privatekey()\n    certificate = p12.get_certificate()\n\n    if private_key.bits() < 2048:\n        raise ValueError(\"Private key is too weak. It must be at least 2048 bits.\")\n    \n    store = crypto.X509Store()\n    store.add_cert(certificate)\n    try:\n        store_ctx = crypto.X509StoreContext(store, certificate)\n        store_ctx.verify_certificate()\n    except crypto.X509StoreContextError as e:\n        raise ValueError(\"Certificate is invalid: \" + str(e))\n\n    return p12\n","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[{"repository":"pyca\/pyopenssl","commit_url":"https:\/\/github.com\/pyca\/pyopenssl\/commit\/e73818600065821d588af475b024f4eb518c3509","commit_subject":"fix a memory leak and a potential UAF and also #722 (#723)","units":[{"file":"setup.py","function":null},{"file":"src\/OpenSSL\/crypto.py","function":"load_pkcs12"},{"file":"src\/OpenSSL\/SSL.py","function":"_VerifyHelper.__init__"}]}],"references":null}