Skip to content

Security: rubtsov-stan/rift

SECURITY.md

Security policy

Supported versions

Version Supported
0.2.x yes
0.1.x no

Reporting a vulnerability

Report vulnerabilities privately through GitHub: open the Security tab of rubtsov-stan/rift, choose "Report a vulnerability", or go straight to https://github.com/rubtsov-stan/rift/security/advisories/new.

Do not open a public issue for a vulnerability.

Include:

  • the Rift version (rift --version) and your platform;
  • the command line and a description of the input that triggers the problem. A pair generated with rift-gen and its seed works well;
  • what you expected and what happened: a crash, memory use above --mem, a wrong diff, an out-of-bounds read.

This is a one-person project. I read every report and reply when I can, without a fixed timeline.

Paths

rift A B on two directories never follows a symbolic link inside the trees: it compares the link's target as bytes, so a link cannot lead the walk out of the tree or into a loop. It never opens a FIFO, socket or device inside the trees. The two operands themselves are followed.

Unsafe code

rift-gen, rift-mcp, rift-session and rift-tui forbid unsafe_code. rift-cli denies it except in the two FFI modules below. rift-core has one unsafe item, the counting allocator. CI runs Miri on rift-core under two aliasing models:

  • Stacked Borrows, Miri's default: the unit tests of every module except scan, skeleton, diff, moves, keyed and sched, and except the anchors test that splits the table across threads, plus tests/alloc_small.rs, which installs the counting allocator and exercises its unsafe forwarding on a few KiB.
  • Tree Borrows: the unit tests of scan, skeleton, moves and keyed, and the anchors test many_samples_split_the_table_with_the_same_result. They start rayon's thread pool, and rayon's crossbeam-epoch 0.9.21 trips a report inside its own code under Stacked Borrows only. Leak checks are off for these, because rayon's pool outlives the test process.

Not run under Miri: the unit tests of diff, which do not finish within the CI time limit; those of sched, whose worker threads and timeouts do not fit Miri's speed; the integration tests other than alloc_small; and the refine property tests that run 10 000 cases, the unit tests of unified that run the system diff and patch, and a few others marked #[cfg_attr(miri, ignore)]. Tests that are too slow at full size use smaller inputs under Miri instead (cfg!(miri) in the test): fewer rows, shorter lines, fewer budgets and piece sizes. Property tests run 8 cases each under Miri. The FFI modules in rift-cli are not covered.

The Miri jobs run nightly, on demand and on pull requests that touch crates/rift-core, not on every push.

Every block below has a // SAFETY: comment, and the workspace lint clippy::undocumented_unsafe_blocks is set to deny.

Location What SAFETY comment
crates/rift-core/src/alloc.rs, unsafe impl GlobalAlloc for CountingAlloc Counting global allocator Every method forwards to System unchanged and only adjusts counters, so the allocator contract is inherited from System.
same file, alloc System.alloc Same layout the caller guaranteed to be non-zero-sized.
same file, alloc_zeroed System.alloc_zeroed As for alloc.
same file, dealloc System.dealloc ptr came from this allocator with this layout, by contract.
same file, realloc System.realloc ptr and layout match a live allocation, by contract.
crates/rift-cli/src/source.rs, hints::sequential (Linux) libc::posix_fadvise The descriptor is open and owned by file for the duration of the call; fadvise reads no memory and only updates kernel state.
same file, hints::sequential (macOS) libc::fcntl(F_RDAHEAD) The descriptor is open and owned by file for the duration of the call; F_RDAHEAD takes an integer flag and touches no memory.
crates/rift-cli/src/full.rs, clock::utc_offset mem::zeroed and libc::localtime_r tm is plain data for which all-zero bytes are valid, and localtime_r writes only into the struct we pass, reading t.
crates/rift-tui/tests/common/counting.rs, unsafe impl GlobalAlloc for Counting (test code) Counting allocator for heap tests Every call is forwarded unchanged to System, which upholds the GlobalAlloc contract; the counters have no effect on the memory handed out. Its alloc, dealloc and realloc blocks each carry a one-line comment saying the pointer and layout come from System or from the caller.

Workflow permissions

Every workflow except release.yml sets permissions: contents: read at the top. Jobs that need more ask for it themselves: security-events: write in Scorecard and CodeQL, contents: write in the jobs that attach .deb packages, VSIX packages and provenance files to a release, issues: write in the job that reports a failing nightly Miri run, pages: write and id-token: write in the job that deploys the site.

release.yml is generated by dist 0.34 and is not edited by hand. Scorecard flags three things in it that stay until dist changes:

  • contents: write at the top of the workflow. dist has no setting to move it to the jobs that need it. The workflow runs only on version tags.
  • curl ... | sh of the dist installer in the plan job, and of rustup in container builds (none are configured). dist writes both and has no setting for a checksum. The installer comes from the axodotdev/cargo-dist release of the pinned version over HTTPS.
  • secrets: inherit on the jobs that call deb.yml, vscode.yml and provenance.yml. Those workflows read no secrets.

Either dist generating job-level permissions and checksum-verified installs, or dropping dist for a hand-written release workflow, would remove all three.

The steps for cutting a release are in RELEASING.md.

There aren't any published security advisories