rudra

Rust Memory Safety & Undefined Behavior Detection

https://github.com/sslab-gatech/rudra

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    3 of 8 committers (37.5%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (16.3%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

Rust Memory Safety & Undefined Behavior Detection

Basic Info
  • Host: GitHub
  • Owner: sslab-gatech
  • License: apache-2.0
  • Language: Rust
  • Default Branch: master
  • Homepage:
  • Size: 1.21 MB
Statistics
  • Stars: 1,348
  • Watchers: 28
  • Forks: 48
  • Open Issues: 12
  • Releases: 0
Created over 5 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Citation

README.md

Rudra

Rudra is a static analyzer to detect common undefined behaviors in Rust programs. It is capable of analyzing single Rust packages as well as all the packages on crates.io.

Rudra and its associated paper received the Distinguished Artifact Award at the 28th ACM Symposium on Operating Systems Principles 2021 (SOSP '21). (PDF, short talk, long talk)

You can find the list of bugs found by Rudra at Rudra-PoC repository.

Usage

The easiest way to use Rudra is to use Docker.

  1. First, make sure your system has Docker and Python 3 installed.
  2. Add rudra:latest image on your system. There are two ways of doing this:
    • docker pull ghcr.io/sslab-gatech/rudra:master && docker tag ghcr.io/sslab-gatech/rudra:master rudra:latest
    • Alternatively, you can build your own image with docker build . -t rudra:latest
  3. Run ./setup_rudra_runner_home.py <directory> and set RUDRA_RUNNER_HOME to that directory. Example: ./setup_rudra_runner_home.py ~/rudra-home && export RUDRA_RUNNER_HOME=$HOME/rudra-home.
    • There are two scripts, ./setup_rudra_runner_home.py and ./setup_rudra_runner_home_fixed.py. In general, ./setup_rudra_runner_home.py should be used unless you want to reproduce the result of the paper with a fixed cargo index.
  4. Add docker-helper in Rudra repository to $PATH. Now you are ready to test Rudra!

For development, you might want to install Rudra on your host system. See DEV.md for advanced usage and development guide.

Run Rudra on a single project

docker-cargo-rudra <directory>

The log and report are printed to stderr by default.

Run Rudra as GitHub Action

Rudra can be run as a GitHub Action allowing the static analyze to be used in an Action workflow.

```yml

Run Rudra

  • name: Rudra uses: sslab-gatech/Rudra@master ```

Run Rudra with different compiler version

Rudra is tied to a specific Rust compiler version, and it can only analyze projects that compiles with this version of the compiler. master branch uses nightly-2021-10-21 version of Rust right now. Check the version page for all supported versions.

Known Issues

  • Rudra does not support workspaces (#11). You can install Rudra on your host system (see DEV.md) and run analysis in the subdirectories to sidestep the problem for now.
  • Rudra does not support suppressing warnings in specific locations. This could cause a usability issue when used in CI/CD due to false positives.

Bug Types Detected by Rudra

Rudra currently detects the following bug types. For the full detail, please check our SOSP 2021 paper.

Panic Safety (Unsafe code that can create memory-safety issues when panicked)

Detects when unsafe code may lead to memory safety issues if a user provided closure or trait panics. For example, consider a function that dereferences a pointer with ptr::read, duplicating its ownership and then calls a user provided function f. This can lead to a double-free if the function f panics.

See this section of the Rustonomicon for more details.

```rust while idx < len { let ch = unsafe { self.getunchecked(idx..len).chars().next().unwrap() }; let chlen = ch.len_utf8();

// Call to user provided predicate function f that can panic.
if !f(ch) {
    del_bytes += ch_len;
} else if del_bytes > 0 {
    unsafe {
        ptr::copy(
            self.vec.as_ptr().add(idx),
            self.vec.as_mut_ptr().add(idx - del_bytes),
            ch_len,
        );
    }
}

// Point idx to the next char
idx += ch_len;

} ```

Example: rust#78498

Higher Order Invariant (Assumed properties about traits)

When code assumes certain properties about trait methods that aren't enforced, such as expecting the Borrow trait to return the same reference on multiple calls to borrow.

rust let mut g = Guard { len: buf.len(), buf }; // ... Ok(n) => g.len += n,

Example: rust#80894

Send Sync Variance (Unrestricted Send or Sync on generic types)

This occurs when a type generic over T implements Send or Sync without having correct bounds on T.

rust unsafe impl<T: ?Sized + Send, U: ?Sized> Send for MappedMutexGuard<'_, T, U> {} unsafe impl<T: ?Sized + Sync, U: ?Sized> Sync for MappedMutexGuard<'_, T, U> {}

Example: futures#2239

Bugs Found by Rudra

Rudra was ran on the entirety of crates.io state as of July 4th, 2020 as well as the Rust standard library from nightly-2020-08-26. It managed to find 264 new memory safety issues across the Rust ecosystem which resulted in 76 CVEs.

The details of these bugs can be found in the Rudra-PoC repo.

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Owner

  • Name: gts3.org (SSLab@Gatech)
  • Login: sslab-gatech
  • Kind: organization
  • Email: sslab@cc.gatech.edu
  • Location: School of Computer Science, Georgia Tech

https://gts3.org

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: Bae
    given-names: Yechan
    affiliation: "Georgia Institute of Technology"
  - family-names: Kim
    given-names: Youngsuk
    affiliation: "Georgia Institute of Technology"
  - family-names: Askar
    given-names: Ammar
    affiliation: "Georgia Institute of Technology"
  - family-names: Lim
    given-names: Jungwon
    affiliation: "Georgia Institute of Technology"
  - family-names: Kim
    given-names: Taesoo
    affiliation: "Georgia Institute of Technology"
title: "Rudra Static Analyzer"
date-released: 2021-10-26
version: 0.1.0
url: "https://github.com/sslab-gatech/Rudra"
preferred-citation:
  # This part is currently incomplete (no page numbers, etc.) and will be filled after the conference.
  type: conference-paper
  authors:
    - family-names: Bae
      given-names: Yechan
      affiliation: "Georgia Institute of Technology"
    - family-names: Kim
      given-names: Youngsuk
      affiliation: "Georgia Institute of Technology"
    - family-names: Askar
      given-names: Ammar
      affiliation: "Georgia Institute of Technology"
    - family-names: Lim
      given-names: Jungwon
      affiliation: "Georgia Institute of Technology"
    - family-names: Kim
      given-names: Taesoo
      affiliation: "Georgia Institute of Technology"
  journal: "ACM Symposium on Operating Systems Principles (SOSP)"
  month: 10
  title: "Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale"
  year: 2021

GitHub Events

Total
  • Issues event: 4
  • Watch event: 37
  • Issue comment event: 4
  • Pull request review event: 1
  • Pull request event: 2
  • Fork event: 8
Last Year
  • Issues event: 4
  • Watch event: 37
  • Issue comment event: 4
  • Pull request review event: 1
  • Pull request event: 2
  • Fork event: 8

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 267
  • Total Committers: 8
  • Avg Commits per committer: 33.375
  • Development Distribution Score (DDS): 0.348
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Yechan Bae y****n@g****u 174
ykim837 y****7@g****u 66
Ammar Askar a****r@a****m 11
Noah Stiltner n****1@l****u 5
GeekMasher g****r@g****m 4
setuid0 s****0@p****m 3
bjorn3 b****3 2
Rajiv Shah r****1@i****m 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 36
  • Total pull requests: 18
  • Average time to close issues: 9 months
  • Average time to close pull requests: 24 days
  • Total issue authors: 21
  • Total pull request authors: 9
  • Average comments per issue: 1.83
  • Average comments per pull request: 2.28
  • Merged pull requests: 13
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 9
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 3
  • Pull request authors: 1
  • Average comments per issue: 0.33
  • Average comments per pull request: 0.33
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • stoneman258 (4)
  • Qwaz (3)
  • sobolevn (1)
  • r-wheeler (1)
  • zjp-CN (1)
  • Luro02 (1)
  • Morganamilo (1)
  • aytey (1)
  • sydhds (1)
  • GeekMasher (1)
  • VaynNecol (1)
  • kirawi (1)
  • fuzious (1)
  • SocialistDalao (1)
  • Bergmann89 (1)
Pull Request Authors
  • stoneman258 (4)
  • Qwaz (4)
  • JOE1994 (2)
  • bjorn3 (2)
  • nstilt1 (2)
  • ammaraskar (1)
  • rajivshah3 (1)
  • GeekMasher (1)
  • rex4539 (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

Cargo.lock cargo
  • addr2line 0.15.2
  • adler 1.0.2
  • ahash 0.3.8
  • autocfg 1.0.1
  • backtrace 0.3.60
  • bitflags 1.2.1
  • cargo_metadata 0.11.4
  • cc 1.0.69
  • cfg-if 0.1.10
  • cfg-if 1.0.0
  • chrono 0.4.19
  • const-random 0.1.13
  • const-random-macro 0.1.13
  • crunchy 0.2.2
  • dashmap 3.11.10
  • doc-comment 0.3.3
  • either 1.6.1
  • fern 0.6.0
  • getrandom 0.2.3
  • gimli 0.24.0
  • hermit-abi 0.1.19
  • if_chain 1.0.1
  • instant 0.1.10
  • itoa 0.4.7
  • lazy_static 1.4.0
  • libc 0.2.98
  • lock_api 0.4.4
  • log 0.4.14
  • maplit 1.0.2
  • memchr 2.4.0
  • miniz_oxide 0.4.4
  • num-integer 0.1.44
  • num-traits 0.2.14
  • num_cpus 1.13.0
  • object 0.25.3
  • once_cell 1.8.0
  • parking_lot 0.11.1
  • parking_lot_core 0.8.3
  • proc-macro-hack 0.5.19
  • proc-macro2 1.0.27
  • quote 1.0.9
  • redox_syscall 0.2.9
  • rustc-demangle 0.1.20
  • rustc_version 0.2.3
  • ryu 1.0.5
  • scopeguard 1.1.0
  • semver 0.9.0
  • semver 0.10.0
  • semver-parser 0.7.0
  • serde 1.0.126
  • serde_derive 1.0.126
  • serde_json 1.0.64
  • smallvec 1.6.1
  • snafu 0.6.10
  • snafu-derive 0.6.10
  • syn 1.0.73
  • termcolor 1.1.2
  • time 0.1.43
  • tiny-keccak 2.0.2
  • toml 0.5.8
  • unicode-xid 0.2.2
  • wait-timeout 0.2.0
  • wasi 0.10.2+wasi-snapshot-preview1
  • which 4.1.0
  • winapi 0.3.9
  • winapi-i686-pc-windows-gnu 0.4.0
  • winapi-util 0.1.5
  • winapi-x86_64-pc-windows-gnu 0.4.0
crawl/Cargo.lock cargo
  • 205 dependencies
.github/workflows/container.yml actions
  • actions/checkout v2 composite
  • docker/build-push-action v2.7.0 composite
  • docker/login-action v1.10.0 composite
  • docker/metadata-action v3.5.0 composite
  • satackey/action-docker-layer-caching v0.0.11 composite
.github/workflows/rust.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
.github/workflows/stdlib.yml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
action.yml actions
  • .github/action.Dockerfile * docker
Cargo.toml cargo
crawl/Cargo.toml cargo
stdlib-analysis/Cargo.lock cargo
stdlib-analysis/Cargo.toml cargo
Dockerfile docker
  • buildpack-deps buster build
stdlib-analysis/Dockerfile docker
  • rudra 2020-08-26 build