LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C functions - security? (https://www.linuxquestions.org/questions/programming-9/c-functions-security-25394/)

tundra 07-09-2002 06:23 AM

C functions - security?
 
which are the C functions that may result in a security compromise? i heard somewhere that scanf may be cause for buffer overflows?

where can i find a list of functions that shouldn't be used and which should be used?

llama_meme 07-09-2002 08:26 AM

Lots of C functions are potentially insecure. As a rule of thumb, if they do string processing or take a variable number of arguments (like printf and scanf), you have to be careful in their use. As an example, using printf like this to display a string entered by the user is insecure:

printf(users_string);

because a malicious user can put formatting directions in the string they enter (e.g. %s) and make printf expect further arguments after user_string, which will cause it to crash. In some cases, clever hackers are able to exploit this to run a small piece of assembly code, which if the C program is suid, can compromise the root account (for example, by opening a root shell).

Alex

Config 07-09-2002 09:24 AM

Quote:

Originally posted by llama_meme
Lots of C functions are potentially insecure. As a rule of thumb, if they do string processing or take a variable number of arguments (like printf and scanf), you have to be careful in their use. As an example, using printf like this to display a string entered by the user is insecure:

printf(users_string);

because a malicious user can put formatting directions in the string they enter (e.g. %s) and make printf expect further arguments after user_string, which will cause it to crash. In some cases, clever hackers are able to exploit this to run a small piece of assembly code, which if the C program is suid, can compromise the root account (for example, by opening a root shell).

Alex

HUCH! This is very clever. Must have been a bright guy who figured that... :eek:

tundra 07-11-2002 09:29 AM

thank you. that was useful.

CARTMAN 07-14-2002 11:17 AM

You may like this article http://www.neworder.box.sk/newsread.php?newsid=5333

tundra 07-15-2002 08:40 AM

thanks. that was a good read, tho i don't know any asm


All times are GMT -5. The time now is 07:08 AM.