Live data from Hacker News

The trouble with symbolic links

lwn.net

91–100 of 126 posts

Re: The trouble with symbolic links

#91
post #88
post #85

Earlier quoted context omitted.

Stop defending poor coding and lack of skill. Everything you're saying is an excusory situation for hiring poor coders at minimum wage who can't or won't read documentation. This is 80IQ points South of frankly most of the conversations on here. Yes the rest of us cope with security incidents. There will always be security incidents. Stop defending practices that leads to them.

> Stop defending poor coding and lack of skill. This is a hopelessly elitist attitude. Also it is a useless one, over 1000 CVEs, yelling "be better at your job!" is just going to result in another 1000 CVEs. That is exactly what happened for decades with buggy C code, buffer overflows and use after frees, for a long time the refrain was "just do better!". Well millions of dollars of damages later, it turns out berati…

How is it hopelessly elitist to call out insecure code as being INSECURE!!!

My whole point is the same as yours fix it at the source. You seem to think hacking off the hands of some coders is safer (I may agree). But why not try to EDUCATE THEM?!?

Education costs 1000s of dollars at most rather than your hypothetical billion dollar APPLICATION LEVEL hack.

Why are you so elitist to assume people can't cope with these concepts?

My whole point is that they need to be tought they're running on a Unix server rather than an 1998 SD card. The rest of your complaining is either you don't understand this or are trying to excuse bad or insecure practice as acceptable. If this is your case. RUN THE CODE IN AN ENVIRONMENT WHERE THIS CAN'T HAPPEN. Seriously there are filesystems and options for this.

Calling for these features to be removed from extX, ZFS or other shows you don't understand storage technologies well enough.

Re: The trouble with symbolic links

#92
post #25

Earlier quoted context omitted.

Don't victim blame. Do you really think that using open(), stat(), lstat() (!), realpath(), mkdir(), rename() etc etc etc is a sign of a bad coder? The problem is that the APIs set you up for unexpected failure, and even some of the provided workarounds to 'safely' handle symlinks don't do it well enough. In the case of symlinks, I think it's fair to blame the tools rather than the workman.

API is always simplification and is not supposed to be used without understanding concepts and reality under the hood. Example: wanna show 1M POI in browser on some small territory. Openmaps/googlemaps API allows that, no prob. Looks good, yeah? Sorry, doesn't work. Because 1M is too large to show and browser gets stuck. The API do not prevent _all_ kinds of legshooting engineers invent.

Don't worry, they don't listen to speaking out against bigG or others for being bad

Re: The trouble with symbolic links

#93
post #38

I'm sorry symlinks are a thorn in Jeremy's side, but they are useful from a user's perspective. Hard links don't fill the same need. You can't normally hard link directories. If a file has multiple links, finding them all normally requires scanning the entire file system, so deleting a file now becomes harder. A file with multiple links doesn't have an obvious canonical path. As an example of all these issues, I mana…

symlinks are great, I don't see why we would remove such feature. The author pointed out a bunch of issues around atomic operations related to symlinks which in my view are valid. Similar TOCTOU race exists with PIDs, see https://lwn.net/Articles/773459/ Not sure whether the pid issue was ever resolved, havn't checked in on that in a while.

Symlinks are great from a "just make it work!" point of view but they're absolutely terrible from a "make it robust, sane and secure" point of view.

All of the points in the article are valid but there's even simpler stuff like the fact that you can't canonicalise paths (resolve ..) without reading the filesystem.

This should be required reading: https://9p.io/sys/doc/lexnames.html

Re: The trouble with symbolic links

#94
post #23
post #8

Earlier quoted context omitted.

Symlinks work as intended, but they cause a lot of unintended security vulnerabilities, i.e. they break lots of otherwise-functioning code. You can play with your words and redefine their meanings, but the vulnerabilities remain.

> they break lots of otherwise-functioning code. There is no otherwise! POSIX has symbolic links: if your software does not function with symbolic links, it does not function on POSIX.

Of course there is otherwise. Windows (more or less) doesn't have symlinks. Plan9 doesn't have symlinks. You don't have to have symlinks.

Can you not imagine anything other than POSIX?

Re: The trouble with symbolic links

#95
post #91
post #88

Earlier quoted context omitted.

> Stop defending poor coding and lack of skill. This is a hopelessly elitist attitude. Also it is a useless one, over 1000 CVEs, yelling "be better at your job!" is just going to result in another 1000 CVEs. That is exactly what happened for decades with buggy C code, buffer overflows and use after frees, for a long time the refrain was "just do better!". Well millions of dollars of damages later, it turns out berati…

How is it hopelessly elitist to call out insecure code as being INSECURE!!! My whole point is the same as yours fix it at the source. You seem to think hacking off the hands of some coders is safer (I may agree). But why not try to EDUCATE THEM?!? Education costs 1000s of dollars at most rather than your hypothetical billion dollar APPLICATION LEVEL hack. Why are you so elitist to assume people can't cope with these…

> How is it hopelessly elitist to call out insecure code as being INSECURE!!!

If a lot of code, written by a lot of different engineers, all ends up being insecure, it is worth asking, why is code dealing with this particular domain so often insecure?

> But why not try to EDUCATE THEM?!?

You can do that, and of course we should, but here is the thing about security:

The good guys have to write secure code every time, or else the attackers guys win.

Eternal vigilance is inhumanly hard to maintain. A better solution is to write higher level APIs or API wrappers that don't have these flaws.

> Why are you so elitist to assume people can't cope with these concepts?

Sure they can, but how many concepts can people cope with at once? Humans have a limit for how much they can juggle in their head. A huge part of software engineering is picking what abstraction layer to operate at. If I am writing code that deals with tons of string parsing and manipulation, I'd be a fool to write it in C or C++. Now I've done that when I needed the performance, but managing a massive number of strings in native code is easily 5x the work compared to using a GC language that also automatically tracks string length.

C is the wrong abstraction there. And indeed an obscene number of security holes have historically centered around string processing in C. That is because on top of managing all the business logic (which may be obscenely complicated by itself!) engineers now have to do so in a language that is really bad at dealing with strings and they have to do a lot of mental work to ensure the code is correct.

If I am manually flipping bits in hardware, well, JS can do it (I have seen it!) but honestly, that shouldn't be anyone's language of choice for directly interfacing with hardware.

(Doing that in C, really fun!)

> Calling for these features to be removed from extX, ZFS or other shows you don't understand storage technologies well enough.

I am not saying that. I am saying that the original POSIX APIs make writing secure code around symlinks hard, and I am saying that solely based on the fact that a bunch of security holes around POSIX APIs and symlinks exist!

This isn't some shocking statement. The original POSIX APIs make a lot of things hard.

Re: The trouble with symbolic links

#98

I was copying a file today and thought: "Why is it duplicating the data? Why does it not just create a new second filename pointer in the filesystem?"

Take a look at the cp man page -

https://www.man7.org/linux/man-pages/man1/cp.1.html

Look for "reflink" and you get your wish :)

Re: The trouble with symbolic links

#99
post #95
post #91

Earlier quoted context omitted.

How is it hopelessly elitist to call out insecure code as being INSECURE!!! My whole point is the same as yours fix it at the source. You seem to think hacking off the hands of some coders is safer (I may agree). But why not try to EDUCATE THEM?!? Education costs 1000s of dollars at most rather than your hypothetical billion dollar APPLICATION LEVEL hack. Why are you so elitist to assume people can't cope with these…

> How is it hopelessly elitist to call out insecure code as being INSECURE!!! If a lot of code, written by a lot of different engineers, all ends up being insecure, it is worth asking, why is code dealing with this particular domain so often insecure? > But why not try to EDUCATE THEM?!? You can do that, and of course we should, but here is the thing about security: The good guys have to write secure code every time,…

People being educated for a specialist job, I wonder how they will cope. Well we hire in enough others for less serious problems, sure why not hire less than competent people to slap a fixed badge on the side of it.

If you want this level of abstraction it should be built into the framework or language you're using. I'm not saying go away and rewrite chrome in C you'd be chasing segfaults for 5 years.

If you want to hire people who don't care again. Run this in an environment where this doesn't matter. If you're ultra paranoid insist in a layer to compensate for people's failings.

Again there is nothing wrong with the tried and tested API that can't be fixed with a modicum of effort. Calling it broken or insisting it change to fit problems caused by people so far removed they don't know what architecture they're working code for is not a reason to change the POSIX system. It's a reason to fix your abstraction.

Re: The trouble with symbolic links

#100
post #36

Earlier quoted context omitted.

In the modern world, the demand seems to be that every tool be perfectly safe in every situation no matter what you do (and it seems practically nothing lives up to this demand, given the ever increasing river of silly CVEs for almost every component, like regex DoS on build tools). It's important to understand the scope of the issue. If you create and operate on your own symlinks in your own folders, there is no pro…

I appreciate the reply, but after thinking about it I think it's more akin to someone having been sold a house only to be told eight years later that the seller of the house knew that if someone tied a shoelace to the front door and pulled on it, then the entire house would explode. Could we consider it a broken doorknob Pierce?

It's more akin to pulling the shoelace, and the door closes on your fingers. Oh no, doors are unsafe, how utterly broken.

Or, more like, if there's an attacker hiding in your house, while you're setting up the shoelace door thing for some odd reason, they could slam the door on your fingers. Oh no, how were we ever allowed to have doors, so criminally unsafe.

Post reply on HN