# CVE-2021-27851: Local privilege escalation in GNU Guix via guix-daemon and '--keep-failed'

> Local attackers can escalate privileges to root by exploiting hardlink handling in guix-daemon when the --keep-failed option is used.

- **Severity:** Medium 5.5 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 26 Apr 2021
- **Updated:** 17 Sep 2024
- **Also known as:** DEBIAN-CVE-2021-27851, GHSA-c5fp-qrw2-8x2w, UBUNTU-CVE-2021-27851, openSUSE-SU-2024:10836-1

## What is CVE-2021-27851?

CVE-2021-27851 is a medium-severity vulnerability in GNU Guix guix-daemon, published on 26 Apr 2021. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

A security vulnerability that can lead to local privilege escalation has been found in ’guix-daemon’. It affects multi-user setups in which ’guix-daemon’ runs locally. The attack consists in having an unprivileged user spawn a build process, for instance with `guix build`, that makes its build directory world-writable. The user then creates a hardlink to a root-owned file such as /etc/shadow in that build directory. If the user passed the --keep-failed option and the build eventually fails, the daemon changes ownership of the whole build tree, including the hardlink, to the user. At that point, the user has write access to the target file. Versions after and including v0.11.0-3298-g2608e40988, and versions prior to v1.2.0-75109-g94f0312546 are vulnerable.

Weakness: CWE-59 (Improper Link Resolution Before File Access), CWE-264

## Which versions are affected by CVE-2021-27851?

It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `guix` | openSUSE:Tumbleweed | All versions | 1.3.0-1.8 |

Products: Gnu Guix.

## How do I fix CVE-2021-27851?

Upgrade to a fixed version.

## Is CVE-2021-27851 being exploited?

There is no known exploitation of CVE-2021-27851 in the wild and no public exploit code.

## Other vulnerabilities in GNU Guix guix-daemon

- [CVE-2019-18192](https://insights.sbomify.com/CVE-2019-18192/): Privilege escalation in n/a (high 7.8)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2021-27851 and fix it if it is affected.

What it is: CVE-2021-27851 is a medium-severity vulnerability in GNU Guix guix-daemon, published on 26 Apr 2021. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2021-27851 in the wild and no public exploit code.

Affected product: GNU Guix guix-daemon. No package-level version data is available, so check the vendor advisory linked from the reference page.

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2021-27851/ (Markdown: https://insights.sbomify.com/CVE-2021-27851/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2021-27851
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2021-27851
- OSV: https://osv.dev/vulnerability/CVE-2021-27851

---
From sbomify Insights: https://insights.sbomify.com/CVE-2021-27851/
Summaries are generated and may contain mistakes; the official description above is the record.
