sa-exim Greylisting.pm vulnerability

Bug #1856873 reported by Henrik Krohns
258
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sa-exim (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Hello from SpamAssassin project,

For reference, check this discussion: https://marc.info/?t=157668107800004&r=1&w=2

Greylisting.pm module provided by sa-exim uses unsafe eval for config string.

Anyone capable of writing .cf files/rules can run perl code and commands even as root, if spamd/spamassassin is started as root.

Example SpamAssassin rule:

header GREYLIST eval:greylisting("( 'hacked' => `touch /tmp/hacked && echo 1`; 'dir' => '/var/spool/sa-exim/tuplets'; 'method' => 'dir'; 'greylistsecs' => '1800'; 'dontgreylistthreshold' => 10; 'connectiphdr' => 'X-SA-Exim-Connect-IP'; 'envfromhdr' => 'X-SA-Exim-Mail-From'; 'rcpttohdr' => 'X-SA-Exim-Rcpt-To'; 'greylistnullfrom' => 1; 'greylistfourthbyte' => 0 )")

Notice one of many ways to inject commands into eval
  'hacked' => `touch /tmp/hacked && echo 1`;

This will create /tmp/hacked file immediately as the user which starts spamd or spamassassin command, and will not create any suspicious output or warnings to user.

These kinds of bugs are nasty, as people might have automatic downloads of external .cf files from third parties and never notice someone abusing things through this.

The bug is mitigated in SpamAssassin 3.4.3, which properly taints configuration strings, and results in Perl complaining and not loading Greylisting.pm at all.

I have attached a patch that maintains backwards compatibility and safely parses the config string, and of course allows the plugin to work with 3.4.3. :-)

Tags: patch

CVE References

Revision history for this message
Henrik Krohns (hegeli) wrote :
Revision history for this message
Henrik Krohns (hegeli) wrote :

Revised patch attached (previous missed untaint).

In case you use Debian sa-exim as upstream, I've also posted this to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=946829

Revision history for this message
Alex Murray (alexmurray) wrote :
information type: Private Security → Public Security
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "greylisting.diff" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Changed in sa-exim (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public Security information  
Everyone can see this security related information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.