Bug 5903 - race condition allows a user to read any file
race condition allows a user to read any file
Product: Red Hat Linux
Classification: Retired
Component: lpr (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
: Security
Depends On:
  Show dependency treegraph
Reported: 1999-10-12 23:43 EDT by tymm
Modified: 2014-03-16 22:10 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 1999-10-17 23:20:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description tymm 1999-10-12 23:43:50 EDT
time between the check between whether a file is accessable
or not and copying of the data in lpr allows a user to
use a symlink race exploit to print any file desired.

Tested by creating a deeply nested directory (I used 256
levels) and having a program change a link there between
/etc/shadow and a readable file, and then doing a while(1)
loop running lpr; after about 3-4 minutes on a P90,
/etc/shadow appeared in the print spool.

crud-level test code:
int main()

	char *file =

	while (1) {
		symlink("/tmp/test", file);
		symlink("/etc/shadow", file);


where /tmp/test is a user-readable file... used
while true; do lpr /tmp/0.../255/x; done
loop for the other half.

suggested fix:  use setfsuid() or seteuid() around points
where files are opened for reading.
Comment 1 Bill Nottingham 1999-10-17 23:20:59 EDT
Fixed in the lpr errata release.

Note You need to log in before you can comment on or make changes to this bug.