Securing 7 Layers of Insecurity
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 62 Simple Mail Transfer Protocol You've got Mail! D 7 eep L “President Bush said for ay security reasons, he's sworn off Se er all e-mail communication. He will s c not be using email at the White o V f I House at all. Is that a good idea? i e n I mean, it's not like that speaking nn thing was working out so good.” sec a 2007 urity -- Jay Leno Copyright Information Some rights reserved / Einige Rechte vorbehalten Michael Kafka, René Pfeiffer, Sebastian Mayer C.a.T. Consulting and Trainings, Vienna, Austria You may freely use, distribute and modify this work under following D agreement: 7 eep Diese Arbeit darf frei genutzt, verbreitet und bearbeitet werden unter L folgenden Bedingungen: ay Se Authors must be referenced (also for modification) er s Autoren müssen genannt werden (auch bei Bearbeitung) c o V Only for non commercial use f I i Nur für nichtkommerzielle Nutzung e n nn Derivative work under same licence sec Derivative Arbeit unter selber Lizenz a 2007 urity http://www.creativecommons.com © November 2007 62 - SMTP Chapter 62 Simple Mail Transfer Protocol Agenda SMTP Basics SMTP Security Risks D 7 eep Anti-Spam Frameworks L ay Se E-Mail Content er s c o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP SMTP Basics The Foundation of Mail Delivery. D 7 eep L ay Se er s c o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP SMTP Properties Text based protocol Commands use 7-bit ASCII Data may use 8-bit encodings D 7 eep Message transmission as header+body L ay Se Uses different TCP ports er s c 25/TCP for server-server communication o V f I i 465/TCP for SMTP+SSL e n nn 587/TCP for message submission sec a 2007 urity © November 2007 62 - SMTP Sample SMTP Session 220 agamemnon.example.net ESMTP Postfix (Debian/GNU) EHLO agamemnon.example.net 250-agamemnon.example.net 250-PIPELINING 250-SIZE 52428800 250-VRFY D 250-ETRN 7 250-STARTTLS eep 250-ENHANCEDSTATUSCODES L 250-8BITMIME ay 250 DSN Se MAIL From: <[email protected]> er 250 2.1.0 Ok s c RCPT To: <[email protected]> o 250 2.1.5 Ok V f I DATA i e 354 End data with <CR><LF>.<CR><LF> n nn Hi! sec Bye, a 2007 Lynx. urity . 250 2.0.0 Ok: queued as 2CB7C24008A9 QUIT 221 2.0.0 Bye © November 2007 62 - SMTP Extended SMTP (ESMTP) Adds commands and functionalities Command pipelining SSL/TLS support D 7 eep 8-bit support for data L ay Se On-demand relay for mobile users er s c Many MTAs support ESMTP o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP SMTP Security Risks Let's Shoot the Messenger. D 7 eep L ay Se er s c o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP Open / Unauthorised Relays UBE/UCE still a big problem Malware packed into email Spam D 7 eep MTA needs to verify source of email L ay Se Any open relay will be misused er s c Disrupt email delivery o V f I i Put IP range(s) on RBLs e n nn Risk: medium sec a 2007 Impact: high urity © November 2007 62 - SMTP SMTP EHLO/HELO Pipe Bombs Imagine you inspect HELO strings Your logs look like this someday 2007-…rblsmtp: 43 EHLO “|http://a.b.cc/cgi/put.cgi” D 7 eep 2007-…rblsmtp: 43 HELO “|http://a.b.cc/cgi/put.cgi” L ay Scripting security also applies to MTAs! Se er s Risk: medium c o V f I Impact: high i e n nn sec a 2007 urity © November 2007 62 - SMTP SMTP VRFY SMTP VRFY tests email addresses Existing accounts will be confirmed (Ab)use for reconnaissance D 7 eep Some clients require VRFY L ay Se MTAs may allow VRFY without announcement er s c Risk: medium o V f I i Impact: medium e n nn sec a 2007 urity © November 2007 62 - SMTP SMTP Authentication Protocol offers no authentication Sender/recipient is arbitrary Mail relaying must be tightly controlled D 7 eep MITM attacks can be easily done L ay Se Spoofing of messages very easy er s c o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP SMTP AUTH ESMTP offers authentication Used for MUA→MTA / MTA→MTA Email addresses stay unauthenticated D 7 eep Reduces open relay problem L ay Se Lost/brute-forced password critical er s c Useful for mobile users o V f I i Most MTA support SASL mechanisms e n nn sec a 2007 urity © November 2007 62 - SMTP SMTP + SSL/TLS Works with keys & certificates Provides everything that SSL/TLS promises MTAs usually have no trust relationship D 7 eep Self-signed certificates L ay Se Certificates are next to never verified er s c MITM still possible o V f I i Risk: medium e n nn Impact: medium sec a 2007 urity © November 2007 62 - SMTP Anti-Spam Frameworks Enhanced Complexity as Security Measure. D 7 eep L ay Se er s c o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP Domain Keys Adds header with signature Signed content of message Signature linked to domain name D 7 eep Cryptographic checksums per message L ay Se In-transit modification breaks checks er s c Mailing list managers o V f I i Content filter e n nn Envelope not part of signature sec a 2007 Replay injection possible urity © November 2007 62 - SMTP Domain Keys & DNS DomainKey-Signature header has fields: …d=example.net; s=dkim.key;… PK lookup: dkim.key._domainkey.example.net D 7 eep DNS security determines DKIM security L ay DNS attacks apply as well Se er s Attacker may try to offer own key c o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP Sender Policy Framework (SPF) Based on published policies in DNS Domains name valid email origins Domains name default trust level D 7 eep SPF works in SMTP dialogue L ay Se Early blocking possible er s c SPF completely breaks email forwarding o V f I i Message must be rewritten e n nn Sender Rewriting Scheme (SRS) sec a 2007 urity © November 2007 62 - SMTP Real Time Blacklisting (RBL) RBL are simply based on lists Distribution by DNS is common Listing may have arbitrary parameters D 7 eep Most RBLs are based on reputation L ay Se Metrics help measurement er s c Scores can change dynamically o V f I i Using any RBL outsources access lists e n nn sec a 2007 urity © November 2007 62 - SMTP Chapter 62 Simple Mail Transfer Protocol Summary . SMTP needs protection. SMTP relies on DNS infrastructure. D 7 eep . SMTP + SSL/TLS isn't necessarily safe. L ay . Se SMTP servers on RBL are useless. er s . c Pick RBLs carefully. o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP Thank You Questions? D 7 eep L ay Se er s c o V f I i e n nn sec a 2007 urity © November 2007 62 - SMTP DeepSec Conference © November 2007 Chapter 62 Simple Mail Transfer Protocol You've got Mail! D 7 eep L “President Bush said for ayers o security reasons, he's sworn off Sec all e-mail communication. He will not be using email at the White Vien House at all. Is that a good idea? f I I mean, it's not like that speaking n secu thing was working out so good.” n a 2007 rity -- Jay Leno © November 2007 62 - SMTP 1 99 - Things in Life 1 DeepSec Conference © November 2007 Copyright Information Some rights reserved / Einige Rechte vorbehalten Michael Kafka, René Pfeiffer, Sebastian Mayer C.a.T. Consulting and Trainings, Vienna, Austria You may freely use, distribute and modify this work under following D agreement: 7 eep Diese Arbeit darf frei genutzt, verbreitet und bearbeitet werden unter L folgenden Bedingungen: ayers o Sec Authors must be referenced (also for modification) Autoren müssen genannt werden (auch bei Bearbeitung) Vien Only for non commercial use f I Nur für nichtkommerzielle Nutzung n secu Derivative work under same licence n Derivative Arbeit unter selber Lizenz a 2007 http://www.creativecommons.com rity © November 2007 62 - SMTP 2 This presentation is published under the CreativeCommons License which can be viewed in detail on their hompage: http://creativecommons.org/licenses/by-nc-sa/2.0/at/ Read more on http://www.creativecommons.com You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Noncommercial. You may not use this work for commercial purposes. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. ● For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.