Skip to content

fix(security): harden runtime against critical/high vulnerabilities#25

Merged
miguelgila merged 2 commits intomainfrom
feat/sec-analysis
Mar 1, 2026
Merged

fix(security): harden runtime against critical/high vulnerabilities#25
miguelgila merged 2 commits intomainfrom
feat/sec-analysis

Conversation

@miguelgila
Copy link
Owner

@miguelgila miguelgila commented Mar 1, 2026

Summary

  • Critical: Gate REAPER_NO_OVERLAY behind #[cfg(test)] — overlay bypass impossible in release builds
  • Critical: Validate container/exec IDs against path traversal (../, empty, special chars)
  • High: Restrict config file to REAPER_ prefixed keys only (prevents LD_PRELOAD/PATH injection)
  • High: Set restrictive permissions (0700 dirs, 0600 files) on state files and directories
  • High: Validate PID > 1 before sending kill signals in runtime and shim
  • High: Always clear supplementary groups during privilege drop, even when additional_gids is empty

Test plan

  • All 57 runtime unit tests pass (cargo test --bin reaper-runtime)
  • Clippy clean (cargo clippy --all-targets)
  • New unit tests for validate_id() (path traversal, empty, special chars, length)
  • New unit test for config key rejection (non-REAPER_ keys)
  • CI integration tests pass

🤖 Generated with Claude Code

miguelgila and others added 2 commits March 1, 2026 09:22
- Gate REAPER_NO_OVERLAY behind #[cfg(test)] so overlay bypass is
  impossible in release builds (Critical)
- Validate container/exec IDs against path traversal: reject empty,
  '..', slashes, and non-alphanumeric chars (Critical)
- Restrict config file to REAPER_ prefixed keys only, preventing
  injection of LD_PRELOAD, PATH, etc. (High)
- Set restrictive permissions (0700 dirs, 0600 files) on state files
  and directories (High)
- Validate PID > 1 before sending kill signals to prevent signalling
  init or the caller's process group (High)
- Always clear supplementary groups during privilege drop, even when
  additional_gids is empty, to prevent inheriting root's groups (High)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
#[cfg(test)] only applies to the test harness, not binary targets
built alongside it. Integration tests spawn reaper-runtime as a
subprocess, so the overlay bypass was inactive in CI.

Switch to #[cfg(debug_assertions)] which is active in debug builds
(cargo test) but not in release builds (production).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 1, 2026

Codecov Report

❌ Patch coverage is 87.80488% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.09%. Comparing base (c7ef98f) to head (8b16f66).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/bin/containerd-shim-reaper-v2/main.rs 72.72% 3 Missing ⚠️
src/bin/reaper-runtime/main.rs 50.00% 1 Missing ⚠️
src/bin/reaper-runtime/state.rs 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
+ Coverage   85.94%   88.09%   +2.14%     
==========================================
  Files           5        5              
  Lines         185      252      +67     
==========================================
+ Hits          159      222      +63     
- Misses         26       30       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@miguelgila miguelgila merged commit 4da65e7 into main Mar 1, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant