LWN.net Logo

xpdf vulnerability - CAN-2003-0434

From:  Andries.Brouwer@cwi.nl
To:  announce@mandrakesecure.net, bugtraq@securityfocus.com, letters@lwn.net
Subject:  xpdf vulnerability - CAN-2003-0434
Date:  Sat, 28 Jun 2003 19:33:12 +0200 (MEST)

I see RedHat and Mandrake reactions to the vulnerability
in xpdf reported by Martyn Gilmore. But their updates do
not fix the problem.

They change xpdf, and make it filter out backquotes before
invoking urlCommand. I think that was unnecessary.

On the other hand, urlCommand must be very careful what it
does with the URL since it was remote-user-supplied.
A urlCommand like the default "netscape -remote 'openURL(%s)'"
is OK since the %s is protected by single quotes.

A urlCommand like the RedHat "/usr/bin/xpdf-handle-url %s"
is bad since %s is not protected and funny games are possible.
In other words, not xpdf but /etc/xpdfrc must be fixed.

Next, RedHat /usr/bin/xpdf-handle-url is bad as well, since
it does
  xterm -e sh -c "echo Edit $0 to include your URL handler; echo $1; read"
exposing the unquoted URL to sh -c.

For example, on a RedHat 8.0 system that I have here, clicking the URL
like "nailto:me; rm /tmp/abc" will remove the indicated file, also
after the fix is applied.

A testexample for playing with pdflatex:

\documentclass[11pt]{minimal}
\usepackage{color}
\usepackage[urlcolor=blue,colorlinks=true,pdfpagemode=none]{hyperref}
\begin{document}
\href{prot:hyperlink with stuff, say, `rm -rf /tmp/abc`; touch /tmp/pqr}{\textt\
t{Click me}}
\end{document}

All shell metacharacters are dangerous. Not only backquote.

Andries


(Log in to post comments)

xpdf vulnerability - CAN-2003-0434

Posted Jul 4, 2003 0:23 UTC (Fri) by joey (subscriber, #328) [Link]

netscape -remote 'openURL(%s)' is not safe, if you are expanding
%s before passing this to the shell. %s could contain any number of single quotes.

Never pass untrusted data through a shell. Use exec.

xpdf vulnerability - CAN-2003-0434

Posted Jul 5, 2003 18:35 UTC (Sat) by piman (subscriber, #8957) [Link]

Or, if you're programming Perl or Ruby, the system() function can take one string argument (which then is expanded), or a list of arguments, which is not expanded, and much safer.

Copyright © 2003, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds