News for hackers. Stuff that matters.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by jonathannerat on Monday April 18, 2022 @08:39PM (#31078535)
Is there any real use case of having filenames with newlines? Everytime I recall that we have to design programs around that I wonder why it's possible in the first place.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by kortex on Monday April 18, 2022 @10:28PM (#31079220)
The only invalid character in a path is \0 (which of course would terminate the string immediately), and a particular filename cannot contain /, or be "." or "..". Doesn't even have to be unicode. Literally any other bytes.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by dataflow on Monday April 18, 2022 @09:05PM (#31078703)
Linux even allows filenames with end-of-transmission characters in them, which is a choice I'd question long before I start questioning newlines!
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by gpvos on Monday April 18, 2022 @11:25PM (#31079483)
EOT or ctrl-D only has significance when typed into a tty. Once it has turned into a character it is as harmless as any other byte value, it doesn't end anything by itself.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by moring on Tuesday April 19, 2022 @02:31AM (#31080202)
Doesn't the article show that newline isn't harmless at all?

Of course EOT doesn't end anything by itself, nor does 0x0a end a line by itself -- all that happens through code that interprets those characters in a particular way, so talking about the "danger" of a character in absence of any code that operates on it is meaningless. In the presence of code, on the other hand, "harmless" in the extreme sense means "there exists no code that will act up when presented this character", which the article shows to be wrong.

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by dataflow on Monday April 18, 2022 @11:32PM (#31079520)
I'm aware, but it nevertheless doesn't make any sense to have it in a file name.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by gpvos on Tuesday April 19, 2022 @03:06AM (#31080376)
I'm just saying that it makes exactly as much sense as ctrl-E or any other control char, it has no special status.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by dataflow on Tuesday April 19, 2022 @03:12AM (#31080410)
There are quite a few ASCII control characters [1] that could make more sense than EOT, e.g., \t, \n, \e, etc.

But yes, EOT is not the only nonsensical character that you could put in a file name, and I never claimed such.

[1] https://en.wikipedia.org/wiki/Control_character#In_ASCII

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by unqueued on Tuesday April 19, 2022 @10:35AM (#31083714)
I think it is good that it is so flexible, because you never know what kind of data you may want represented on your filesystem. I would rather that there be as few restrictions as possible.

There are cases where you will encounter lots of nasty filenames, especially if you are handling user generated content, like scraping from YouTube or Instagram.

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by nightfly on Monday April 18, 2022 @10:28PM (#31079225)
Makes things like UTF8 and other new encodings easier. Everything has to support that nearly anything can be in a filename
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by Thorrez on Tuesday April 19, 2022 @04:23AM (#31080782)
It doesn't directly help UTF8, since all the bytes it uses for encoding non-ASCII have the high bit set.

It might directly help with UTF16, I'm not sure.

But the general idea of "block only a few specific characters (\0 and /) and allow all the rest" does help with UTF8. If the designers said something like "only ASCII letters and number and dashes and underscores" then that would block UTF8, and we might end up with something like URL hostnames, where you use punycode to encode non-ASCII into ASCII.

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by gpderetta on Tuesday April 19, 2022 @05:33AM (#31081147)
The point is that unix behaviour is to treat filenames as byte strings, so no particular encoding is mandated by the kernel or by most tools. That made the transition to utf-8 fairly painless.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by lupire on Tuesday April 19, 2022 @07:31AM (#31081766)
So it's easier to write insecure software. Wrong priorities.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by ElectricalUnion on Tuesday April 19, 2022 @09:58AM (#31083168)
> easier to write insecure software.

Not filtering untrusted inputs, and not escaping or handling them correctly is how you write insecure software. Arbitrary input guarantees (unless very strict, then that's indirectly filtering inputs anyways) don't change that.

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by Thorrez on Wednesday April 20, 2022 @03:35AM (#31093869)
Why does that make it easier to write insecure software? Which is easier: dealing with bytes, only 2 of which have special meanings (/ and \0) or dealing with a ton of different character classes, each of which you have to think about and code for. The second case happened with URLs, so there's all sorts of weird rules about you can have a ? in this section but not that section, and percent encoding and punycode and stuff like that.