VYPR
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.

PackageAffected versionsPatched versions
solana_rbpfcrates.io
>= 0.2.26, < 0.2.280.2.28

Affected products

1

Patches

1
e61e045f8c24

jit: sign-extend the quotient register on sdiv32 (#310)

https://github.com/solana-labs/rbpfAlessandro DecinaApr 29, 2022via ghsa
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

News mentions

0

No linked articles in our index yet.