Bug 4968 - [review] untaint_file_path claims "%" is an unsafe character
Summary: [review] untaint_file_path claims "%" is an unsafe character
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Libraries (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: Other other
: P5 normal
Target Milestone: 3.1.4
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard: can be committed
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-25 13:27 UTC by Wincent Colaiuta
Modified: 2006-07-09 17:38 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status
suggested patch patch None Theo Van Dinter [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Wincent Colaiuta 2006-06-25 13:27:40 UTC
On my Red Hat Enterprise Linux box all hosted email accounts have home directories that contain a "%" 
character and look like this (this example is for the email address, "john@example.com"):

/home/john%example.com

This causes Spam Assassin to complain like this in various circumstances (for example, when running 
sa-learn):

security: cannot untaint path: "/home/john%example.com/.spamassassin"

This is because the "%" character in the path causes the regex in the untaint_file_path() function (in 
"Util.pm") to fail to match:

  my $chars = '-_A-Za-z\xA0-\xFF0-9\.\@\=\+\,\/\\\:';
  my $re = qr/^\s*([$chars][${chars}~ ]*)$/o;

Now, this may be a bug in Spam Assassin, or an unfortunate consequence of the server policy to 
substitute "%" for "@" in email account home directories. I am not aware of any adverse consequences of 
adding "%" to the regex; am I missing something here? Should Spam Assassin be changed to allow the 
"%" character when untainting file paths?

  my $chars = '-_A-Za-z\xA0-\xFF0-9\.\@\%\=\+\,\/\\\:';
  my $re = qr/^\s*([$chars][${chars}~ ]*)$/o;
Comment 1 Theo Van Dinter 2006-06-27 00:10:59 UTC
I can't think of a reason not to include %, so I've committed it for 3.2.0 and
will put up a proper patch needing votes in a minute.

Sending        lib/Mail/SpamAssassin/Util.pm
Transmitting file data .
Committed revision 417315.
Comment 2 Theo Van Dinter 2006-06-27 00:11:21 UTC
Created attachment 3560 [details]
suggested patch
Comment 3 Justin Mason 2006-06-29 09:30:33 UTC
+1
Comment 4 Daryl C. W. O'Shea 2006-07-09 22:15:12 UTC
+1
Comment 5 Theo Van Dinter 2006-07-10 00:38:15 UTC
Sending        lib/Mail/SpamAssassin/Util.pm
Transmitting file data .
Committed revision 420383.