187 points · by whiteyford · 6y ago · 44 comments
It's well written and easy to follow even for someone that doesn't know much about Windows security.
And if you didn't read it the bug comes from the fact that the Powershell command Add-PrinterPort can be used to add a printer port as a file that you don't have access to. After restarting the spooler service you can then use this port to write to that file.
> the bug comes from the fact that the Powershell command Add-PrinterPort can be used ...
The bug is in the print spooler service and the Windows API to access to it. It just happens that PowerShell offers an easy way to access the Windows API, which makes it easy to illustrate the exploit.
If so, seems like you could use it to break out of VMs/RDP servers.
For those not interested in the whole narrative, it's still interesting to browse one or two chapters of interest.
https://www.amazon.com/Countdown-Zero-Day-Stuxnet-Digital/dp...
Can anyone recommend similar audiobooks on tech that are not as well known?
I'm not too familar with what it does exactly. But I presume it's a queue of documents to send to a printer and some level of conversation of the data from a print document format to what the printer driver understands.
This seems like quite a crazy bug. Also today, a lot of home printers are network printers so it shouldn't even require higher privilages to send the document to the printer, right?
Or is printing in Windows a huge can of worms like its use of UTF-16?
But most OS printing services cover both network and local (USB, parallel, even serial!) printing, and therefore the print daemon needs to essentially "own" ACLs on some collection of USB-devices and even "own" direct bit-banging access to a set of serial/parallel-ports, in the same sense that X11 gets to own VRAM memory-regions, or an audio daemon gets to own bit-banging access to a set of DAC controllers.
Coupled with this is the problem of supporting legacy software that expects older consumer-microcomputer OS paradigms for device access. This isn't so much of a problem on POSIX systems, where the oldest paradigm (having /var/spool as a sticky dir, where roff(1) would just write files there) was already multitenant-friendly; you just need a print daemon (CUPS) that can watch /var/spool for changes, along with its non-legacy API. I believe you can roff(1) even within Termux on Android, and it'll "just work", without special kernel support other than the generic filesystem notification-event API.
But Windows specifically inherits a print-system design all the way from DOS, and still supports software (e.g. Win9x software written for the Win32 API) that was written to expect that legacy API. I don't know too much about the Win32 print API specifically, but I'd guess that it was designed to be a forward-compatible shim on top of the DOS printing "API"—which was really just allowing the application to bang bits down the serial/parallel port through memory-mapped IO.
That's what the "LPT1", "COM", etc. devices in Windows are: emulations of those same legacy memory-mapped IO channels that only make sense to access in a single-tasking OS. But, as of NT/W2K, it's actually the OS on the other end of that pipe, arbitrating data flows. So that's another thing that needs to happen in kernel-land in Windows: the emulation of an unprotected MMIO memory region within the process's address space, as a glorified syscall ABI, which just (these days) routes messages to the userspace print daemon, but back in Win9x probably did do all its work in kernelspace.
LPT1/COM are not emulations of unprotected memory-mapped IO channels. They're DOS device names, inherited more or less from CP/M, and DOS itself would call a routine to I/O to a device instead of a file if the special device names were used. A DOS program didn't need to bitbang the UART or parallel port registers to print things, though some did I'm sure.
The Windows print spooler does not need to access I/O ports directly, it can simply open up a device and doesn't need kernel-level privileges to do it. (It may very well be actually doing that for some godawful reason but it doesn't need to).
What the Windows print spooler does is allow distribution and even installation I believe of print drivers - and that's why it needs kernel-level access and support of that hardware is why the Windows spooler architecture won't change. Something is going on because you can't delete print drivers in Windows with the spooler service running.
This is part of Microsoft trying to make network printers plug and play. Tbf it's working OKish these days, a lot of times you can connect a printer and it's recognized or installed by Windows automatically, though you still need to install your scanner utilities for AIO devices.
I suspect most people would be fine using that version of Windows, and it would have less security problems.
Everything works with Windows. I can run Linux software on Windows. I can run run greenfield web applications on Windows (the new Edge is being built for this purpose, but even Chrome for Windows was satisfactory, as long as it's easy to install). I can run old web applications on Windows. I can run old win32 applications on Windows, even stuff using emulated 16-bit APIs.
About the only thing you can't run on Windows is XCode. I wonder how big of a bribe Microsoft has tried to propose to Apple to get XCode for Windows, because developing iPhone applications is an enormous gap in Microsoft's moat.
The locked-down RT tablets were a horrible blot on an otherwise great brand. "Everything works with Windows" is a terrific selling point.
People say that a lot, but it has a very specific meaning when talking about a platform SDK: "backward compatibility" here specifically means that if you wrote version N of your software for version N of Windows, then when you're writing version N+1 of your software targeting version N+1 of Windows, you don't need to re-write any of the old code. You can just start taking advantage of the new Windows API features in the new code you write, while leaving your old code that calls legacy Windows APIs alone.
Almost all large Windows applications are written this way: a gradual sedimentary accretion of calls to whatever Windows APIs were modern at the time of writing. Even first-party software like Office still makes calls to kernel-shimmed 16-bit APIs, right alongside calls to the modern UWP APIs.
But nevertheless:
> Why don't we have a version of Windows without as much legacy support? Like a security hardened (or really just modern-only) version of Windows?
We did get this; it was called Windows RT, which could only run software (re)developed specifically for the WinRT platform SDK.
WinRT applications are automatically sandboxed; are able to be developed in many languages, including Rust and Javascript; and, while being native code (when you use a compiled language), are also architecture-agnostic—meaning mostly that you can easily build one deliverable for the Windows Store that contains binaries for x86, ARM, and any other arch Windows Store supports, and then by downloading your app people will transparently be downloading whichever sub-package their device needs.
But, well, few developers bothered, because most major pieces of software would need to be majorly rewritten to support WinRT. It was mostly used for greenfield projects by existing companies; or as a target for new Windows porting efforts (e.g. of iOS/Android software.)
Originally the incentive for using WinRT was supposed to be that only WinRT apps could be sold through the Windows Store; but since so few third-parties bit this bullet, Microsoft backed off and allowed all their biggest bigcorp partners—exactly the people they were really trying to convince—to just submit non-WinRT apps to the store. As of that moment, WinRT-the-SDK was dead in the water; basically no large project has been rewritten for it since then.
If you don't want to run programs, you could get a Chromebook.
For business uses though, that backwards compatibility is absolutely key. From my work in IT I've seen countless applications originally developed for much older versions of windows, where the developer is no longer releasing updates or has even gone out of business altogether.
Yet some important part of the business still runs on that software for some reason, so it needs to work. This is where backwards compatibility in Windows is a huge strength.
The average home user probably can do without such legacy features (other than maybe playing old games which may rely on them), but for businesses its pretty important
Microsoft makes a ton of money selling the exact opposite.
There is an edition of Windows called "POSReady" that is used in Point of Sale, ATMs, and other embedded devices. Microsoft guarentees drivers won't change, no patches will be issued, and almost all security controls are disabled. If you build on top of it, the underlying OS will never change.
So we have plenty of versions of Windows like that, but they are not doing very well in market share so far. It turns out it's hard to get everything people want to keep working on such a version.
Longer analysis: https://windows-internals.com/printdemon-cve-2020-1048/
The core is:
a) you can set up a printer port that prints to a file
b) no admin privilege is required to do this, just a check on the ownership of the file
c) the ownership check is in the wrong place, so you can just create a port that prints to a DLL in system32
d) a second export forces Windows to load that DLL and run a specific function as SYSTEM, at which point game over
https://www.quora.com/What-is-the-most-sophisticated-piece-o...
Almost certainly an NSA product.
Siemens engineers deployed a PCS 7 lab environment at the Idaho National Laboratory, where research in to exploits was conducted. Coincidently one of the methods Stuxnet used to stay hidden was demonstrated at the KEMA Control Systems Conference in Idaho Falls.
Separately, Siemens engineers built a replica of the Iranian system at Shimon Peres Negev Nuclear Research Center in Israel using P-1 centrifuges the US obtained from Libya's nuclear program.
Definitely don't take that as fact though :)
I found it to be a fascinating account of international cyber attacks with a clear, well-argued thesis.
https://www.amazon.com/Hacker-State-Attacks-Normal-Geopoliti...
https://en.wikipedia.org/wiki/Stuxnet
It would be very interesting to see the next Stuxnet class viruses, sponsored by major companies/countries. I'm fairly sure there are some already running in the wild.
From the article: "The [researchers] also said that they had found and disclosed some other bugs in the same are that have not yet been patched “so there’s definitely still some dragons hiding.”"