News for hackers. Stuff that matters.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by TheDong on Monday April 18, 2022 @05:01PM (#31076498)
The commit fixing this bug is here: https://git.savannah.gnu.org/cgit/gzip.git/commit/?id=dc9740...

while grep is written in C, zgrep is written in posix sh, and the bug was from using sed to escape arguments, and sed being a line-oriented utility that is non-ideal for operating on newline-containing strings (i.e. linux filenames).

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by foota on Monday April 18, 2022 @06:27PM (#31077445)
The thought of writing anything in sh is horrifying to me.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by djbusby on Monday April 18, 2022 @07:46PM (#31078184)
Check out GNU pass

It's like all sh

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by 0xdeadb00f on Monday April 18, 2022 @08:22PM (#31078419)
I didn't know pass was "GNU". I also recall it being pretty well written.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by guns on Monday April 18, 2022 @10:02PM (#31079089)
Original author of password-store was Jason Donenfeld (of Wireguard fame), and it was indeed well-written.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by 0xdeadb00f on Monday April 18, 2022 @10:05PM (#31079105)
Yes! Actually I remember now being surprised to find out Jason had written it. His git repository is full of neat and interesting projects.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by loudmax on Tuesday April 19, 2022 @08:42AM (#31082318)
Pass is a wrapper script around git and gpg. You can get the functionality of `pass` by running git and gpg commands directly.

Learning git itself is non-intuitive, but the gpg utilities take the learning curve to a whole other level. If you want to make simple use of the gpg utilities, you should plan on setting aside a few full days to learn how they work. Or just use pass, which additionally leverages git for password history.

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by scbrg on Tuesday April 19, 2022 @09:06AM (#31082556)
bash, actually.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by nikonyrh on Monday April 18, 2022 @06:11PM (#31077288)
This reminds me that filenames can contain newlines.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by 10000truths on Tuesday April 19, 2022 @04:02AM (#31080655)
They can contain any octet except ASCII NUL and /.

That said, pretty much every filesystem's on-disk format has an explicit length field for file names. So in theory, there's nothing stopping them from supporting completely binary filenames - it's the kernel's VFS layer that treats NUL and / as special.

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by tomrod on Monday April 18, 2022 @11:01PM (#31079381)
D:
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by guipsp on Tuesday April 19, 2022 @01:52AM (#31080061)
And nulls :)
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by hddqsb on Tuesday April 19, 2022 @02:01AM (#31080091)
How exactly can they contain nulls?

fopen() takes a null-terminated filename, so if there is a null byte in the middle it would just truncate the filename.

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by minusf on Tuesday April 19, 2022 @02:32AM (#31080208)
that might be a corrupt filename that can be opened only by its inode in debugfs or similar.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by teddyh on Tuesday April 19, 2022 @02:43AM (#31080264)
No they can’t.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by bee_rider on Monday April 18, 2022 @06:55PM (#31077719)
Well, this seems like the sort of error that we've all made when throwing together our own personal scripts, so I guess it is somewhat heartening that the serious Redhat folks would make it too.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by formerly_proven on Tuesday April 19, 2022 @03:17AM (#31080423)
It always seemed very strange to me that there is no way to generate escaped representations in sh/bash, because you do need that from time to time.
Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by phh on Tuesday April 19, 2022 @03:41AM (#31080544)
There is printf %q, a bashism I think

Sample usage to escape var called v v="$(printf '%q' "$v")"

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by unqueued on Tuesday April 19, 2022 @10:22AM (#31083533)
This is called ANSI-C quoting[1], and I am surprised it is not more popular, because I think it provides a good compromise with readability and power.

I used it myself when I wrote a script that generates a self executing bash script to restore mtimes for directories[2]

[1]: https://www.gnu.org/software/bash/manual/bash.html#ANSI_002d...

[2]: https://github.com/unqueued/storetouch

Re:Arbitrary file write vulnerability in GNU gzip's zgrep ut... by formerly_proven on Tuesday April 19, 2022 @08:06AM (#31082013)
Thanks!