I found this as a definition of setuid/setgid:
SUID and SGID
SUID and SGID programs can be double edged swords as whoever executes them gets the UID of the programs owner. If the program is owned by root, the user becomes root. They can be used to give a user access to something they would normally need root privilege for without giving them the root password. They can also be a serious security risk.
Shell scripts with SUID and SGID bits are not secure, period. This does not mean they should never be used. Rather this goes back to the larger issue of minimizing risk vs. eliminating it. Risk can be minimized by making sure that programs with SUID and SGID are not world readable. This can prevent people from studying the code, discovering how it works and exploiting its weaknesses.
The following command can be used to check for SUID programs owned by root:
Now the question:
If I understand this if root creates a file and give you write and execute on it, you could edit the file to make a script to do anything as root ?
What are vaid uses of setuid and are there better ways of doing this ?