CVE-2018-1000810: Buffer overflow vulnerability in str:repeat()
The str::repeat function in Rust's standard library could overflow when calculating the capacity of the resulting string, leading to a buffer overflow. An attacker could exploit this to cause memory corruption, potentially leading to denial of service or arbitrary code execution.
rustsec.org
Published on rustsec.org
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The multiplication of string length by repeat count was not checked for integer overflow, and the subsequent unsafe code assumed the preallocated buffer had sufficient capacity.
Impact
An attacker could cause a buffer overflow, leading to memory corruption with high confidentiality, integrity, and availability impact, potentially enabling arbitrary code execution or denial of service.
What the attacker needed
Code uses str::repeat with attacker-controlled length and…
The fix
The fix checks for overflow and deterministically panics if it happens, and was released in Rust 1.29.1.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A function in Rust's standard library that repeats a string a given number of times had a bug. When the total size of the repeated string was too large to fit in memory, the calculation wrapped around to a small number, and the program then wrote past the end of the allocated memory. This could crash the program or allow an attacker to run malicious code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.