footpad has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a CGI script that accepts an upload and emails it to a preset address. It uses CGI and MIME::Lite for the appropriate bits and is based, in part, on merlyn's column on the subject.

While experimenting with this and reading the relevant documentation, I learned that it was possible control the Encoding of the attachment in the resulting email. For example:

my $cgi = new CGI; my $file = $cgi->upload( 'uploadfile' ); my $info = $cgi->uploadInfo( $file ); # error checking deleted for brevity. # Cut the user's path from the file name. We don't care where # they stored it and it prevents most funky browser behavior. fileparse_set_fstype( "MSWin32" ); # normally risky; "okay" here [1] my ( $name ) = fileparse( $file ); # more stuff deleted, including validations and user feedback. my $msg = MIME::Lite->new( Type => 'multipart/mixed', From => $cfg{ "MSGFROM" }, # [2] To => $cfg( "MSGTO" }, Subject => $cfg( "MSGSUBJECT" } ); $msg->attach( Disposition = 'attachment', Type = $info->{ "Content-Type" }, Encoding = 'base64'; Filename = $name; FH = $file; ); # The rest deleted

My petition is this: Am I making a dangerous assumption about Encoding? As I read the documentation, it should help make the submission slightly more secure as the email travels the wires. However I want to make sure I'm not deluding myself with a bad meme, cargo-cult-programming, or other form of "the usual mistakes."

Please note that I'm not trying to get overly zealous about it. If I was really paranoid, we'd be using PGP keys, etc. I'm just trying to take a reasonable precaution. (You know, lock the door to prevent casual snooping as opposed to determined thieves who can alway throw a brick through your window.)

Footnotes:

  1. Normally, it's dangerous to assume things about the platform a visitor is using. However, this particular script will only be run by selected users, who are all running Win32 or some variation. The project manager said to assume Win32. I'm not happy with the decision, but that's what the project manager wants. *Sigh*

    I only mention to let know know that a) I know it's dangerous and b) it's something I'll address in a later update.

  2. $cfg is a hash containing basic configuration information, as discussed previously.

Thanks in advance...

--f

Replies are listed 'Best First'.
Re: Encoding Attachments
by faerloche (Sexton) on Mar 14, 2001 at 02:32 UTC
    Assuming that you are referring the base64 MIME decoding:

    It will not really make the email any more secure.. any decent email client can decode base64. If someone other than the intended recipient gets the email, their email client will most likely decode it automagically for them.

    I think you might be confusing encoding with encryption (which would make the email more secure).
Re: Encoding Attachments
by arhuman (Vicar) on Mar 14, 2001 at 03:28 UTC

    Encoding don't mean here enciphering it only means change the format to a reliable standard format to travel accross the network (mainly to deal with 8bits char being transported by mailer only accepting 7bit char...)

    You don't have key there ! EVERYBODY can decipher your 'encoded' email.

    This encoding won't give you more security than let's say URL encoding.

    Telling your boss that winzip or outlook can decode base64 and uuencode should be clear enough on the 'security strength' of this encoding.

    BTW: Almost all mail that you consider as less secure are encoded (whatever the form quoted printable,uuencode,base64) during their travel, you just don't see it beccause it's done automagically by the Mail transport and user agents...

    "Trying to be a SMART lamer" (thanx to Merlyn ;-)