search menu icon-carat-right cmu-wordmark

CERT Coordination Center

Solaris libc getopt(3) contains buffer overflow

Vulnerability Note VU#6901

Original Release Date: 2003-09-25 | Last Revised: 2003-09-25


Solaris libc getopt(3) contains a buffer overflow vulnerability. Please note the date of this report: 1/27/1997. This does not affect current versions of Solaris.


From <>:

A buffer overflow condition exists in the getopt(3) routine in Solaris libc. By supplying an invalid option and replacing argv[0] of a SUID program that uses the getopt(3) function with the appropriate address and machine code instructions, it is possible to overwrite the saved stack frame and upon return(s) force the processor to execute user supplied instructions with elevated permissions.


A local user can gain root access.


Please see <>.

From <>:

For those with source:
If you are one of the few people who have a source code license the fix should be fairly simple. Replace the sprintf() routine in getopt.c with snprintf() and rebuld libc.

Super Ugly kludge fix:
If you don't have the source code available (like most of us), one solution is to use adb to change the name for getopt with something like getopz, yank a publicly available getopt.c, and put it in place of getopt.

See also section 4. of <>.

Vendor Information


Sun Microsystems Inc. Affected

Updated:  September 25, 2003



Vendor Statement

We have not received a statement from the vendor.

Vendor Information

The vendor has not provided us with any further information regarding this vulnerability.


Please see <>.

If you have feedback, comments, or additional information about this vulnerability, please send us email.

CVSS Metrics

Group Score Vector



Thanks to L0pht/@stake and Sun for information used in this document.

This document was written by James T. Ellis and updated by Art Manion.

Other Information

CVE IDs: None
Severity Metric: 3.92
Date Public: 1997-01-27
Date First Published: 2003-09-25
Date Last Updated: 2003-09-25 15:34 UTC
Document Revision: 7

Sponsored by CISA.