Beware xargs security holes

John R. MacMillan john at sco.COM
Fri Oct 26 16:10:55 AEST 1990


|It dosn't matter what xargs uses to run the command.  The problem is how
|it parses it's input.  If the input is newline separated and a user can
|add newlines to a filename, then the user can create a file that will
|cause xargs to incorrectly parse it's input.

So check that xargs did indeed parse its input correctly.  Instead of

find / -name '#*' -print | xargs rm -f

use

find / -name '#*' -print | xargs patok '.*/#[^/]*' rm -f --

where patok elimnates arguments that don't match the pattern.
Shouldn't be tough to write.  It wouldn't remove files with newlines,
but if patok complains about non-matches, you could find them later and
go slap the file owner's wrist.

Sound reasonable?
-- 
John R. MacMillan       | I'm in love with a McDonald's girl
SCO Canada, Inc.        | She's an angel in a polyester uniform.
john at sco.COM            |      -- barenaked ladies



More information about the Comp.unix.shell mailing list