LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 03-22-2018, 04:28 PM   #1
sreeharsha1988
LQ Newbie
 
Registered: Apr 2014
Posts: 19

Rep: Reputation: Disabled
Exploiting race conditions in privileged programs


I am looking at a 2008 academic test paper from a university on secure computing. I could not think of any solution to on particular question.

*******************************************************************
Basically a user has a file in a directory and there is another directory nested inside which is owned by root. The nested directory has a file which is owned by root and user cant access it.

There is a root program which user can invoke which basically checking the permission on user file and creates a symbolic link to it for a few moments and deletes it after use.

This program has a flaw and user has found a way to access the secret file. what could be wrong?
*******************************************************************

Clearly the root program has a race condition vulnerability but how can a user actually exploit it to gain access to root file? This is what is puzzling me. I am attaching the screen shot of the complete question.

Any suggestions would help.
Attached Thumbnails
Click image for larger version

Name:	question.png
Views:	42
Size:	127.8 KB
ID:	27252  
 
Old 03-22-2018, 07:47 PM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
If it is a symbolic link, versus a hard link, I don't see how the root-owned file would be made accessible ...
 
Old 03-22-2018, 08:33 PM   #3
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,784

Rep: Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214Reputation: 2214
Even a hard link could not work. The access permissions are part of the file's inode, and are independent of how that inode is reached. A hard link could work around directory permissions, but not file permissions. A symbolic link can do neither.
 
Old 03-22-2018, 09:27 PM   #4
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,382

Rep: Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761
Gotta luv the web! http://www.cis.syr.edu/~wedu/Teachin..._Condition.pdf
 
Old 03-23-2018, 12:03 AM   #5
sreeharsha1988
LQ Newbie
 
Registered: Apr 2014
Posts: 19

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by allend View Post
Yes I have gone through this. It exploits the race condition and symbolic links to write to an inaccessible file because the root program which is running is writing to the file and it can be tricked to redirect its input to some other file but in this case the root program is merely creating a symbolic link not opening the file.

The most an attacker could do is to create a symbolic link of file in folder C to imitate his image file apart from that nothing. So how can he gian access to the secret file?
 
Old 03-23-2018, 02:52 AM   #6
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,382

Rep: Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761
As directory B has 755 permissions, the attacker can exploit the race condition by creating a symlink named "funny.jpeg" to the "secret_records" file.
 
Old 03-23-2018, 03:26 AM   #7
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,786

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
So the program checks if "the user can view the file" by writing to the file? That doesn't seem like a plausible error. I mean, even in normal non-attacker scenarios wouldn't that cause obvious problems? Maybe that is the intended answer, but IMO it doesn't make much sense.
 
Old 03-23-2018, 03:55 AM   #8
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,382

Rep: Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761Reputation: 2761
An alternative presentation with more ideas on potential exploitation techniques. https://www.cs.utexas.edu/~shmat/cou...ou-porter.pptx
 
Old 03-23-2018, 07:24 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,691
Blog Entries: 4

Rep: Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947Reputation: 3947
A symbolic link is "a tiny file containing a file name." It is resolved as a filename – effectively, the symlink is shorthand.
 
  


Reply

Tags
security



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
Prevent race conditions in SSH, PERL aarontwc Programming 9 12-04-2008 12:51 AM
LXer: Exploiting the Linux Kernel LXer Syndicated Linux News 0 08-16-2007 10:21 AM
Race conditions in 2.4 between tasklet and sys.call yyanovsk Linux - Kernel 4 10-05-2006 11:33 AM
how do i stop potintal user abuseie exploiting and scanning? f1uke Linux - Security 7 10-21-2003 07:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01:07 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