tl;dr : CVE-2024-38531 (see Sandbox escape · Advisory · NixOS/nix · GitHub if the CVE index doesn’t show it yet) was published earlier today. Please update your Nix installation.
Discovered by @lheckemann some time ago, and recently reported with a reproducer by @alois31 , a security issue in Nix allowed allowed a build process to access and change the permissions of the build directory. After creating a setuid binary in a globally accessible location, a malicious local user could assume the permissions of a Nix daemon worker and hijack all future builds.
Concretely, this would happen when all the following conditions are met:
The attacker has access to a local user
The local user has access to the Nix daemon (but does not have to be a trusted user)
seccomp is disabled (if the sandbox is disabled or filter-syscalls
if set to false on Linux) or ineffective (fixed in #10501 )
It has been patched in the following Nix versions:
How to update
The fix will first land in nixos-unstable-small
, and then nixpkgs-unstable
.
Backports to nixos-23.11
And nixos-24.05
are on the way, and are likely to land first on nixos-23.11-small
and nixos-24.05-small
.
If you don’t, or if you can’t afford to wait, you can directly fetch the source from the patches above.
14 Likes
vcunat
June 27, 2024, 3:05pm
2
No, it is not there yet. It wasn’t even in cache.nixos.org at the moment of your post.
Yes, true, excuse the copypasta. I’m just a dog in a lab coat, never done this before.
14 Likes
Because I wasn’t able to find the PR that updated nixpkgs with a quick search for 2.23.1
, I’m linking it here after doing a deeper search.
NixOS:master
← fricklerhandwerk:update-nix
opened 11:44AM - 27 Jun 24 UTC
@nixos/nix-team
## Description of changes
<!--
For package updates please link… to a changelog or describe changes, this helps your fellow maintainers discover breaking updates.
For new packages please briefly describe the package or provide a link to its homepage.
-->
## Things done
- Built on platform(s)
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] x86_64-darwin
- [x] aarch64-darwin
- For non-Linux: Is sandboxing enabled in `nix.conf`? (See [Nix manual](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
- [ ] `sandbox = relaxed`
- [ ] `sandbox = true`
- [ ] Tested, as applicable:
- [NixOS test(s)](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside [nixos/tests](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
- and/or [package tests](https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests)
- or, for functions and "core" functionality, tests in [lib/tests](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or [pkgs/test](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
- made sure NixOS tests are [linked](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
- [ ] Tested compilation of all packages that depend on this change using `nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"`. Note: all changes have to be committed, also see [nixpkgs-review usage](https://github.com/Mic92/nixpkgs-review#usage)
- [ ] Tested basic functionality of all binary files (usually in `./result/bin/`)
- [24.11 Release Notes](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2411.section.md) (or backporting [23.11](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) and [24.05](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2405.section.md) Release notes)
- [ ] (Package updates) Added a release notes entry if the change is major or breaking
- [ ] (Module updates) Added a release notes entry if the change is significant
- [ ] (Module addition) Added a release notes entry if adding a new NixOS module
- [x] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
<!--
To help with the large amounts of pull requests, we would appreciate your
reviews of other pull requests, especially simple package updates. Just leave a
comment describing what you have tested in the relevant package/service.
Reviewing helps to reduce the average time-to-merge for everyone.
Thanks a lot if you do!
List of open PRs: https://github.com/NixOS/nixpkgs/pulls
Reviewing guidelines: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#reviewing-contributions
-->
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc
1 Like
I have been using nosuid,nodev mounts for /nix and /tmp, doesn’t that also prevent this?
No, it doesn’t. But running an up-to-date Nix does.