Skip to content

About

Rust vulnerability testing toolkit exploring memory safety boundaries — from safe-Rust panics to raw unsafe memory bugs.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Common Rust Vulnerabilities Scanner

Rust vulnerability testing toolkit exploring memory safety boundaries — from safe-Rust panics to raw unsafe memory bugs.


Overview

This vulnerability tester is a CLI tool that deliberately triggers well-known classes of Rust vulnerabilities — both safe-Rust panics and unsafe memory bugs. It is designed to help security researchers and developers:

  • Understand how Rust's safety guarantees work (and where they break down)
  • Explore the boundary between safe and unsafe Rust
  • Practice crash analysis and vulnerability triage
  • Study memory bug classes relevant to systems and protocol security

Vulnerability Categories

Common (Safe) Rust Panics

Command Description
unwrap_expect Panics from .unwrap() and .expect() on None/Err values
panic_macro Explicit panics via panic!, todo!, unreachable!, etc.
arith Integer overflow and underflow across multiple modes
utf8 Panics from slicing strings at invalid UTF-8 byte boundaries
index_oob Index out-of-bounds access on a slice
stack_overflow Recursive stack exhaustion
oom Out-of-memory via unbounded heap allocation

Unsafe Rust Memory Bugs

Command Description
unsafe_oob Raw pointer read beyond allocated buffer
unsafe_uaf Use-after-free via raw pointer dereference
unsafe_double_free Double-free of heap-allocated memory
unsafe_memory_leak Memory leak via Box::into_raw without reclaim
unsafe_uninit_memory Reading from uninitialized memory
unsafe_data_race Data race across threads

Project Structure

vuln_tester/
├── Cargo.toml
├── Cargo.lock
├── README.md
└── src/
    ├── main.rs             # CLI entry point (structopt dispatch)
    ├── common_vuln.rs      # Safe-Rust panic scenarios
    ├── unsafe_code.rs      # Unsafe memory bug scenarios
    └── double_free.rs      # Double-free specific testing

Getting Started

Prerequisites

  • Rust (stable toolchain)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Build

git clone https://github.com/jabariwoods/Common-Rust-Vulnerabilities-Scanner.git
cd Common-Rust-Vulnerabilities-Scanner
cargo build --release
cargo build                       # debug build for full debu symbols

Usage

cargo run -- <COMMAND> [OPTIONS]

Unwrap & Expect Panics

cargo run -- unwrap_expect <choice>  

Tests various .unwrap() and .expect() call sites that panic on None or Err.

Panic Macros

cargo run -- panic_macro <choice>    

Triggers explicit panics using Rust's built-in panicking macros.

Integer Arithmetic Overflow

cargo run -- arith <choice> <a> <b>   

Tests overflow and underflow with two integer inputs across different operation modes.

cargo run -- arith 1 200 100

UTF-8 String Slicing

cargo run -- utf8 "<string>"

Slices a string at a hardcoded byte boundary — panics when the string contains multibyte characters.

# "банан" is Cyrillic; each character is 2 bytes
cargo run -- utf8 "банан"

Index Out of Bounds

cargo run -- index_oob <offset>       # crashes when offset > 22

Stack Overflow

cargo run -- stack_overflow <value>   # crashes when value == 42

Triggers unbounded recursion leading to a stack overflow.

Out of Memory

cargo run -- oom

Allocates memory in an infinite loop until the OS kills the process.

Unsafe Out-of-Bounds Read

cargo run -- unsafe_oob <input>       

Reads beyond the end of an allocated buffer using a raw pointer.

Use After Free

cargo run -- unsafe_uaf

Frees memory and then dereferences the dangling pointer.

Double Free

cargo run -- unsafe_double_free

Frees the same heap allocation twice — undefined behavior in Rust's unsafe.

Memory Leak

cargo run -- unsafe_memory_leak

Leaks heap memory by converting a Box to a raw pointer without ever reclaiming it.

Uninitialized Memory

cargo run -- unsafe_uninit_memory

Reads from memory that was never initialized.

Data Race

cargo run -- unsafe_data_race

Spawns threads that concurrently read and write shared memory without synchronization.


Warning: Several commands are designed to crash the process or cause undefined behavior. Run in a controlled environment.


Purpose

This tool is intentionally unsafe in places. The goal is education and security research — understanding vulnerability classes at the systems level is foundational to smart contract and protocol security auditing, where similar logic bugs (overflow, reentrancy, uninitialized state) manifest in a different execution environment.


License

MIT

About

Rust vulnerability testing toolkit exploring memory safety boundaries — from safe-Rust panics to raw unsafe memory bugs.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages