Owning Internet Printing – A Case Study in Modern Software Exploitation
CUPS over-decremented the reference count of a globally shared string when freeing a multi-value localised attribute, allowing an attacker to prematurely free strings such as the ACL location paths. By freeing the '/admin' and '/admin/conf' location strings, the access-control lists stopped matching, so an unauthenticated user could upload a replacement cupsd.conf and run code.
googleprojectzero.blogspot.com
Published on googleprojectzero.blogspot.com
Modern exploit mitigations draw attackers into a game of diminishing marginal returns. With each additional mitigation added, a subset of software bugs become unexploitable, and others become difficult to exploit, requiring application or even bug-specific knowledge that cannot be reused.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the job-creation code freed the shared language string once per value of a multi-value attribute instead of once per attribute, over-decrementing a global reference count.
Impact
An unauthenticated attacker able to print could bypass the admin ACLs and run code, as root on Mac OS X Yosemite with cups-2.0.2 and as the lp user on Linux; the XSS lets this reach loopback-bound instances when a user browses the web interface.
What the attacker needed
Ability to send print jobs; web interface enabled (Linux default); victim browses the web interface (for XSS path)
How it was found
- Send an IPP create-job or print-job request with a multi-value job-originating-host-name attribute to over-decrement the target string's reference count.
- Let the freed block be reused so the dangling location pointers no longer match '/admin' and '/admin/conf'.
- Upload a replacement cupsd.conf through the now-unprotected admin configuration endpoint.
- Add a SetEnv directive pointing LD_PRELOAD (or DYLD_INSERT_LIBRARIES) at a library written to the spool directory.
- Seed the library file by sending POST requests and closing the connection before the body is complete.
- Trigger a CGI request so the library loads and code runs.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
CUPS is the printing software on many Linux and Mac machines. It keeps some text in one shared place and counts how many parts of the program are using it; when the count reaches zero the text is deleted. A bug let an attacker make that count drop too fast, so text still in use was deleted and replaced with other data, which broke the rules that decide who may change the printer settings.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.