Bug 1955695 (CVE-2021-3527)

Summary: CVE-2021-3527 QEMU: usb: unbounded stack allocation in usbredir
Product: [Other] Security Response Reporter: Mauro Matteo Cascella <mcascell>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: berrange, cfergeau, dbecker, jen, jferlan, jforbes, jjoyce, jmaloy, jschluet, knoel, lhh, lpeer, m.a.young, mburns, mkenneth, mrezanin, mst, ondrejj, pbonzini, philmd, ribarry, rjones, sclewis, slinaber, virt-maint, virt-maint, yduan
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 USB redirector device (usb-redir) of QEMU. Small USB packets are combined into a single, large transfer request, to reduce the overhead and improve performance. The combined size of the bulk transfer is used to dynamically allocate a variable length array (VLA) on the stack without proper validation. Since the total size is not bounded, a malicious guest could use this flaw to influence the array length and cause the QEMU process to perform an excessive allocation on the stack, resulting in a denial of service. The highest threat from this vulnerability is to system availability.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-10-29 08:59:58 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: 1956201, 1956221, 1956222, 1956223, 1956224, 1956225    
Bug Blocks: 1949585, 1955699    

Description Mauro Matteo Cascella 2021-04-30 16:52:07 UTC
A flaw was found in the USB redirection support (usb-redir) of QEMU. More specifically, usb-host and usb-redirect try to batch bulk transfers by combining many small USB packets into a single, large transfer request, to reduce the overhead and improve performance. The combined size of the bulk sending is used in usbredir_handle_bulk_data() to dynamically allocate a variable length array (VLA) on the stack. Since the total size is not bounded, a malicious guest could be able to influence the array length and cause the QEMU process to perform an excessive allocation on the stack, resulting in a denial of service.

Comment 2 Mauro Matteo Cascella 2021-05-03 07:58:03 UTC
Created qemu tracking bugs for this issue:

Affects: fedora-all [bug 1956201]

Comment 4 Mauro Matteo Cascella 2021-05-03 08:45:33 UTC
Statement:

This issue affects the version of `qemu-kvm` as shipped with Red Hat Enterprise Linux 8 and Red Hat Enterprise Linux 8 Advanced Virtualization. A future update may address this flaw.

Comment 5 Mauro Matteo Cascella 2021-05-03 08:55:49 UTC
Upstream patch series:
https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg00564.html

Comment 7 Mauro Matteo Cascella 2021-05-05 19:04:13 UTC
External References:

https://www.openwall.com/lists/oss-security/2021/05/05/5

Comment 8 Mauro Matteo Cascella 2021-05-07 08:51:48 UTC
Acknowledgments:

Name: Remy Noel (Blade Group)

Comment 9 Mauro Matteo Cascella 2021-05-07 09:42:58 UTC
In reply to comment #5:
> Upstream patch series:
> https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg00564.html

Note that the xhci patch was dropped [1] and a new USB patchset has been proposed without it [2]. As discussed upstream, this could leave room for unbound allocation on the heap, although more difficult to exploit by the guest to crash the QEMU process on the host.

[1] https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg01372.html
[2] https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg01373.html