Skip to content

Multiple memory safety vulnerabilities #5

Description

@vnrst

There are multiple memory safety issues with the implementations of methods in CMutSlice that are marked safe, allowing aliased mutable references.

For example :

extern crate cslice;
use cslice::{CMutSlice};

fn main() {
	let mut a : [i32; 5] = [1, 2, 3, 4, 5];

	let mut sl = unsafe{CMutSlice::new(&mut a[0], 5)};

	// Multiple mutable references to same location
	let ptr1: &mut[i32] = sl.as_mut_slice();
	let ptr2: &mut[i32] = sl.as_mut_slice();

	ptr1[0] = 5;

	println!("{:?}", ptr2); // ptr2 will have also changed
}

Similarly, one could exploit vulnerabilities in CMutSlice::as_ptr() and CMutSlice::clone (implicitly derived).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions