Skip to content

makeBinaryWrapper: fix read past NUL - #541663

Merged
ncfavier merged 1 commit into
NixOS:stagingfrom
accelbread:binwrapper-fix
Aug 5, 2026
Merged

ncfavier merged 1 commit into
NixOS:stagingfrom
accelbread:binwrapper-fix

Conversation

@accelbread

@accelbread accelbread commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

This fixes a bug in makeBinaryWrapper which corrupts path-like environment variables when using the prefix option and the path had an existing duplicate element in the last element. In this case the nul byte is skipped and the value is overread (likely into the next element).

This bug causes issues as env vars intended values get concatenated with neighboring values.

On my system this causes Gstreamer directories to be appended onto GIO modules path. This causes every GIO application to dlload all gstreamer modules, creating a flood of error logs, and also running initialization code in each of those modules.

This was also interesting to debug as the env variables passed to the program look completely correct since they are corrupted by makeBinaryWrapper; observing what pam outputs or what gets passed to the program look correct. This allows manipulating path-like env vars such that they appear different to the application executing the program and the actual program under the wrapper.

I have updated the makeBinaryWrapper tests as needed as part of the change commit. I also added a new test for this case.

Things done

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. labels Jul 14, 2026
@LeSuisse LeSuisse added 1.severity: security Issues which raise a security issue, or PRs that fix one backport staging-26.05 Backport PR automatically labels Jul 14, 2026
@mweinelt
mweinelt requested a review from ncfavier July 22, 2026 11:46
@nixpkgs-ci nixpkgs-ci Bot removed the 9.needs: reviewer This PR currently has no reviewers requested and needs attention. label Jul 22, 2026
Comment thread pkgs/by-name/ma/makeBinaryWrapper/make-binary-wrapper.sh Outdated
Comment thread pkgs/test/make-binary-wrapper/combination/combination.c
@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 4, 2026
When setting a prefix for a path-like environment variable, the
deduplication code in set_env_prefix reads past the NUL byte at the end
of the env val and into the next entry. This corrupts the resultant env
value with data from the next env var, or other data sitting after it.
@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Aug 5, 2026
@accelbread
accelbread requested a review from ncfavier August 5, 2026 01:17
@ncfavier
ncfavier added this pull request to the merge queue Aug 5, 2026
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Aug 5, 2026
Merged via the queue into NixOS:staging with commit 247113d Aug 5, 2026
28 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Backport failed for staging-26.05, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin staging-26.05
git worktree add -d .worktree/backport-541663-to-staging-26.05 origin/staging-26.05
cd .worktree/backport-541663-to-staging-26.05
git switch --create backport-541663-to-staging-26.05
git cherry-pick -x d75cae80fa4ab7b5f6f39ddcbbbfbaa1a9183d81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.severity: security Issues which raise a security issue, or PRs that fix one 8.has: failed backport 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. backport staging-26.05 Backport PR automatically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants