Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.05] cups: fix socket-only usage after CVE-2024-35235 #337748

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

Yarny0
Copy link
Contributor

@Yarny0 Yarny0 commented Aug 27, 2024

Description of changes

With the patch for CVE-2024-35235, cups refuses to start if only domain sockets (Listen /path/to/unix.socket in cupsd.conf) are used. In NixOS, it can be triggered by setting services.printing.listenAddresses = []; (e.g. in the cups-pdf vm test).

The pull request at hand does two thing:

  • The patch file for the CVE is replaced by a fetchpatch that pulls the commit from the upstream repository. This does not change the resulting C code -- the patches only differ w.r.t. comments in the code.
  • Three more patches are added to cups, all fetched from upstream repository. The first two of these three patches are required so that the third one (the actual fixup) applies cleanly.

Reference: Upstream issue and fixup.

Notifying cups maintainer @matthewbauer and author of #330650 @risicle

The pull request at hand (like #330650) targets staging-24.05, as changing cups causes a mass rebuild.

The patches added here (like the patch from #330650) is already included in the cups version used on master branch, hence there is nothing to do for NixOS unstable.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • 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
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 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
  • Fits CONTRIBUTING.md.

Also:

  • Successfully built nixosTests.{printing-{service,socket},cups-pdf} on both commits of this pull request
  • Successfully built nixosTests.cups-pdf with services.printing.listenAddresses = []; added to the test configuration on the top-most commit of this pull request (the printing-* tests also check for port 631 and hence cannot be used to verify a socket-only configuration).

Add a 👍 reaction to pull requests you find important.

The patch from commit

NixOS@bdf63d7

is also available in the cups source repository
(up to some variations in code comments).
If cups is started with no network listeners,
i.e., only with `Listen /path/to/unix.socket`
lines in cupsd.conf, it fails to start.
This is caused by the patch of CVE-2024-35235, see also

NixOS@bdf63d7
NixOS@dfe9603

Upstream documented the problem here

OpenPrinting/cups#985

and fixed it here

OpenPrinting/cups#988 .

In NixOS, the problem manifests itself with this configuration:

> services.printing.listenAddresses = [];

The commit at hand adds three more
patches from the upstream repository.
This is the smalles possible change that
fixes the regression caused by the initial patch.
@risicle
Copy link
Contributor

risicle commented Aug 27, 2024

Huh for some reason I failed to find the commit on the 2.4.x branch.

Sounds like this would have been caught if the cups-pdf test were in cups' passthru.tests. Suggest adding it here (and of course on master) oh, fully read comment - but it's still probably worth adding it to passthru.tests

Copy link
Contributor

@risicle risicle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cherry-picked to release-24.05, built passthru.tests on nixos x86_64 & cups on macos 12 x86_64 successfully. Patches check out.

@Yarny0
Copy link
Contributor Author

Yarny0 commented Aug 28, 2024

Thanks, @risicle, for your fast reaction!

Sounds like this would have been caught if the cups-pdf test were in cups' passthru.tests. Suggest adding it here (and of course on master) oh, fully read comment - but it's still probably worth adding it to passthru.tests

How about this: We add cups-pdf to the passthru.tests of cups, and we expand the printing-* vm tests such that they also cover the case of listenAddresses = []. If you approve I can prepare a pull request for the master branch immediately.

@risicle
Copy link
Contributor

risicle commented Aug 28, 2024

I broadly approve, but I am of course not a cups/printing maintainer.

Anyway, I think this is merge-worthy as it is.

@risicle risicle merged commit 8454c79 into NixOS:staging-24.05 Aug 28, 2024
29 of 31 checks passed
@Yarny0 Yarny0 deleted the 2405-cups-fix-ondemand branch August 29, 2024 10:16
Yarny0 added a commit to Yarny0/nixpkgs that referenced this pull request Aug 29, 2024
Add two new vm tests for the printing configuration that
test `listenAddresses = []`, i.e., the situation where cups
only listens on the unix domain socket `/run/cups/cups.sock`.

This helps catching bugs like this:

OpenPrinting/cups#985
NixOS#337748

Note: It would probably be more readable to have a shorter
conditional code block and simply write

> f"lpstat ${pkgs.lib.optionalString listenTcp ''-h {server.name}:631''} -a"

But that would make the linter complain about a
superfluous f-string. in the case `listenTcp=false`.
Yarny0 added a commit to Yarny0/nixpkgs that referenced this pull request Aug 29, 2024
Add two new vm tests for the printing configuration that
test `listenAddresses = []`, i.e., the situation where cups
only listens on the unix domain socket `/run/cups/cups.sock`.

This helps catching bugs like this:

OpenPrinting/cups#985
NixOS#337748
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants