CVE-2025-22003

Severity CVSS v4.0:
Pending analysis
Type:
CWE-125 Out-of-bounds Read
Publication date:
03/04/2025
Last modified:
01/10/2025

Description

In the Linux kernel, the following vulnerability has been resolved:<br /> <br /> can: ucan: fix out of bound read in strscpy() source<br /> <br /> Commit 7fdaf8966aae ("can: ucan: use strscpy() to instead of strncpy()")<br /> unintentionally introduced a one byte out of bound read on strscpy()&amp;#39;s<br /> source argument (which is kind of ironic knowing that strscpy() is meant<br /> to be a more secure alternative :)).<br /> <br /> Let&amp;#39;s consider below buffers:<br /> <br /> dest[len + 1]; /* will be NUL terminated */<br /> src[len]; /* may not be NUL terminated */<br /> <br /> When doing:<br /> <br /> strncpy(dest, src, len);<br /> dest[len] = &amp;#39;\0&amp;#39;;<br /> <br /> strncpy() will read up to len bytes from src.<br /> <br /> On the other hand:<br /> <br /> strscpy(dest, src, len + 1);<br /> <br /> will read up to len + 1 bytes from src, that is to say, an out of bound<br /> read of one byte will occur on src if it is not NUL terminated. Note<br /> that the src[len] byte is never copied, but strscpy() still needs to<br /> read it to check whether a truncation occurred or not.<br /> <br /> This exact pattern happened in ucan.<br /> <br /> The root cause is that the source is not NUL terminated. Instead of<br /> doing a copy in a local buffer, directly NUL terminate it as soon as<br /> usb_control_msg() returns. With this, the local firmware_str[] variable<br /> can be removed.<br /> <br /> On top of this do a couple refactors:<br /> <br /> - ucan_ctl_payload-&gt;raw is only used for the firmware string, so<br /> rename it to ucan_ctl_payload-&gt;fw_str and change its type from u8 to<br /> char.<br /> <br /> - ucan_device_request_in() is only used to retrieve the firmware<br /> string, so rename it to ucan_get_fw_str() and refactor it to make it<br /> directly handle all the string termination logic.

Vulnerable products and versions

CPE From Up to
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.2 (including) 6.6.85 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.7 (including) 6.12.21 (excluding)
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* 6.13 (including) 6.13.9 (excluding)
cpe:2.3:o:linux:linux_kernel:6.14:rc1:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.14:rc2:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.14:rc3:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.14:rc4:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.14:rc5:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.14:rc6:*:*:*:*:*:*
cpe:2.3:o:linux:linux_kernel:6.14:rc7:*:*:*:*:*:*