Repository navigation
Conversation
rig uses the package name from the package's own `DESCRIPTION` and uses it to construct various paths. Previously a name like `../victim` or `/tmp/x` could prompt rig to create, replace or delete from directories than intended, so this commit adds a small guard against actively malicious names at install time. Unit tests are included. Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
After a successful `R CMD INSTALL`, rig patches the `DESCRIPTION` file and moves the built package into the cache. Previously a maliciously crafted package could use symlinks (either the `DESCRIPTION` file or the package directory itself) to make rig itself write to arbitrary filesystem locations; this commit hardens rig against symlink misuse at this stage. Unfortunately, there's a lot of complexity here to prevent TOCTOU attacks. Unit tests are included. Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
Previously a local source was copied into a deterministic location in rig's cache during installation. As of this commit we move them into a fresh directory for the build instead, the same approach we use for git sources. This sidesteps various race issues and potential pitfalls of a partially-built packages (as discussed in #526). Unit tests are included. Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
This commit introduces a new lightweight sandboxing mechanism for source package builds on Linux, largely designed to protect the cache from malicious package installs. It includes a new `--sandbox` flag, defaulting to `off`. CRAN policy holds that package builds must not write outside of the build directory or `/tmp`; this sandbox enforces that, so all well-behaved packages should work with it alrady. If spot checked a few popular ones, too. When possible we also prevent builds from connecting to Unix sockets or sending signals outside of the sandbox, too. The sandbox mechanism is based on Landlock, which does not require elevated privileges and even works inside of containers. Debian 13, Ubuntu 24.04, and RHEL 9.6 and later all have the requisite kernel support. Unit tests are included, as is a NEWS entry. Signed-off-by: Aaron Jacobs <aaron.jacobs@posit.co>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #533 +/- ##
==========================================
+ Coverage 69.20% 69.36% +0.15%
==========================================
Files 97 98 +1
Lines 55815 56212 +397
==========================================
+ Hits 38628 38989 +361
- Misses 17187 17223 +36 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: this is build in top of #530, #531, and #532, so it looks larger than it actually is.
This commit introduces a new lightweight sandboxing mechanism for source package builds on Linux, largely designed to protect the cache from malicious package installs. It includes a new
--sandboxflag, defaulting tooff.CRAN policy holds that package builds must not write outside of the build directory or
/tmp; this sandbox enforces that, so all well-behaved packages should work with it already. I've spot checked a few popular ones, too.When possible we also prevent builds from connecting to Unix sockets or sending signals outside of the sandbox, too.
The sandbox mechanism is based on Landlock, which does not require elevated privileges and even works inside of containers. Debian 13, Ubuntu 24.04, and RHEL 9.6 and later all have the requisite kernel support.
Unit tests are included, as is a NEWS entry.