Login | Sign up

May 30


0

Find files with setuid or setgid

Comments (0)

You should check to make sure there are no unneeded setuid and setgid files on your computer. They might be a potential security risk.

setuid and setgid permissions are very useful, however, they can be used to attack a system. Only files that absolutely need these permissions should have them set. There is an easy way to find all files on your computer that have these permissions set. You can then verify if these files need the permissions or not.

You can see our Intro to setuid and setgid if you are unsure what they are.

  1. find / -type f -perm /6000

The previous command will list all files on your computer that have either setuid or setgid set. Your system will have some files with these permissions that actually need them. You should review the list online to make sure any file that has the permissions needs them.

setuid/setgid on world writable files

You should never have any files that have either setuid or setgid set and are writable by other/world. An anonymous user could edit the file and execute it as the owner and essentially make the file do whatever he/she wants.

You can find files with these permissions with the following commands.

  1. find . -type f -perm /6000 -a -perm -0002

The previous command should not list any files. If it does, remove some permissions (either the world writable permission or both setuid and setgid) from the found files and investigate where they came from. It may very likely be a file that should not be on your computer.


Comments

There are no comments yet.


Post a new comment

Note: Items marked * are required fields

Post a comment

You must login before you can do that.

If you don't have an account, register for free. It's completely private.

Why register

  • rate posts and comments
  • ask questions about posts
  • request new topics/tutorials
  • mark posts as favorites to easily find them again