CUPS webui (cups-webui) is designed as an unprivileged, local-only daemon and web management interface for macOS CUPS (127.0.0.1:6310). Because it runs locally and interacts with system printing utilities, it implements defense-in-depth security controls to protect the user against malicious websites, cross-origin web threats, and command injection.
Please report suspected security vulnerabilities privately through PaperCut's security contact page: https://www.papercut.com/contact/security/. Do not open a public GitHub issue for security problems.
Include the affected version or commit, steps to reproduce, and the impact you observed.
- Loopback Binding by Default: The HTTP server binds to
127.0.0.1by default and is intended to be used on the loopback interface only. Binding it to another interface with-hostis not a supported configuration. - DNS Rebinding Protection: Every incoming HTTP request must supply a valid loopback
Hostheader (127.0.0.1,localhost, or[::1]). Requests routed via external hostnames or DNS rebinding domains are terminated with400 Bad Request. - CSRF & Cross-Site Defense:
- Every API request (reads as well as
POST,PUT,DELETE) is checked against browser metadata (Sec-Fetch-Site). Requests a browser marks as coming from another site, or from anotherlocalhostport, are refused with403 Forbidden, so other web pages can't make the server run CUPS commands. Clients that don't send the header (curl, scripts) are handled by the token and connection-owner rules. - Origin headers must match the exact address the interface is served on (same host and port). Pages on other loopback ports are treated as cross-origin: they receive no CORS access and cannot obtain the session token.
- Every API request (reads as well as
- CORS Lockdown on Event Streams: Server-Sent Events (
/api/v1/events) do not permit wildcard or cross-origin access, preventing malicious third-party websites from eavesdropping on print jobs, document titles, or queue state.
- Cryptographic Session Tokens: A 128-bit session token is generated using
crypto/randand stored at~/.cups-webui/session.json. - Filesystem Permissions: The user configuration directory is restricted to
0700and the session credential file is restricted to0600(read/write by the user only). - Same-User Sign-In: The session is established automatically only for connections that originate from the same macOS user account that runs
cups-webui. Connections from other accounts or other hosts must already hold the session token, for both reading and changing data. - Constant-Time Verification: Session tokens are validated using
crypto/subtle.ConstantTimeCompareto mitigate timing side-channel attacks. - Protected Cookies: Direct browser navigations issue an
HttpOnly,SameSite=Strict,Path=/session cookie only when the navigation origin is verified. - Header-Gated Token Handshake: Session bootstrap endpoints require custom client headers (
X-Requested-With: CUPS-WebUI), which standard browsers prohibit cross-origin scripts from attaching without explicit CORS approval.
cups-webui acts as a management proxy over CUPS command-line utilities (lpadmin, lpstat, lpoptions, cancel, cupsctl). All subprocess invocations adhere to strict security boundaries:
- No Shell Interpolation: All commands execute via discrete
argvarrays directly throughos/exec(never through/bin/shor a shell interpreter). - Strict Parameter Whitelisting:
- Job IDs: Must be a number or
<printer>-<number>with a valid printer name, to prevent flag injection (e.g.cancel -aor-u root). - Printer Names: Enforced to the CUPS naming limits (1–127 characters; no spaces, control characters,
/,\,?, quotes or#), and may not start with-. The optional alphanumeric-only "Safe Queue Naming" in the Add Printer screen is a recommendation, not a server-side limit. - Device URIs: Whitelisted strictly to authorized network and hardware transport schemes (
ipp,ipps,http,https,socket,lpd,usb,smb,dnssd,mdns). Arbitrary schemes likefile://orexec://are prohibited; the one exception is the exact null devicefile:/dev/null(also accepted asfile:///dev/null), used for virtual queues that discard jobs. A URI may carry thepapercut:prefix that PaperCut print tracking adds to a queue; the address after the prefix must pass the same checks, so the prefix cannot be used to reach a blocked scheme or path. URIs must not start with a dash or contain control characters, percent-encoding must be well formed, and the value is passed tolpadminunchanged as a single argument (never URL-decoded or interpreted by a shell). - PPD Options: Option keys and values are sanitized to disallow leading dashes and command separators.
- Job IDs: Must be a number or
- Execution Timeouts: All external CLI processes run within a
context.WithTimeout(maximum 10 seconds) to prevent hung child processes.
- System Path Whitelisting: PPD file selection is restricted to recognized system driver locations (
/Library/Printers/,/System/Library/Printers/, the CUPS model directories under/usr/share,/usr/local/shareand/opt/homebrew/share, and/etc/cups/ppd/). Temporary and home-directory locations are rejected. - Directive Inspection: Uploaded PPD files are inspected to block known dangerous directives, including
*FoomaticRIPCommandLine(CVE-2024-47176), and to warn about filter paths outside the standard system locations.