Re: Secure access to system calls for a library?

Casper Dik <[email protected]> Fri, 11 Jun 2004 12:53:51 +0200
Newsgroups gmane.comp.security.programming
Message-ID <[email protected]>
>How can a library ensure that when it calls getuid(), it really calls the 
>system call and not a dummy provided by the application that is using the 
>library?

You can't.

Perhaps you can explain to us why the library is checking the user id?

>On Solaris, you can defer the pain marginally by calling _getuid() 
>instead, but the user can define that too, and you could defer the pain 
>one step more by calling __getuid(), but the user can define that as well, 
>and then you're hosed.

Or you can write an automated tracer using /proc or PTRACE which changes
the system call return value to something else.

>AFAICS, the only reliable way for the library to know that it is really 
>calling the system call is for it to embed the assembler code for the 
>system call into its code, under its own name, and to use that name 
>everywhere.  I'm hoping, desparately, that this is wrong.

And then a user can still make the call return a different value with
the help of an automated tool.

Casper