Bug 1783552 (CVE-2019-19536)

Summary: CVE-2019-19536 kernel: information leak bug caused by a malicious USB device in the drivers/net/can/usb/peak_usb/pcan_usb_pro.c driver
Product: [Other] Security Response Reporter: msiddiqu
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: acaringi, airlied, bhu, blc, brdeoliv, bskeggs, dhoward, dvlasenk, esammons, fhrbata, hdegoede, hkrzesin, iboverma, ichavero, itamar, jarodwilson, jeremy, jforbes, jlelli, john.j5live, jonathan, josef, jross, jshortt, jstancek, jwboyer, kernel-maint, kernel-mgr, lgoncalv, linville, masami256, mchehab, mcressma, mjg59, mlangsdo, nmurray, qzhao, rt-maint, rvrbovsk, steved, williams, wmealing
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
A flaw was found in the Linux kernel’s implementation of the driver for the PEAK System PCAN-USB adapter. On device initialization, the driver can leak information to all devices connected to the CANBUS.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-10-25 22:15:11 UTC Type: ---
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: 1783553, 1785096, 1785097, 1785098, 1785099    
Bug Blocks: 1783555    

Description msiddiqu 2019-12-13 21:43:30 UTC
A flaw was found in the Linux kernels implementation of the driver for the PEAK System PCAN-USB adapter. On device initialization the driver can leak information to devices all devices connected to the CANBUS.


Upstream Patch:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ead16e53c2f0ed946d82d4037c630e2f60f4ab69

References: 

https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.2.9
http://seclists.org/oss-sec/2019/q4/115
https://www.openwall.com/lists/oss-security/2019/12/03/4

Comment 1 msiddiqu 2019-12-13 21:43:57 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 1783553]

Comment 2 Justin M. Forbes 2019-12-16 17:19:54 UTC
This was fixed for Fedora with the 5.2.9 stable kernel update.

Comment 3 Wade Mealing 2019-12-19 05:36:26 UTC
It appears that the information leaks 'across the bus' not actually to the host, below is the code with not relevant sections snipped out.

static int pcan_usb_pro_drv_loaded(struct peak_usb_device *dev, int loaded)
{
   <snip> 
        buffer = kmalloc(PCAN_USBPRO_FCT_DRVLD_REQ_LEN, GFP_KERNEL);

        err = pcan_usb_pro_send_req(dev, PCAN_USBPRO_REQ_FCT,
                                    PCAN_USBPRO_FCT_DRVLD, buffer,
                                    PCAN_USBPRO_FCT_DRVLD_REQ_LEN);
        kfree(buffer);
}

So, the area for abuse is in pcan_usb_pro_send_req(), the req_addr arg.

pcan_usb_pro_send_req()
|  usb_control_msg()
|    usb_internal_control_msg()
|        usb_fill_control_urb() (enters struct urb->transfer_buffer here)
|    usb_start_wait_urb()
|    | usb_submit_urb()
|    |    usb_hcd_submit_urb()
|    |
|    usb_free_urb(urb); <-- freed here.|
|
| < kfreed here.
  
At this point its deep enough in the usb stack that I know that its not coming back as a value that is leaking to userspace, its going to be on the bus.


The attacker would need a device on the CANBUS (see https://en.wikipedia.org/wiki/CAN_bus ) to gather the information leak that is leaked.    This would mean that CVSSV3 scores would be scored as either physical or adjacent attack vectors. I'm going to choose adjacent as the attacker may wish to be on the network, listening for this 'information leak' while an end user plugs their device in.  

The CAN bus is a broadcast bus, all nodes on the network do get all packets of data sent by a node.  It appears that the data being leaked to the bus would be previous stack contents or userspace or kernel space data structures that previous occupied this area.

Just to be clear, this is -not- a normal TCP/IP network leak this is a -very- specific network type found on automotive and marine drive systems.

Comment 5 Wade Mealing 2019-12-19 06:30:23 UTC
This flaw is rated as moderate, its an information leak that only happens once at device creation time, access methods of the information is quite difficult.

Comment 8 Wade Mealing 2019-12-19 06:58:12 UTC
External References:

https://www.nxp.com/docs/en/reference-manual/BCANPSV2.pdf

Comment 9 Wade Mealing 2019-12-19 07:00:48 UTC
Mitigation:

As the pcan_usb  module will be auto-loaded when required, its use can be disabled  by preventing the module from loading with the following instructions:

# echo "install pcan_usb /bin/true" >> /etc/modprobe.d/disable-pcan_usb.conf 
 
The system will need to be restarted if the module is loaded. In most circumstances, the pcan_usb kernel modules will be unable to be unloaded while any CANBUS interfaces are active and the protocol is in use.

If the system requires this module to work correctly, this mitigation may not be suitable.

If you need further assistance, see KCS article https://access.redhat.com/solutions/41278 or contact Red Hat Global Support Services.