Valhalla Legends Forums Archive | General Discussion | ln -s

AuthorMessageTime
iago
This is a question for a linux guy: (*coughthingcough*)

Can symbolic links be uploaded, or can a file be edited to make a symbolic link, like the way a windows shortcut can be?

I would think not, but I don't want people to be able to upload symlinks to my server :)

Thanks!
January 29, 2004, 4:54 PM
Yoni
A symbolic link isn't a file like .lnk in Windows. It's a file system element. It's a secondary entry in the file table that points to an already existing file.

So... No, I guess.
January 29, 2004, 5:30 PM
iago
[quote author=Yoni link=board=2;threadid=4986;start=0#msg41676 date=1075397451]
A symbolic link isn't a file like .lnk in Windows. It's a file system element. It's a secondary entry in the file table that points to an already existing file.

So... No, I guess.
[/quote]

Ok, good, that's what I thought. In the code I have here, they check it by doing an ls -l on an unchecked filename and check the first character. I just killed that function; I don't like people executing arbitrary code :)
January 29, 2004, 5:40 PM
Yoni
[quote author=iago link=board=2;threadid=4986;start=0#msg41679 date=1075398021]
In the code I have here, they check it by doing an ls -l on an unchecked filename and check the first character.
[/quote]
mv /bin/ls /bin/.ls
gcc evil.c -o /bin/ls
January 29, 2004, 6:27 PM
iago
[quote author=Yoni link=board=2;threadid=4986;start=0#msg41688 date=1075400849]
[quote author=iago link=board=2;threadid=4986;start=0#msg41679 date=1075398021]
In the code I have here, they check it by doing an ls -l on an unchecked filename and check the first character.
[/quote]
mv /bin/ls /bin/.ls
gcc evil.c -o /bin/ls

[/quote]

hmm, I would have just executed the command "myfile;ln -s /etc/passwd", then I could download passwd or whatever the actual password file is at my leasure. We tested this, and we can actually download passwd through a symbolic link like that :)
January 29, 2004, 6:44 PM
Kp
[quote author=iago link=board=2;threadid=4986;start=0#msg41689 date=1075401884]hmm, I would have just executed the command "myfile;ln -s /etc/passwd", then I could download passwd or whatever the actual password file is at my leasure. We tested this, and we can actually download passwd through a symbolic link like that :)[/quote]

Sounds like a really bad FTP server. Don't you even chroot? Also, if you're using shadow passwords, the risk is significantly reduced. If you are using chroot (and you really ought to be if you don't completely trust the clients, and maybe even then), you can supply a stripped down passwd file that only enumerates some users (unidentified users will show up by UID only), and even have bogus names (bogus relative to the "real" /etc/passwd).
January 29, 2004, 8:01 PM
iago
[quote author=Kp link=board=2;threadid=4986;start=0#msg41703 date=1075406484]
[quote author=iago link=board=2;threadid=4986;start=0#msg41689 date=1075401884]hmm, I would have just executed the command "myfile;ln -s /etc/passwd", then I could download passwd or whatever the actual password file is at my leasure. We tested this, and we can actually download passwd through a symbolic link like that :)[/quote]

Sounds like a really bad FTP server. Don't you even chroot? Also, if you're using shadow passwords, the risk is significantly reduced. If you are using chroot (and you really ought to be if you don't completely trust the clients, and maybe even then), you can supply a stripped down passwd file that only enumerates some users (unidentified users will show up by UID only), and even have bogus names (bogus relative to the "real" /etc/passwd).
[/quote]

For now, anyway, we only have 2 users, both have the root password, so that's not really an issue. Our password file is shadowed, too, there's no hashes in it.

I don't really know how chroot works, but I read about it before for running webservers.

The File Server is just that: a File Server. It doesn't have any important functions, and it can't give backdoor access to the rest of the network, so chroot'ing it would change nothing if they managed to get access.

And yeah, the filetransfer sucks. It's because it was written by students. We've spent all day adding error handling :)
January 29, 2004, 8:46 PM
Adron
[quote author=Yoni link=board=2;threadid=4986;start=0#msg41676 date=1075397451]
A symbolic link isn't a file like .lnk in Windows. It's a file system element. It's a secondary entry in the file table that points to an already existing file.

So... No, I guess.
[/quote]

I think you're confusing hard links and symbolic links. Symbolic links are more like .lnk files in Windows. They contain a path.
January 29, 2004, 11:04 PM
Yoni
Ok, yes, I probably confused them. But still, symbolic links aren't regular files like .lnk in Windows, they're marked by the file system as a link... Right?
January 29, 2004, 11:18 PM
Adron
Yes, symbolic links are special in the file system. I think they basically store the (relative or absolute) path of the target as the file contents, and have a special attribute indicating that this is a symbolic link.

You can't seem to create symbolic links on a network (samba) mounted ntfs partition.

The big difference between Windows' lnk files and symbolic links in linux is that all the file opening functions support following symbolic links natively. In Windows, you have to either use a special function to follow links, or parse them yourself.
January 29, 2004, 11:27 PM
Kp
[quote author=iago link=board=2;threadid=4986;start=0#msg41706 date=1075409209]I don't really know how chroot works, but I read about it before for running webservers.

The File Server is just that: a File Server. It doesn't have any important functions, and it can't give backdoor access to the rest of the network, so chroot'ing it would change nothing if they managed to get access.

And yeah, the filetransfer sucks. It's because it was written by students. We've spent all day adding error handling :)[/quote]

I can give you a basic overview of chroot; for each process, there is a concept of the root directory as part of the process information. Normally, that root directory really is the root directory -- i.e., it refers to / as the home. However, if an application uses chroot, it can change that base to refer to something else, such as /home/ftp. After the chroot call, the server could access /.cshrc to get the file that is really in /home/ftp/.cshrc. The attractive thing about this is that, if the chroot'd application then attempted to access ../../etc/passwd, it would successfully access in the following way:

/.. => /
/.. => /
/etc/passwd => etc/passwd

That is, each of the .. references would expand into / again, since you can never chdir above the root directory (even if it is a bogus root directory). Thus, even if an attacker convinced the server to upload files at a location of his choosing, it couldn't write or even read anything outside /home/ftp, regardless of permissions. This is the attraction of chroot -- a well designed chroot "sandbox" is almost entirely useless to an attacker even if he attains total control over the ftp server, since it locks itself into the sandbox before it even answers his connection. Afaik, once you have called chroot, there is no going back. Your descendents will inherit your root directory (which they could chroot to be even deeper, if they desired), and chroot to /../ will expand out to chroot /, which doesn't take you anywhere. :)
January 30, 2004, 9:34 PM
Adron
I'm pretty sure that as root you can chroot out. Also, handles open to things outside your current chroot jail are still accessible?
January 30, 2004, 11:00 PM

Search