Details
Recommended Fix
Perform defensive length checks before any split_at usage and return a controlled Err instead of allowing a panic. Minimal fixes in decrypt():
let c1_len_usize = c1_len as usize;
if cipher.len() < c1_len_usize {
return Err(Error);
}
let (c1, c) = cipher.split_at(c1_len_usize);
let digest_size = hasher.output_size();
if c.len() < digest_size {
return Err(Error);
}
let (c2, c3) = match mode {
Mode::C1C3C2 => {
let (c3, c2) = c.split_at(digest_size);
(c2, c3)
}
Mode::C1C2C3 => c.split_at(c.len() - digest_size),
};
After applying these checks, decrypt() will return an error for short or malformed inputs instead of panicking.
Credit
This vulnerability was discovered by:
- XlabAI Team of Tencent Xuanwu Lab
- Atuin Automated Vulnerability Discovery Engine
CVE and credit are preferred.
If you have any questions regarding the vulnerability details, please feel free to reach out to us for further discussion. Our email address is [email protected].
Note
We follow the security industry standard disclosure policy—the 90+30 policy (reference: https://googleprojectzero.blogspot.com/p/vulnerability-disclosure-policy.html). If the aforementioned vulnerabilities cannot be fixed within 90 days of submission, we reserve the right to publicly disclose all information about the issues after this timeframe.