LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-09-2002, 06:23 AM   #1
tundra
Member
 
Registered: Jun 2002
Location: Koom Valley
Distribution: rh8
Posts: 528

Rep: Reputation: 31
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?
 
Old 07-09-2002, 08:26 AM   #2
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
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
 
Old 07-09-2002, 09:24 AM   #3
Config
Member
 
Registered: Jan 2001
Location: Switzerland
Distribution: Gentoo
Posts: 376

Rep: Reputation: 30
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...
 
Old 07-11-2002, 09:29 AM   #4
tundra
Member
 
Registered: Jun 2002
Location: Koom Valley
Distribution: rh8
Posts: 528

Original Poster
Rep: Reputation: 31
thank you. that was useful.
 
Old 07-14-2002, 11:17 AM   #5
CARTMAN
Member
 
Registered: Feb 2002
Location: Turkiye
Distribution: Pardus
Posts: 147

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

Last edited by CARTMAN; 07-14-2002 at 11:18 AM.
 
Old 07-15-2002, 08:40 AM   #6
tundra
Member
 
Registered: Jun 2002
Location: Koom Valley
Distribution: rh8
Posts: 528

Original Poster
Rep: Reputation: 31
thanks. that was a good read, tho i don't know any asm
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help needed in security ,vonarabilities ,loopholes in linux security haseebnazar Linux - Security 2 11-23-2005 07:16 PM
Converting php5 socket functions to php3 socket functions mrobertson Programming 0 06-23-2005 09:11 AM
[Security Questions] Last Login, how good is this feature for security breach info? t3gah Linux - Security 2 06-14-2005 01:02 AM
todays requirements regarding security (not limited to linux security) markus1982 Linux - Security 8 04-25-2004 10:58 PM
pointers to functions/member functions champ Programming 2 03-28-2003 06:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration