comparison thesis/tex/4-MasqmailsFuture.tex @ 165:a7fd6d974d3c

added lots of notes about spam, malware, auth, ...
author meillo@marmaro.de
date Thu, 18 Dec 2008 16:41:42 +0100
parents 5681a18270b5
children 4ac06b7b9bdf
comparison
equal deleted inserted replaced
164:0e208e23aac3 165:a7fd6d974d3c
98 \end{quote} 98 \end{quote}
99 He identifies the security of \qmail\ to come from it's \name{compartmentalization}, which goes hand in hand with modularity: 99 He identifies the security of \qmail\ to come from it's \name{compartmentalization}, which goes hand in hand with modularity:
100 \begin{quote} 100 \begin{quote}
101 A perfect example is the contrast between the feature envy early \sendmail\ architecture implemented as one process and the simple, modular architecture of \qmail. The security of \qmail\ comes from its compartmentalized simple processes that perform one task only and are therefor testable for security. \cite[page 64]{hafiz05} 101 A perfect example is the contrast between the feature envy early \sendmail\ architecture implemented as one process and the simple, modular architecture of \qmail. The security of \qmail\ comes from its compartmentalized simple processes that perform one task only and are therefor testable for security. \cite[page 64]{hafiz05}
102 \end{quote} 102 \end{quote}
103 As well does \person{Dent}: ``The modular architecture of Postfix forms the basis for much of its security.''\cite[page 7]{dent04}
103 104
104 Modularity is needed for supporting modern \MTA\ requirements, providing a clear interface to add further functionality without increasing the overall complexity much. Modularity is also an enabler for security. Security comes from good design, as \person{Graff} and \person{van Wyk} explain: 105 Modularity is needed for supporting modern \MTA\ requirements, providing a clear interface to add further functionality without increasing the overall complexity much. Modularity is also an enabler for security. Security comes from good design, as \person{Graff} and \person{van Wyk} explain:
105 \begin{quote} 106 \begin{quote}
106 Good design is the sword and shield of the security-conscious developer. Sound design defends your application from subversion or misuse, protecting your network and the information on it from internal and external attacks alike. It also provides a safe foundation for future extensions and maintainance of the software. 107 Good design is the sword and shield of the security-conscious developer. Sound design defends your application from subversion or misuse, protecting your network and the information on it from internal and external attacks alike. It also provides a safe foundation for future extensions and maintainance of the software.
107 % 108 %
119 \subsection{Modules needed} 120 \subsection{Modules needed}
120 121
121 This section tries to identify the needed modules for a modern \MTA. They are later the pieces of which the new architecture is built of. 122 This section tries to identify the needed modules for a modern \MTA. They are later the pieces of which the new architecture is built of.
122 123
123 124
124 \subsubsection*{The simplest MTA} 125 \subsubsection*{The simple view}
125 This view of the problem is taken from \person{Hafiz} \cite[pages 3-5]{hafiz05}. 126
126 127 The basic job of a \mta\ is to tranport mail from a sender to a recipient. This is the definition of such a program and this is how \person{Dent}\cite[page 19]{dent04} and \person{Hafiz} \cite[pages 3-5]{hafiz05} start on the design.
127 The basic job of a \mta\ is to tranport mail from a sender to a recipient. The simplest \MTA\ therefor needs at least a mail receiving facility and a mail sending facility. This basic \MTA---following the definition of an \MTA---is much to abstract. Hence a next step to add some important features is needed, the result is an operational \MTA. 128
128 129 An \MTA\ therefor needs at least a mail receiving facility and a mail sending facility. But both, and probably all \MTA\ developers (excluded the only forwarders), see the need for a mail queue. A mail queue removed the need to deliver at once. They also provide fail-safe storage of mails until they are delivered.
129 130
130 131
131 \subsubsection*{Mail queue}
132
133 \person{Hafif} adds a mail queue to make it possible to not deliver at once.
134
135 Mail queues are probably used in all \mta{}s, excluding the simple forwarders. A mail queue is a essential requirement for \masqmail, as it is to be used for non-permanent online connections.
136 132
137 133
138 \subsubsection*{Incoming channels} 134 \subsubsection*{Incoming channels}
139 135
140 The second addition \person{Hafiz} made is the split of incoming and outgoing channels into local and remote. The question is, if this is nessesary. It is the way, it was done for a long time, but is this extra complexity needed? 136 The second addition \person{Hafiz} made is the split of incoming and outgoing channels into local and remote. The question is, if this is nessesary. It is the way, it was done for a long time, but is this extra complexity needed?
156 As mail delivery to local users, is \emph{not} included in the basic job of \MTA{}s, why should they care about it? In order to keep the system simple and to have programs do one job well, the local delivery job should be handed over to \NAME{MDA}s. \name{Mail delivery agents} are the tools that are specialized for local delivery. They know about the various mailbox formats and are aware of the problems of concurrent write access and thelike. Hence handling the message and the responsiblity for it over to a mail delivery agent, like \name{procmail} or \name{maildrop}, seems to be the right way to go. 152 As mail delivery to local users, is \emph{not} included in the basic job of \MTA{}s, why should they care about it? In order to keep the system simple and to have programs do one job well, the local delivery job should be handed over to \NAME{MDA}s. \name{Mail delivery agents} are the tools that are specialized for local delivery. They know about the various mailbox formats and are aware of the problems of concurrent write access and thelike. Hence handling the message and the responsiblity for it over to a mail delivery agent, like \name{procmail} or \name{maildrop}, seems to be the right way to go.
157 153
158 This means outgoing connections, piping mails into local commands needs to be implemented. 154 This means outgoing connections, piping mails into local commands needs to be implemented.
159 155
160 156
161 \subsubsection*{Mail queue (again)} 157
158 \subsubsection*{Sanitize mail}
159 generate valid headers: add, rewrite
160 ... better before inserting into the queue
161
162 (determine the method to send at that position?)
163
164
165
166
167 \subsubsection*{Aliasing}
168
169 where to expand aliases?
170
171
172
173 \subsubsection*{Mail queue}
174
175 Mail queues are probably used in all \mta{}s, excluding the simple forwarders. A mail queue is a essential requirement for \masqmail, as it is to be used for non-permanent online connections.
176
177
178
162 179
163 180
164 181
165 182
166 \subsubsection*{Authentication} 183 \subsubsection*{Authentication}
167 184
168 easiest: restricting by static IP addresses (Access control via hosts.allow/hosts.deny) 185 either by
169 if dynamic remote hosts need access: some auth is needed 186 - network/ip address
170 - SASL 187 easiest: restricting by static IP addresses (Access control via hosts.allow/hosts.deny)
171 - POP/IMAP: pop-before-smtp, DRAC, WHOSON 188 or
172 - TLS (certificates) 189 - some kind of auth (for dynamic remote hosts)
173 190 adds complexity
174 ``None of these add-ons is an ideal solution. They require additional code compiled into your existing daemons that may then require special write accesss to system files. They also require additional work for busy system administrators. If you cannot use any of the nonauthenticating alternatives mentioned earlier, or your business requirements demand that all of thyour users' mail pass through your system no matter where they are on the Internet, SASL is probably the solution that offers the most reliable and scalable method to authenticate users.'' (Dent: Postfix, page 44, ch04) 191 - SASL
192 - POP/IMAP: pop-before-smtp, DRAC, WHOSON
193 - TLS (certificates)
194
195 \begin{quote}
196 None of these add-ons is an ideal solution. They require additional code compiled into your existing daemons that may then require special write accesss to system files. They also require additional work for busy system administrators. If you cannot use any of the nonauthenticating alternatives mentioned earlier, or your business requirements demand that all of thyour users' mail pass through your system no matter where they are on the Internet, SASL is probably the solution that offers the most reliable and scalable method to authenticate users.
197 \cite[page 44]{dent04}
198 \end{quote}
175 199
176 200
177 \subsubsection*{Encryption} 201 \subsubsection*{Encryption}
178 202
203 TLS/SSL prevents attackers to listen on the cable
204 but it does not prevent man-in-the-middle attacks
205 signed certificates help here
206
207
208 ch /usr/share/ssl/misc
209
210 create new CA:
211 \begin{verbatim}
212 CA.pl -newca
213 country: DE
214 state: schwaben
215 city: Ulm
216 company:
217 section:
218 name:
219 emailaddress:
220 \end{verbatim}
221
222 generate ssl key:
223 \begin{verbatim}
224 CA.pl -newreq
225 ... the same questions
226 \end{verbatim}
227
228 sign request with CA:
229 \begin{verbatim}
230 CA.pl -sign
231 \end{verbatim}
232
233 remove passphrase from private key:
234 \begin{verbatim}
235 openssl rsa <newreq.pem >key.pem
236 (to be used by programs automaticly)
237 \end{verbatim}
238
239 secure:
240 \begin{verbatim}
241 chmod 400 *.pem
242 cp newcert.pem /etc/postfix/cert.pem
243 cp key.pem /etc/postfix/key.pem
244 cp demoCA/cacert.pem /etc/postfix/CAcert.pem
245 chmode 400 /etc/postfix/*.pem
246
247 mkdir /etc/stunnel
248 cat newcert.pem key.pem >/etc/stunnel/stunnel.pem
249 chmod 400 /etc/stunnel/stunnel.pem
250 (check /etc/stunnel with `stunnel -V')
251 \end{verbatim}
252
253
254 set up stunnels for POP, etc:
255 \begin{verbatim}
256 nmap localhost
257 stunnel -d pop3s -r localhost:pop3 -p /etc/stunnel/stunnel.pem
258 stunnel -d imaps -r localhost:imap -p /etc/stunnel/stunnel.pem
259 nmap localhost
260 pop3s 995
261 imaps 993
262 \end{verbatim}
263
264 do not use stunnel wit SMTP:
265 because all incoming mail would be from 127.0.0.1 !!
266 use STARTTLS instead
267
268 postfix: main.cf
269 \begin{verbatim}
270 smtpd_use_tls = yes
271 smtpd_tls_received_header = no (does not log in received headers)
272
273 smtpd_tls_key_file = /etc/postfix/key.pem
274 smtpd_tls_cert_file = /etc/postfix/cert.pem
275 smtpd_tls_CA_file = /etc/postfix/CAcert.pem
276
277 smtp_use_tls = yes (use TLS for sending)
278 smtp_tls_key_file = /etc/postfix/key.pem
279 smtp_tls_cert_file = /etc/postfix/cert.pem
280 smtp_tls_CA_file = /etc/postfix/CAcert.pem
281 \end{verbatim}
282
283
284
179 285
180 \subsubsection*{Spam prevention} 286 \subsubsection*{Spam prevention}
181 287
182 288
183 where to filter what 289 where to filter what
184 290
185 291
292 postfix:
293 content-filter: arbitrary programs that talk smtp, can filter, rewrite or delete mail
294 - before-queue-c-f: need to be fast, can prevent system load
295 - after-queue-c-f: need more resources in global, more load
296
297 exim:
298 acls: to filter, what to accept (hook into smtp dialog) (complex)
299 routers: take recipient address and choose a matching transport
300 transports: ways to deliver mail (smtp, local)
301
302
186 postfix: after-queue-content-filter (smtp communication) 303 postfix: after-queue-content-filter (smtp communication)
187 exim: content-scan-feature 304 exim: content-scan-feature (analyses the content: MIME stuff, blacklisted words, virus scanning) (all within smtp dialog)
188 sendmail: milter (tcp or unix sockets) 305 sendmail: milter (tcp or unix sockets)
189 306
190 checks while smtp dialog (pre-queue): in MTA implemented (need to be fast) 307 checks while smtp dialog (pre-queue): in MTA implemented (need to be fast)
191 checks when mail is accepted and queued: external (amavis, spamassassin) 308 checks when mail is accepted and queued: external (amavis, spamassassin)
192 309
193 310
311
312
313
314
315 what do do with recognized mail?
316 - reject (only possible if recognized during SMTP dialog)
317 - forward with added header line or changed subject
318 (eisentraut05: page 18--20)
319
320 check incoming and outgoing mail
321 (eisentraut05: page 21)
322
323
324 milter:
325 communication with external daemons via a special protocol
326 at various times in the smtp dialog possible
327 can reject, delete or alter messages
328 http://milter.org
329 (eisentraut05: page 69)
330
331
332 use SA with exim:
333 - with transport: piped into sa
334 - content-scanning-feature: with ACL during smtp dialog
335 - plugin: sa-exim
336 - within amavis
337
338 use SA with sendmail:
339 - with milter
340 - within mimedefang or amavis
341
342 use SA with postfix:
343 - within amavis or mailfilter
344
345
346 (eisentraut05: page 25) ``Ganz ohne Analyse während der SMTP-Phase kommt sowieso kein MTA aus, und es ist eine Frage der Einschätzung, wie weit man diese Phase belasten möchte.''
347
348
349 DNSBL can contain:
350 - open relays
351 - dynamic IP addresses
352 - verified spam sources
353 - open multistage relays
354 - vulnerable CGI scripts
355 - open proxy servers
356 example: NJABL (http://njabl.org)
357
358 DNSBL in smpt dialog is aggressive and can lead to problems (eisentraut05: page 126)
359
360
361 greylisting:
362 if first contact from that address: temp failure and add to list
363 sender will retry, then accept
364
365 ``Das Greylisting zählt derzeit zu den effektivsten Methoden, um gegen unerwünschte E-Mails vorzugehen. Allein durch Greylisting können derzeit rund 70\% des potenziellen Spam-Aufkommens auf einem Mailserver vollständig geblockt werden. Allerdings ist es auch nur eine Frage der Zeit, bis sich die Gemeinde der Spammer und Virenautoren auf diese Methode der Spam-Bekämpfung eingerichtet und entsprechende Queues in ihre Software eingebaut hat.''(eisentraut05: page 138)
366 Probleme: load balancing using multiple servers with different IPs.
367 postfix: with policy server
368 exim: direct in config
369 sendmail: with greylist milter
370
371
372
373 hashcash
374
375
376 \subsubsection*{Virus checking}
377
378 The same for malicious content (\name{malware}) like viruses, worms, trojan horses. They are related to spam, but affect the \MTA less, as they are in the mail body.
379
380 message body <-> envelope, header
381
382
383 anti-virus: clamav
384 postfix: via amavis
385 exim: via content-scanning-feature called from acl
386 sendmail: with milter
387 procmail
388
389
390 virus scanner work on file level
391 amavis receives mail via smtp or pipe, splits it in its parts (MIME) and extracks archives, the come the virus scanners
392 if the mail is okay, it goes via smtp to a second mta
393
394
194 AMaViS (amavisd-new): email filter framework to integrate spam and virus scanner 395 AMaViS (amavisd-new): email filter framework to integrate spam and virus scanner
396 \begin{verbatim}
195 internet -->25 MTA -->10024 amavis -->10025 MTA --> reciptient 397 internet -->25 MTA -->10024 amavis -->10025 MTA --> reciptient
196 | | 398 | |
197 +----------------------------+ 399 +----------------------------+
198 mail scanner: 400 \end{verbatim}
199 incoming queue --> mail scanner --> outgoing queue 401
402 postfix and exim can habe both mta servises in the same instance, sendmail needs two instances running.
403
404 what amavis recognizes:
405 - invalid headers
406 - banned files
407 - viruses
408 - spam (using spam assassin)
409
200 410
201 mimedefang: uses milter interface with sendmail 411 mimedefang: uses milter interface with sendmail
202 412
203 413
204 \subsubsection*{Virus checking} 414 MailScanner:
205 415 incoming queue --> MailScanner --> outgoing queue
206 The same for malicious content (\name{malware}) like viruses, worms, trojan horses. They are related to spam, but affect the \MTA less, as they are in the mail body. 416
207 417 postfix: with one instance possible, exim and sendmail need two instances running
208 message body <-> envelope, header
209
210
211 anti-virus: clamav
212
213 418
214 419
215 420
216 421
217 \subsubsection*{Archiving} 422 \subsubsection*{Archiving}
218 423
219 424
425 \texttt{always\_bcc} feature of postfix
220 426
221 427
222 428
223 \section{A new architecture} 429 \section{A new architecture}
224 430