Bug 1837946 (CVE-2019-20792) - CVE-2019-20792 opensc: Double free in coolkey_free_private_data in libopensc/card-coolkey.c
Summary: CVE-2019-20792 opensc: Double free in coolkey_free_private_data in libopensc/...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2019-20792
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1837948 1838182 1838709 1838710 1838711 1838712 1838713 1838714 1841494
Blocks: 1837950
TreeView+ depends on / blocked
 
Reported: 2020-05-20 09:12 UTC by Marian Rehak
Modified: 2021-02-16 20:00 UTC (History)
6 users (show)

Fixed In Version: opensc 0.20.0
Doc Type: If docs needed, set a value
Doc Text:
A use-after-free vulnerability was discovered in OpenSC while disconnecting a smart card. This flaw allows a physical attacker to exploit this vulnerability by inserting and removing a malicious smart card, handled by the coolkey driver, that could potentially execute code on the target system, with privileges that depend on the particular configuration and system that makes use of the OpenSC library.
Clone Of:
Environment:
Last Closed: 2020-11-04 02:25:31 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2020:4483 0 None None None 2020-11-04 01:23:09 UTC

Description Marian Rehak 2020-05-20 09:12:36 UTC
OpenSC before 0.20.0 has a double free in coolkey_free_private_data because coolkey_add_object in libopensc/card-coolkey.c lacks a uniqueness check.

Comment 1 Marian Rehak 2020-05-20 09:13:12 UTC
Created opensc tracking bugs for this issue:

Affects: fedora-30 [bug 1837948]

Comment 3 Riccardo Schirone 2020-05-20 15:17:44 UTC
Created opensc tracking bugs for this issue:

Affects: epel-all [bug 1838182]

Comment 8 Riccardo Schirone 2020-05-22 09:47:54 UTC
Function coolkey_free_private_data() iterates over all elements in coolkey_private_data_t.objects_list, freeing the `data` field. However, it may happen that two items in the list have the same `data` value, thus causing the double free when the second element is freed. If coolkey_add_object() is called multiple times with the same `object_id`, when an object `data` is filled with coolkey_fill_object() it may sets the same value on multiple objects in the list.

The issue is fixed by ensuring that there is only one unique element for a given object_id value.

Comment 10 Riccardo Schirone 2020-05-29 09:28:39 UTC
The double-free can be triggered only during clean-up of the smart card structures and an attack would very likely require multiple attempts due to the various protections used in Red Hat Enterprise Linux and Fedora (e.g. ASLR), which would mean an attacker has to remove and re-insert the malicious smart card multiple times to actually exploit the system. When such attacks fail, this would result just in a segmentation fault with no security consequences. 

Considering the above reasons, I am increasing the Attack Complexity to High (AC:H) in the CVSSv3 score and downgrading the Impact of this flaw to Moderate, as they make the flaw much harder to exploit.

Comment 11 Riccardo Schirone 2020-05-29 09:33:58 UTC
Mitigation:

If the coolkey driver is not necessary for the configuration and system in use, it is possible to disable it by not listing it in the /etc/opensc.conf file.
For example:
```
app default {
   card_drivers = cac, cac1, PIV-II;
}
```

Comment 13 errata-xmlrpc 2020-11-04 01:23:24 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2020:4483 https://access.redhat.com/errata/RHSA-2020:4483

Comment 14 Product Security DevOps Team 2020-11-04 02:25:31 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2019-20792


Note You need to log in before you can comment on or make changes to this bug.