{"id":"CVE-2022-50156","state":"PUBLISHED","title":"HID: cp2112: prevent a buffer overflow in cp2112_xfer()","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nHID: cp2112: prevent a buffer overflow in cp2112_xfer()\n\nSmatch warnings:\ndrivers/hid/hid-cp2112.c:793 cp2112_xfer() error: __memcpy()\n'data->block[1]' too small (33 vs 255)\ndrivers/hid/hid-cp2112.c:793 cp2112_xfer() error: __memcpy() 'buf' too\nsmall (64 vs 255)\n\nThe 'read_length' variable is provided by 'data->block[0]' which comes\nfrom user and it(read_length) can take a value between 0-255. Add an\nupper bound to 'read_length' variable to prevent a buffer overflow in\nmemcpy().","publishedAt":"2025-06-18T11:03:13.913Z","updatedAt":"2026-08-05T08:57:33.812Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"3af7d60e9a6c17d6d41c4341f8020511887d372d","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"519ff31a6ddd87aa4905bd9bf3b92e8b88801614","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"ebda3d6b004bb6127a66a616524a2de152302ca7","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"8489a20ac481b08c0391608d81ed3796d373cfdf","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"e7028944e61014ae915e7fb74963d3835f2f761a","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"26e427ac85c2b8d0d108cc80b6de34d33e2780c4","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"381583845d19cb4bd21c8193449385f3fefa9caf","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/hid/hid-cp2112.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"4.15","status":"affected"},{"version":"0","status":"unaffected","lessThan":"4.15","versionType":"semver"},{"version":"4.19.256","status":"unaffected","lessThanOrEqual":"4.19.*","versionType":"semver"},{"version":"5.4.211","status":"unaffected","lessThanOrEqual":"5.4.*","versionType":"semver"},{"version":"5.10.137","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.61","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"5.18.18","status":"unaffected","lessThanOrEqual":"5.18.*","versionType":"semver"},{"version":"5.19.2","status":"unaffected","lessThanOrEqual":"5.19.*","versionType":"semver"},{"version":"6.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/hid/hid-cp2112.c"]}],"references":["https://git.kernel.org/stable/c/3af7d60e9a6c17d6d41c4341f8020511887d372d","https://git.kernel.org/stable/c/519ff31a6ddd87aa4905bd9bf3b92e8b88801614","https://git.kernel.org/stable/c/ebda3d6b004bb6127a66a616524a2de152302ca7","https://git.kernel.org/stable/c/8489a20ac481b08c0391608d81ed3796d373cfdf","https://git.kernel.org/stable/c/e7028944e61014ae915e7fb74963d3835f2f761a","https://git.kernel.org/stable/c/26e427ac85c2b8d0d108cc80b6de34d33e2780c4","https://git.kernel.org/stable/c/381583845d19cb4bd21c8193449385f3fefa9caf"],"weaknesses":[],"ingestedAt":"2026-10-29T20:05:26.763Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2022/50xxx/CVE-2022-50156.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2022-50156","state":"PUBLISHED","datePublished":"2025-06-18T11:03:13.913Z","dateUpdated":"2026-08-05T08:57:33.812Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2025-06-18T10:57:27.425Z"},"containers":{"cna":{"title":"HID: cp2112: prevent a buffer overflow in cp2112_xfer()","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nHID: cp2112: prevent a buffer overflow in cp2112_xfer()\n\nSmatch warnings:\ndrivers/hid/hid-cp2112.c:793 cp2112_xfer() error: __memcpy()\n'data->block[1]' too small (33 vs 255)\ndrivers/hid/hid-cp2112.c:793 cp2112_xfer() error: __memcpy() 'buf' too\nsmall (64 vs 255)\n\nThe 'read_length' variable is provided by 'data->block[0]' which comes\nfrom user and it(read_length) can take a value between 0-255. Add an\nupper bound to 'read_length' variable to prevent a buffer overflow in\nmemcpy()."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"3af7d60e9a6c17d6d41c4341f8020511887d372d","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"519ff31a6ddd87aa4905bd9bf3b92e8b88801614","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"ebda3d6b004bb6127a66a616524a2de152302ca7","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"8489a20ac481b08c0391608d81ed3796d373cfdf","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"e7028944e61014ae915e7fb74963d3835f2f761a","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"26e427ac85c2b8d0d108cc80b6de34d33e2780c4","versionType":"git"},{"version":"542134c0375b5ca2b1d18490c02b8a20bfdd8d74","status":"affected","lessThan":"381583845d19cb4bd21c8193449385f3fefa9caf","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/hid/hid-cp2112.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"4.15","status":"affected"},{"version":"0","status":"unaffected","lessThan":"4.15","versionType":"semver"},{"version":"4.19.256","status":"unaffected","lessThanOrEqual":"4.19.*","versionType":"semver"},{"version":"5.4.211","status":"unaffected","lessThanOrEqual":"5.4.*","versionType":"semver"},{"version":"5.10.137","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.61","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"5.18.18","status":"unaffected","lessThanOrEqual":"5.18.*","versionType":"semver"},{"version":"5.19.2","status":"unaffected","lessThanOrEqual":"5.19.*","versionType":"semver"},{"version":"6.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/hid/hid-cp2112.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/3af7d60e9a6c17d6d41c4341f8020511887d372d"},{"url":"https://git.kernel.org/stable/c/519ff31a6ddd87aa4905bd9bf3b92e8b88801614"},{"url":"https://git.kernel.org/stable/c/ebda3d6b004bb6127a66a616524a2de152302ca7"},{"url":"https://git.kernel.org/stable/c/8489a20ac481b08c0391608d81ed3796d373cfdf"},{"url":"https://git.kernel.org/stable/c/e7028944e61014ae915e7fb74963d3835f2f761a"},{"url":"https://git.kernel.org/stable/c/26e427ac85c2b8d0d108cc80b6de34d33e2780c4"},{"url":"https://git.kernel.org/stable/c/381583845d19cb4bd21c8193449385f3fefa9caf"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - The overflow is triggered through the local i2c-dev I2C_SMBUS ioctl path into cp2112_xfer(), not by crafted USB HID reports from a malicious peripheral. Presence of a CP2112 adapter is a deployment precondition; the attack itself is a local syscall against /dev/i2c-N.\nAC:L - An attacker who can open the adapter reliably sets data->block[0] above I2C_SMBUS_BLOCK_MAX (e.g. 33–61) and completes a normal I2C block read; no race or unpredictable state outside attacker influence is required. CP2112 deployments typically have responding I2C slaves (EEPROMs/sensors) that the attacker can address.\nPR:L - i2cdev_open() performs no capability check; access is governed by /dev/i2c-* permissions, commonly 0660 root:i2c or similarly granted to unprivileged service accounts on embedded/industrial systems. That is basic local access, not real root/init-namespace admin rights.\nUI:N - Exploitation requires only the attacker issuing ioctl(I2C_SMBUS) with I2C_SMBUS_I2C_BLOCK_DATA; no victim action is needed.\nS:U - This is ordinary kernel memory corruption within the host OS authority (local privilege escalation/DoS), with no VM escape, IOMMU bypass, or other cross-boundary impact.\nC:H - The bug is an out-of-bounds write of attacker-chosen length (and I2C-sourced contents) past union i2c_smbus_data on the stack, which is memory corruption that can be leveraged for information disclosure.\nI:H - Out-of-bounds stack write via memcpy(data->block+1, buf, read_length) with read_length up to 61 into a 33-byte destination enables integrity compromise and potential control-flow hijacking.\nA:H - The same memory corruption can crash the kernel (oops/panic) even when not fully exploited for code execution."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T08:57:33.812Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.15","versionEndExcluding":"4.19.256"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.15","versionEndExcluding":"5.4.211"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.15","versionEndExcluding":"5.10.137"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.15","versionEndExcluding":"5.15.61"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.15","versionEndExcluding":"5.18.18"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.15","versionEndExcluding":"5.19.2"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"4.15","versionEndExcluding":"6.0"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}