CWEweakness
CWE-1335 Incorrect Bitwise Shift of Integer
- Abstraction
- Base
- Structure
- Simple
- Status
- Draft
- Languages
- C, C#, C++, Java, JavaScript, Python
- CWE version
- 5.0
Description
An integer value is specified to be shifted by a negative amount or an amount greater than or equal to the number of bits contained in the value.
Extended description
Specifying a value to be shifted by a negative amount is undefined in various languages. Various computer architectures implement this action in different ways. The compilers and interpreters when generating code to accomplish a shift generally do not do a check for this issue.
Specifying an over-shift - a shift greater than or equal to the number of bits contained in a value to be shifted - produces a result that varies by architecture and compiler. In some languages, this action is undefined.
Common consequences
• Integrity: DoS: Crash, Exit, or Restart
• Other: Undefined Behavior, Unexpected State, Alter Execution Logic
Potential mitigations
• [Implementation] Implicitly or explicitly add checks and mitigation for negative or over-shift values.
Detection methods
• Automated Static Analysis: Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Observed examples
• CVE-2023-4720: multimedia product performs a left shift with a negative value, leading to a crash
• CVE-2009-4307: An unexpected large value in the ext4 filesystem causes an overshift condition resulting in a divide by zero.
• CVE-2012-2100: An unexpected large value in the ext4 filesystem causes an overshift condition resulting in a divide by zero - fix of CVE-2009-4307.
• CVE-2020-8835: An overshift in a kernel allowed out of bounds reads and writes resulting in a root takeover.
• CVE-2015-1607: Program is not properly handling signed bitwise left-shifts causing an overlapping memcpy memory range error.
• CVE-2016-9842: Compression function improperly executes a signed left shift of a negative integer.
• CVE-2018-18445: Some kernels improperly handle right shifts of 32 bit numbers in a 64 bit register.
• CVE-2013-4206: Putty has an incorrectly sized shift value resulting in an overshift.
• CVE-2018-20788: LED driver overshifts under certain conditions resulting in a DoS.
Related
Observed example · CVE (9)
- CVE-2023-4720 Floating Point Comparison with Incorrect Operator in GitHub repository gpac/gpac prior to 2.3-DEV. vulnerability
- CVE-2020-8835 In the Linux kernel 5.5.0 and newer, the bpf verifier (kernel/bpf/verifier.c) did not properly restrict the register bounds for 32-bit… vulnerability
- CVE-2015-1607 kbx/keybox-search.c in GnuPG before 1.4.19, 2.0.x before 2.0.27, and 2.1.x before 2.1.2 does not properly handle bitwise left-shifts, which… vulnerability
- CVE-2018-20788 drivers/leds/leds-aw2023.c in the led driver for custom Linux kernels on the Xiaomi Redmi 6pro daisy-o-oss phone has several integer… vulnerability
- CVE-2018-18445 In the Linux kernel 4.14.x, 4.15.x, 4.16.x, 4.17.x, and 4.18.x before 4.18.13, faulty computation of numeric bounds in the BPF verifier… vulnerability
- CVE-2016-9842 The inflateMark function in inflate.c in zlib 1.2.8 might allow context-dependent attackers to have unspecified impact via vectors… vulnerability
- CVE-2013-4206 Heap-based buffer underflow in the modmul function in sshbn.c in PuTTY before 0.63 allows remote SSH servers to cause a denial of service… vulnerability
- CVE-2012-2100 The ext4_fill_flex_info function in fs/ext4/super.c in the Linux kernel before 3.2.2, on the x86 platform and unspecified other platforms,… vulnerability
- CVE-2009-4307 The ext4_fill_flex_info function in fs/ext4/super.c in the Linux kernel before 2.6.32-git6 allows user-assisted remote attackers to cause a… vulnerability
Child of · CWE (1)
- CWE-682 Incorrect Calculation weakness
Referenced by CVE · weakness (8)
- CVE-2026-93925 Stack-based buffer overflow, Incorrect bitwise shift of integer vulnerability in Apache Thrift C++ THeaderProtocol. vulnerability
- CVE-2026-88357 nDPI 5.1.0 contains a memory access issue in the DNS dissector and serializer deserialization code. vulnerability
- CVE-2026-5072 A bitwise shift vulnerability in Zephyr's PTP subsystem allows a remote attacker to cause undefined behavior and potential system crashes. vulnerability
- CVE-2026-4426 A flaw was found in libarchive. vulnerability
- CVE-2025-32029 ts-asn1-der is a collection of utility classes to encode ASN.1 data following DER rule. vulnerability
- CVE-2023-52810 In the Linux kernel, the following vulnerability has been resolved: fs/jfs: Add check for negative db_l2nbperpage l2nbperpage is… vulnerability
- CVE-2023-3161 A flaw was found in the Framebuffer Console (fbcon) in the Linux Kernel. vulnerability
- CVE-2016-9842 The inflateMark function in inflate.c in zlib 1.2.8 might allow context-dependent attackers to have unspecified impact via vectors… vulnerability