MIME boundaries ending with "--"

Matt Garretson mattg at assembly.state.ny.us
Wed Feb 25 19:32:47 CET 2015


(Note, the following refers to Bogofilter 1.2.3, as I don't use 1.2.4
due to db-related problems.)


I've noticed a quirk in how bogofilter processes MIME parts, when the
boundary string ends with "--".  Bogofilter assumes that any appearance
of a boundary ending in "--" is the end of the part.  This approach
does not take into account cases where the boundary string itself ends
in "--".  (This probably doesn't happen very often, but AFAICT it is
permitted, and I have seen it in the wild.)

Here is an example from an actual email I got yesterday (quoted):

> Content-Type: multipart/mixed;
>        boundary="--InfrawareEmailBoundaryDepth1_6b5acefc--"


Admittedly, it's ugly to have "--" in the string itself, especially at
the beginning and/or end.  But I think it's legal.

So, when the part starts, we have:

> ----InfrawareEmailBoundaryDepth1_6b5acefc--

Bogofilter sees the trailing "--" and interprets this as a final
boundary, and removes the trailing "--" which causes it not to match
anything when looking through the boundary stack.  Thus the MIME part is
not recognized, the end result being hundreds of garbage tokens like
"zKzRkqfvYb2rPaNo" which pushes the score to .5

I'm not sure yet the best way to fix this, but I see some code in
mime.c that appears to control this behavior.




More information about the bogofilter mailing list