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, 2018 at 13:21
  • 1
    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
    – dfsg76
    Sep 14, 2018 at 13:39
  • Is the encrypted mail is mean to be used as a way to check legitimacy of the sender ?
    – mootmoot
    Sep 14, 2018 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
    – dfsg76
    Sep 14, 2018 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, 2018 at 14:21

1 Answer 1


Main concerns would probably be - your server is taken over as a spam bot - your server is used to phish your legit customers with malicious emails originating from your server

Implement logging & review it so you know when your server starts sending unexpected emails on your behalf

Implement whitelisting such as - whitelist of allowed outbound recipients , if they're not on the list your email server won't send it - whitelist of allowed sending servers, if attacker tries send email to your email server it is rejected because not on the allowed list of sending servers

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .