Critical severityNVD Advisory· Published May 9, 2022· Updated Sep 16, 2024
Solana rBPF - Incorrect Calculation in sdiv instruction
CVE-2022-23066
Description
In Solana rBPF versions 0.2.26 and 0.2.27 are affected by Incorrect Calculation which is caused by improper implementation of sdiv instruction. This can lead to the wrong execution path, resulting in huge loss in specific cases. For example, the result of a sdiv instruction may decide whether to transfer tokens or not. The vulnerability affects both integrity and may cause serious availability problems.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
solana_rbpfcrates.io | >= 0.2.26, < 0.2.28 | 0.2.28 |
Affected products
1- Range: 0.2.26
Patches
1e61e045f8c24jit: sign-extend the quotient register on sdiv32 (#310)
2 files changed · +32 −1
src/jit.rs+1 −1 modified@@ -913,7 +913,7 @@ fn emit_muldivmod<E: UserDefinedError>(jit: &mut JitCompiler, opc: u8, src: u8, X86Instruction::pop(RAX).emit(jit)?; } - if size == OperandSize::S32 && opc & ebpf::BPF_ALU_OP_MASK == ebpf::BPF_MUL { + if size == OperandSize::S32 && (mul || sdiv) { X86Instruction::sign_extend_i32_to_i64(dst, dst).emit(jit)?; } Ok(())
tests/ubpf_execution.rs+31 −0 modified@@ -838,6 +838,21 @@ fn test_sdiv32_imm() { ); } +#[test] +fn test_sdiv32_neg_imm() { + test_interpreter_and_jit_asm!( + " + lddw r0, 0x10000000c + sdiv32 r0, -4 + exit", + [], + (), + 0, + { |_vm, res: Result| { res.unwrap() as i64 == -3 } }, + 3 + ); +} + #[test] fn test_sdiv32_reg() { test_interpreter_and_jit_asm!( @@ -854,6 +869,22 @@ fn test_sdiv32_reg() { ); } +#[test] +fn test_sdiv32_neg_reg() { + test_interpreter_and_jit_asm!( + " + lddw r0, 0x10000000c + mov r1, -4 + sdiv32 r0, r1 + exit", + [], + (), + 0, + { |_vm, res: Result| { res.unwrap() as i64 == -0x3 } }, + 4 + ); +} + #[test] fn test_div64_imm() { test_interpreter_and_jit_asm!(
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
5- github.com/advisories/GHSA-9qmm-4mfr-r3wjghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2022-23066ghsaADVISORY
- blocksecteam.medium.com/how-a-critical-bug-in-solana-network-was-detected-and-timely-patched-a701870e1324ghsax_refsource_MISCWEB
- github.com/solana-labs/rbpf/commit/e61e045f8c244de978401d186dcfd50838817297ghsax_refsource_MISCWEB
- www.whitesourcesoftware.com/vulnerability-database/CVE-2022-23066ghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.