I'm writing a web application which will be able to send signed and encrypted emails to someone else outside my trust boundary. It will also retrieve S/MIME encrypted (and maybe also signed) emails from different accounts.

What security precautions do I need to make?

More specific questions:

  • Is there a need to implement any kind of input validation (for the emails received). The attachment will be stored in a database and accessible via the web UI.
  • What about output sanitization? As the email will be encrypted and signed, is there a strong need to do anything with the contents before?
  • Please take note that signed email doesn't mean it is legitimate, because recipient may publish the public key freely to anyone, thus spammer or malware getting the key can craft the mail and send to the victim. It is not easy to implement a phisher proof point to point email solution without introduce excessive validation that will annoyed the user. – mootmoot Sep 14 at 13:21
  • I don't see why it would be a problem when the recipient publishes his public key to the public in this case. The signature will be done with my private key when I send a signed email. My private key will of course never leave the machine where the signature is attached – pudelwudel Sep 14 at 13:39
  • Is the encrypted mail is mean to be used as a way to check legitimacy of the sender ? – mootmoot Sep 14 at 13:50
  • 1
    Of course not, that's not what encryption is meant to be for. I will both encrypt AND sign the message – pudelwudel Sep 14 at 14:13
  • Then I guess this is question about possible vulnerabilities on parsing the email message? Such as various email-client vulnerabilities published under CVE : cvedetails.com – mootmoot Sep 14 at 14:21

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.