Bug 526513 (CVE-2009-5067) - CVE-2009-5067 html2ps: arbitrary file disclosure in SSI directives
Summary: CVE-2009-5067 html2ps: arbitrary file disclosure in SSI directives
Alias: CVE-2009-5067
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL: http://user.it.uu.se/~jan/html2ps.html
Depends On: 530386 530398 530403 586356 587324
TreeView+ depends on / blocked
Reported: 2009-09-30 17:26 UTC by Vincent Danen
Modified: 2019-09-29 12:32 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-06-25 10:02:50 UTC

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Debian BTS 548633 0 None None None Never

Description Vincent Danen 2009-09-30 17:26:22 UTC
It was reported [1] that html2ps suffers from an arbitrary file disclosure in SSI directives, as noted via the exploit [2] posted to PacketStorm.  This has not been addressed upstream from what I can tell.  If html2ps is called via a web page that allows a user to upload the content to convert to ps, it could allow for abitrary file content disclosure based on the permissions of the user running html2ps.

This would affect html2ps in Fedora 10, 11, rawhide, and EPEL 5.

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=548633
[2] http://www.packetstormsecurity.org/0909-exploits/html2ps-disclose.txt

Comment 1 Vincent Danen 2009-10-20 16:44:21 UTC
This was not reported upstream at all, so I emailed the author.  He isn't really maintaining html2ps anymore, but did provide the following patch to disable SSI support:

*** 2526,2530 ****
!       if($1 eq "include" && (substr($file,0,1) ne "/" || $opt_r)) {
          if(substr($file,0,1) ne "/") {
--- 2526,2530 ----
!       if(0 && $1 eq "include" && (substr($file,0,1) ne "/" || $opt_r)) {
          if(substr($file,0,1) ne "/") {

He has, however, indicated that he will try to come up with a better fix.  I think it unlikely that many people would be using html2ps as a CGI to parse untrusted user input, so it may be prudent to disable the support altogether if we do not get an appropriate fix or cannot come up with one.

Comment 3 Vincent Danen 2009-10-22 15:36:05 UTC
Upstream has released 1.0b6 to address this issue:

  091021 1.0b6   "Security" fix. Changed behavior for SSI, to avoid having
                 arbitrary readable files disclosed on a web server that uses
                 html2ps in a web application (cgi script etc), allowing HTML
                 files to be uploaded for conversion. Setting up a service like
                 this is begging for trouble in my opinion. (Is /bin/cat also
                 a vulnerability, since one can use it in a web app, allowing
                 uploading arbitrary parameters to it?)

Could you update to the b6 release?  The diff is quite small so patching would be an option as well, but because the only change in this version is this fix, I think it would be better to update to the latest version.


Comment 7 Petr Pisar 2010-04-27 11:50:36 UTC
New upstream fix does two things: disable SSI by default and checks for ".." in file path.

Problem is the second thing is done by m// operator that replaces $` and $' variables that are used later.

IOW, the fix introduce bug

Comment 8 Petr Pisar 2010-04-27 12:00:38 UTC
(In reply to comment #7)
IOW, the fix introduce regression. I have proposed following fix to upstream:

diff --git a/html2ps b/html2ps
index 98d3b8c..b6fb943 100755
--- a/html2ps
+++ b/html2ps
@@ -2525,6 +2525,7 @@ sub Subst{
     while(/<!--#(include|config|echo)\s+(\w+)\s*="([^"]+)"\s*-->/) {
+      my ($prefix, $suffix) = ($`,$');
       if($1 eq "include" && ($file !~m"^/|\.\." || $opt_r)) {
         if(substr($file,0,1) ne "/") {
@@ -2545,7 +2546,7 @@ sub Subst{
       } elsif ($1 eq "echo") {
-      $_=$`.$inc.$';
+      $_=$prefix.$inc.$suffix;

Comment 9 Vincent Danen 2010-04-29 15:34:22 UTC
Petr, have you heard from upstream yet regarding this?  Is this fix suitable to fix the regression and something they will be incorporating upstream?


Comment 11 Petr Pisar 2010-04-29 21:01:39 UTC
No, I haven't. However I think the patch is very trivial and bug in 1.0b6 upstream version is obvious. This is what I sent to upstream:

===Begining of mail===
Date: Tue, 27 Apr 2010 13:30:50 +0200
From: Petr Pisar <ppisar>
To: jan.se
Subject: html2ps-1.0b6 SSI fix breaks document composition


while reviewing html2ps-1.0b6 release because of SSI directory traversal bug,
I found your fix introduced regression:

- if($1 eq "include" && (substr($file,0,1) ne "/" || $opt_r)) {
+ if($1 eq "include" && ($file !~m"(^/|\.\.)" || $opt_r)) {

m/// operator replaces $` and $' variables if match succeeds. However these
variables are used later on to complete $_. This is reason why former code used
susbtr() instead of match operator.

Simple fix is to store those two variables and retrieve their content at the

[the above quoted patch from comment #8]

This is testcase where 1.0b6 dismisses everything and pastes just a part of
first included file name matching m"^/|..":

        <p>Should include (README):</p>
        <!--#include file="README"-->
        <p>Should not include (../etc/passwd):</p>
        <!--#include file="../etc/passwd"-->
        <p>Should chroot (/etc/passwd):</p>
        <!--#include file="/etc/passwd"-->
===End of mail===

Thus I have not waited longer and fixed the code in RHEL6 on my own.

Comment 12 Fedora Update System 2010-05-03 10:49:45 UTC
html2ps-1.0-0.3.b5.fc11 has been submitted as an update for Fedora 11.

Comment 13 Fedora Update System 2010-05-03 10:50:21 UTC
html2ps-1.0-0.4.b5.fc12 has been submitted as an update for Fedora 12.

Comment 14 Fedora Update System 2010-05-03 10:50:28 UTC
html2ps-1.0-0.2.b5.el5 has been submitted as an update for Fedora EPEL 5.

Comment 15 Petr Pisar 2010-05-07 12:42:35 UTC
Upstream has accepted proposed patch (comment #8) and released new version 1.0b7.

Comment 16 Fedora Update System 2010-05-25 18:37:35 UTC
html2ps-1.0-0.3.b5.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 17 Fedora Update System 2010-05-25 18:40:03 UTC
html2ps-1.0-0.4.b5.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 18 Fedora Update System 2010-05-26 00:01:47 UTC
html2ps-1.0-0.2.b5.el5 has been pushed to the Fedora EPEL 5 stable repository.  If problems still persist, please make note of it in this bug report.

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