LWN.net Logo

Potential pitfalls in DNS handling

Potential pitfalls in DNS handling

Posted Nov 15, 2012 14:44 UTC (Thu) by rvfh (subscriber, #31018)
Parent article: Potential pitfalls in DNS handling

It is worth noting that file names in UNIX can also have any characters except NULL and /. I had the bad surprise to find out that some users can be very creative with file naming, and misbehaving programs even more so, before I realised this.


(Log in to post comments)

Potential pitfalls in DNS handling

Posted Nov 15, 2012 21:29 UTC (Thu) by wahern (subscriber, #37304) [Link]

I once found a hacker on a large university system who kept a setuid binary in / for his backdoor, except the name had escaping sequences which kept it hidden from the typical shell listing. I found it when poking around, like inquisitive users do. I had compiled zshell, which unlike the default, proprietary shell on the system let me see and manipulate those names. I was giddy when I executed it and was dropped into a root shell.

I notified the sysadmin, who was incredulous at first. Later I found out that the hacker had penetrated many more systems, including many Bell Atlantic servers. Never did find out how he broke in, though in those days there was lots of low hanging fruit to exploit.

Potential pitfalls in DNS handling

Posted Nov 16, 2012 12:25 UTC (Fri) by cate (subscriber, #1359) [Link]

Not really. You can eventually have "/" in a filename: "/" has a value defined in localedef, thus you can define a private locale, create a file containing the ascii value of "/", and returning to a normal locale.

It is allowed by POSIX (but without specifying what a POSIX program should behave when it encounters such file), but I never tested.

'/' in filename? Really?

Posted Nov 17, 2012 2:35 UTC (Sat) by pr1268 (subscriber, #24648) [Link]

Really...? Any online examples of this?

I'm sincerely curious as to how I could overcome the inability to create a directory named "AC/DC" in my music files directory (where each subdirectory is named after the artist/band whose song files are stored within).

Back to the article, I feel somewhat re-assured that the various DNS library implementations would appear to fail given strange input that the RFCs seem to allow. And besides, those are relatively low-numbered RFCs; surely they've been around a while to shake out the bugs. </slightly ignorant observation>

Thanks to Phil Pennock and the Exim developers looking into this.

'/' in filename? Really?

Posted Nov 17, 2012 11:47 UTC (Sat) by hummassa (subscriber, #307) [Link]

Use the codepoint 0x2215 And be happy...

Potential pitfalls in DNS handling

Posted Nov 16, 2012 18:34 UTC (Fri) by quotemstr (subscriber, #45331) [Link]

> file names in UNIX can also have any characters

And I maintain that's a bug. Kernels should be doing:

* UTF-8 normalization
* Leading and trailing space elimination
* Banning leading dashes
* Banning non-printable unicode characters

There's absolutely no reason for treating filenames as opaque strings, except that by doing so, you avoid having arguments about encodings. Now that UTF-8 has won, we should revisit that decision.

Potential pitfalls in DNS handling

Posted Nov 17, 2012 1:39 UTC (Sat) by anselm (subscriber, #2796) [Link]

UTF-8 normalisation probably makes sense, but disallowing leading dashes in filenames would disable potentially desirable features like being able to create a file called »-i« in a directory where you don't want to accidentally have »rm *« delete all your files.

Potential pitfalls in DNS handling

Posted Nov 17, 2012 2:13 UTC (Sat) by apoelstra (subscriber, #75205) [Link]

> UTF-8 normalisation probably makes sense, but disallowing leading dashes in filenames would disable potentially desirable features like being able to create a file called »-i« in a directory where you don't want to accidentally have »rm *« delete all your files.

Nor would it allow creating "-r" in directories where you want rm to be extra destructive. :)

Potential pitfalls in DNS handling

Posted Nov 17, 2012 15:13 UTC (Sat) by Jandar (subscriber, #85683) [Link]

It is not the kernels job to judge the userspace character-encodings or other aspects of filenames. If we follow this path would more than one dot legal, why ban only leading and trailing spaces? And think of the children, disallow NSFW words in filenames or file-content ;-).

Potential pitfalls in DNS handling

Posted Nov 19, 2012 10:51 UTC (Mon) by cesarb (subscriber, #6266) [Link]

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds