- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Problem with SUID bit in executable
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2010 02:51 AM
тАО11-04-2010 02:51 AM
I have the following problem.
../bin/memdbkey and ../bin/memdbkey2 are identical executables. The only different thing is permissions: ../bin/memdbkey2 has SIUD bit.
User-1: owner of the executables
hpx418> uname -a
HP-UX hpx418 B.11.23 U ia64 1139467043 unlimited-user license
hpx418> pwd
/devjuser/jp/ccjp/avinokur/proj/gadj750_CNV64/ut
hpx418> id
uid=75308(avinokur) gid=479(pm)
hpx418> ls -l ../bin/memdbkey*
-rwxr-xr-x 1 avinokur pm 2037608 Nov 4 11:15 ../bin/memdbkey*
-rwsr-sr-x 1 avinokur pm 2037608 Nov 4 12:17 ../bin/memdbkey2*
hpx418> ../bin/memdbkey
// Works fine
hpx418> ../bin/memdbkey2
// Works fine
Unber-2: Another user
hpx418> uname -a
HP-UX hpx418 B.11.23 U ia64 1139467043 unlimited-user license
hpx418> pwd
/devjuser/jp/ccjp/avinokur/proj/gadj750_CNV64/ut
hpx418> id
uid=204925(monitor) gid=20(users)
hpx418> ls -l ../bin/memdbkey*
-rwxr-xr-x 1 avinokur pm 2037608 Nov 4 11:15 ../bin/memdbkey*
-rwsr-sr-x 1 avinokur pm 2037608 Nov 4 12:17 ../bin/memdbkey2*
hpx418> ../bin/memdbkey
// Works fine
hpx418> ../bin/memdbkey2
/usr/lib/hpux64/dld.so: Unable to find library 'libicuuc.sl.34'.
Killed
Regards
Alex Vinokur
Solved! Go to Solution.
- Tags:
- SUID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2010 03:23 AM
тАО11-04-2010 03:23 AM
Re: Problem with SUID bit in executable
convenient form for everyone. (What's in it
besides plain text?)
> /usr/lib/hpux64/dld.so: Unable to find library 'libicuuc.sl.34'.
Ok. So where's "libicuuc.sl.34", and who
owns it, and what are its permissions
("ls -l")?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2010 03:51 AM
тАО11-04-2010 03:51 AM
Re: Problem with SUID bit in executable
My Word-attachment holds the same information as plain text.
=========================================================
> id
uid=75308(avinokur) gid=479(pm)
> ldd ../bin/memdbkey2 | & tee log
...
> grep libicuuc log
libicuuc.sl.34 => /usr/local64/xerces-c2_6_0_icu_64b//lib/libicuuc.sl.34
> ls -l /usr/local64/xerces-c2_6_0_icu_64b//lib/libicuuc.sl.34
lrwxr-xr-x 1 root sys 16 Feb 20 2007 /usr/local64/xerces-c2_6_0_icu_64b//lib/libicuuc.sl.34@ -> libicuuc.sl.34.0
> env | grep "/usr/local64/xerces-c2_6_0_icu_64b//lib"
SHLIB_PATH= ...
LD_LIBRARY_PATH= ...
=========================================================
> id
uid=204925(monitor) gid=20(users)
> ldd ../bin/memdbkey2 | & tee ~/log2
...
> grep libicuuc ~/log2
Unable to find library 'libicuuc.sl.34'.
> ls -l /usr/local64/xerces-c2_6_0_icu_64b//lib/libicuuc.sl.34
lrwxr-xr-x 1 root sys 16 Feb 20 2007 /usr/local64/xerces-c2_6_0_icu_64b//lib/libicuuc.sl.34@ -> libicuuc.sl.34.0
> env | grep "/usr/local64/xerces-c2_6_0_icu_64b//lib"
SHLIB_PATH= ...
LD_LIBRARY_PATH= ...
---------------
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2010 04:09 AM
тАО11-04-2010 04:09 AM
Re: Problem with SUID bit in executable
lrwxr-xr-x 1 root sys 16 Feb 20 2007 /usr/local64/xerces-c2_6_0_icu_64b//lib/libicuuc.sl.34@ -> libicuuc.sl.34.0
Ok. That's a link to something. Now what
about the link target, "libicuuc.sl.34.0"?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2010 04:13 AM
тАО11-04-2010 04:13 AM
Re: Problem with SUID bit in executable
4.0
-rwxr-xr-x 1 root sys 4078304 Dec 11 2006 /usr/local64/xerces-c2_6_0_icu_64b//lib/libicuuc.sl.34.0*
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2010 09:17 PM
тАО11-04-2010 09:17 PM
SolutionSHLIB_PATH= ...
LD_LIBRARY_PATH= ...
As mentioned in your comp.sys.hp.hpux newsgroup post, it is important to know that the security police force dld to ignore the setting of those environment variables.
If you want those paths to be honored, you must follow the directions in dld.so(5) and edit /etc/dld.sl.conf.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2010 11:42 PM
тАО11-06-2010 11:42 PM
Re: Problem with SUID bit in executable
hpx418> uname -a
HP-UX hpx418 B.11.23 U ia64 1139467043 unlimited-user license
hpx418> more /etc/dld.sl.conf
/etc/dld.sl.conf: No such file or directory
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-06-2010 11:58 PM
тАО11-06-2010 11:58 PM
Re: Problem with SUID bit in executable
Is this approach correct?
> cp /usr/bin/chmod myChmod
> chmod 4555 myChmod
> ls -ld myChmod
-r-sr-xr-x 1 avinokur pm 52388 Nov 7 08:41 myChmod
Now,
> id
uid=204925(monitor) gid=20(users)
> ls -ld myDir
dr-------- 2 avinokur pm 96 Nov 7 08:42 myDir/
> chmod 777 myDir
chmod: can't change myDir: Not owner
> myChmod 777 myDir
> ls -ld myDir
drwxrwxrwx 2 avinokur pm 96 Nov 7 08:42 myDir/
====================================
Now, I would like to do something like (for any user)
int main ()
{
...
system ("./myChmod 0777 ./myDir/);
...
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2010 03:46 AM
тАО11-07-2010 03:46 AM
Re: Problem with SUID bit in executable
> Actually, the only thing I need is to give another process to change mode of some directory.
Then you need to create an executable that is owned by 'root' and has its setuid set. You don't need the setgid bit, though. The permissions will look like:
-r-sr-xr-x 1 root sys
That is, 4555
Instead of calling 'system(3S)' in your executable, simply call 'chmod(2)' to do the work.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-07-2010 04:00 AM
тАО11-07-2010 04:00 AM
Re: Problem with SUID bit in executable
If at all possible, you should avoid setting up setuid-root programs. Perhaps you could create a group, add the users of your application to that group and then make myDir writable by that group only?
But if you absolutely must have your program change the permissions on a directory it does not own, make a small program "chmodMydir" and make it setuid root.
You should design to be as secure as possible, and to do exactly one thing and nothing else: to change the permissions of the specific directory your application needs.
The chmodMydir program should open() the desired directory for reading, then _while holding the opened file descriptor_, it should use fstat() to verify the real name of the directory and that it really is the directory your application needs, not something nasty like a symbolic link to a critical system directory.
If the directory passes the checks, use the fchmod() function on the file descriptor to change the permissions directly within your program.
(The purpose of holding the file descriptor while making the checks is to protect your chmodMydir from race conditions. A malicious user might make chmodMydir run on a symbolic link, then change where the link is pointing to while chmodMydir is running. Holding the file descriptor ensures both the checks and the fchmod() will be operating on the same object, no matter what happens in between.)
The chmodMydir program should check the return code of all the system calls it makes. If there is an error, it should output a descriptive error message (perhaps using perror() or strerror(errno)), and then exit.
It would be best if the chmodMydir program would not have to accept any input from the user directly: a hardcoded directory name would be safest. Reading the directory name from a configuration file that is writeable only by root might also be acceptable *if* you clearly document that the permissions of that configuration file will be critical for system security. If you need to accept the directory name from the command line or from an environment variable, be *extremely* careful in the checking phase.
You should assume any external data can be tampered with in order to overflow the buffers in your program, so use appropriate functions to limit the amount of data you're reading (e.g. use fgets() or strncpy() to read the directory name to your buffer, then make sure it's in fact null-terminated).
With at least these precautions, it *might* be reasonably safe to give your chownMydir program setuid-root permissions. (I'm sure I've forgotten something important: please don't blindly trust me.)
Google for "writing setuid programs" to find lots of other advice for making a program secure enough for setuid-root use.
MK