-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrfc5804.txt
2747 lines (1822 loc) · 101 KB
/
rfc5804.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Internet Engineering Task Force (IETF) A. Melnikov, Ed.
Request for Comments: 5804 Isode Limited
Category: Standards Track T. Martin
ISSN: 2070-1721 BeThereBeSquare, Inc.
July 2010
A Protocol for Remotely Managing Sieve Scripts
Abstract
Sieve scripts allow users to filter incoming email. Message stores
are commonly sealed servers so users cannot log into them, yet users
must be able to update their scripts on them. This document
describes a protocol "ManageSieve" for securely managing Sieve
scripts on a remote server. This protocol allows a user to have
multiple scripts, and also alerts a user to syntactically flawed
scripts.
Status of This Memo
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has
received public review and has been approved for publication by the
Internet Engineering Steering Group (IESG). Further information on
Internet Standards is available in Section 2 of RFC 5741.
Information about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
http://www.rfc-editor.org/info/rfc5804.
Copyright Notice
Copyright (c) 2010 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Melnikov & Martin Standards Track [Page 1]
RFC 5804 ManageSieve July 2010
Table of Contents
1. Introduction ....................................................3
1.1. Commands and Responses .....................................3
1.2. Syntax .....................................................3
1.3. Response Codes .............................................3
1.4. Active Script ..............................................6
1.5. Quotas .....................................................6
1.6. Script Names ...............................................6
1.7. Capabilities ...............................................7
1.8. Transport ..................................................9
1.9. Conventions Used in This Document .........................10
2. Commands .......................................................10
2.1. AUTHENTICATE Command ......................................11
2.1.1. Use of SASL PLAIN Mechanism over TLS ...............16
2.2. STARTTLS Command ..........................................16
2.2.1. Server Identity Check ..............................17
2.3. LOGOUT Command ............................................20
2.4. CAPABILITY Command ........................................20
2.5. HAVESPACE Command .........................................20
2.6. PUTSCRIPT Command .........................................21
2.7. LISTSCRIPTS Command .......................................23
2.8. SETACTIVE Command .........................................24
2.9. GETSCRIPT Command .........................................25
2.10. DELETESCRIPT Command .....................................25
2.11. RENAMESCRIPT Command .....................................26
2.12. CHECKSCRIPT Command ......................................27
2.13. NOOP Command .............................................28
2.14. Recommended Extensions ...................................28
2.14.1. UNAUTHENTICATE Command ............................28
3. Sieve URL Scheme ...............................................29
4. Formal Syntax ..................................................31
5. Security Considerations ........................................37
6. IANA Considerations ............................................38
6.1. ManageSieve Capability Registration Template ..............39
6.2. Registration of Initial ManageSieve Capabilities ..........39
6.3. ManageSieve Response Code Registration Template ...........41
6.4. Registration of Initial ManageSieve Response Codes ........41
7. Internationalization Considerations ............................46
8. Acknowledgements ...............................................46
9. References .....................................................47
9.1. Normative References ......................................47
9.2. Informative References ....................................48
Melnikov & Martin Standards Track [Page 2]
RFC 5804 ManageSieve July 2010
1. Introduction
1.1. Commands and Responses
A ManageSieve connection consists of the establishment of a client/
server network connection, an initial greeting from the server, and
client/server interactions. These client/server interactions consist
of a client command, server data, and a server completion result
response.
All interactions transmitted by client and server are in the form of
lines, that is, strings that end with a CRLF. The protocol receiver
of a ManageSieve client or server is either reading a line or reading
a sequence of octets with a known count followed by a line.
1.2. Syntax
ManageSieve is a line-oriented protocol much like [IMAP] or [ACAP],
which runs over TCP. There are three data types: atoms, numbers and
strings. Strings may be quoted or literal. See [ACAP] for detailed
descriptions of these types.
Each command consists of an atom (the command name) followed by zero
or more strings and numbers terminated by CRLF.
All client queries are replied to with either an OK, NO, or BYE
response. Each response may be followed by a response code (see
Section 1.3) and by a string consisting of human-readable text in the
local language (as returned by the LANGUAGE capability; see
Section 1.7), encoded in UTF-8 [UTF-8]. The contents of the string
SHOULD be shown to the user ,and implementations MUST NOT attempt to
parse the message for meaning.
The BYE response SHOULD be used if the server wishes to close the
connection. A server may wish to do this because the client was idle
for too long or there were too many failed authentication attempts.
This response can be issued at any time and should be immediately
followed by a server hang-up of the connection. If a server has an
inactivity timeout resulting in client autologout, it MUST be no less
than 30 minutes after successful authentication. The inactivity
timeout MAY be less before authentication.
1.3. Response Codes
An OK, NO, or BYE response from the server MAY contain a response
code to describe the event in a more detailed machine-parsable
fashion. A response code consists of data inside parentheses in the
form of an atom, possibly followed by a space and arguments.
Melnikov & Martin Standards Track [Page 3]
RFC 5804 ManageSieve July 2010
Response codes are defined when there is a specific action that a
client can take based upon the additional information. In order to
support future extension, the response code is represented as a
slash-separated (Solidus, %x2F) hierarchy with each level of
hierarchy representing increasing detail about the error. Response
codes MUST NOT start with the Solidus character. Clients MUST
tolerate additional hierarchical response code detail that they don't
understand. For example, if the client supports the "QUOTA" response
code, but doesn't understand the "QUOTA/MAXSCRIPTS" response code, it
should treat "QUOTA/MAXSCRIPTS" as "QUOTA".
Client implementations MUST tolerate (ignore) response codes that
they do not recognize.
The currently defined response codes are the following:
AUTH-TOO-WEAK
This response code is returned in the NO or BYE response from an
AUTHENTICATE command. It indicates that site security policy forbids
the use of the requested mechanism for the specified authentication
identity.
ENCRYPT-NEEDED
This response code is returned in the NO or BYE response from an
AUTHENTICATE command. It indicates that site security policy
requires the use of a strong encryption mechanism for the specified
authentication identity and mechanism.
QUOTA
If this response code is returned in the NO/BYE response, it means
that the command would have placed the user above the site-defined
quota constraints. If this response code is returned in the OK
response, it can mean that the user's storage is near its quota, or
it can mean that the account exceeded its quota but that the
condition is being allowed by the server (the server supports
so-called soft quotas). The QUOTA response code has two more
detailed variants: "QUOTA/MAXSCRIPTS" (the maximum number of per-user
scripts) and "QUOTA/MAXSIZE" (the maximum script size).
REFERRAL
This response code may be returned with a BYE result from any
command, and includes a mandatory parameter that indicates what
server to access to manage this user's Sieve scripts. The server
will be specified by a Sieve URL (see Section 3). The scriptname
Melnikov & Martin Standards Track [Page 4]
RFC 5804 ManageSieve July 2010
portion of the URL MUST NOT be specified. The client should
authenticate to the specified server and use it for all further
commands in the current session.
SASL
This response code can occur in the OK response to a successful
AUTHENTICATE command and includes the optional final server response
data from the server as specified by [SASL].
TRANSITION-NEEDED
This response code occurs in a NO response of an AUTHENTICATE
command. It indicates that the user name is valid, but the entry in
the authentication database needs to be updated in order to permit
authentication with the specified mechanism. This is typically done
by establishing a secure channel using TLS, verifying server identity
as specified in Section 2.2.1, and finally authenticating once using
the [PLAIN] authentication mechanism. The selected mechanism SHOULD
then work for authentications in subsequent sessions.
This condition can happen if a user has an entry in a system
authentication database such as Unix /etc/passwd, but does not have
credentials suitable for use by the specified mechanism.
TRYLATER
A command failed due to a temporary server failure. The client MAY
continue using local information and try the command later. This
response code only makes sense when returned in a NO/BYE response.
ACTIVE
A command failed because it is not allowed on the active script, for
example, DELETESCRIPT on the active script. This response code only
makes sense when returned in a NO/BYE response.
NONEXISTENT
A command failed because the referenced script name doesn't exist.
This response code only makes sense when returned in a NO/BYE
response.
ALREADYEXISTS
A command failed because the referenced script name already exists.
This response code only makes sense when returned in a NO/BYE
response.
Melnikov & Martin Standards Track [Page 5]
RFC 5804 ManageSieve July 2010
TAG
This response code name is followed by a string specified in the
command. See Section 2.13 for a possible use case.
WARNINGS
This response code MAY be returned by the server in the OK response
(but it might be returned with the NO/BYE response as well) and
signals the client that even though the script is syntactically
valid, it might contain errors not intended by the script writer.
This response code is typically returned in response to PUTSCRIPT
and/or CHECKSCRIPT commands. A client seeing such response code
SHOULD present the returned warning text to the user.
1.4. Active Script
A user may have multiple Sieve scripts on the server, yet only one
script may be used for filtering of incoming messages. This is the
active script. Users may have zero or one active script and MUST use
the SETACTIVE command described below for changing the active script
or disabling Sieve processing. For example, users may have an
everyday script they normally use and a special script they use when
they go on vacation. Users can change which script is being used
without having to download and upload a script stored somewhere else.
1.5. Quotas
Servers SHOULD impose quotas to prevent malicious users from
overflowing available storage. If a command would place a user over
a quota setting, servers that impose such quotas MUST reply with a NO
response containing the QUOTA response code. Client implementations
MUST be able to handle commands failing because of quota
restrictions.
1.6. Script Names
A Sieve script name is a sequence of Unicode characters encoded in
UTF-8 [UTF-8]. A script name MUST comply with Net-Unicode Definition
(Section 2 of [NET-UNICODE]), with the additional restriction of
prohibiting the following Unicode characters:
o 0000-001F; [CONTROL CHARACTERS]
o 007F; DELETE
o 0080-009F; [CONTROL CHARACTERS]
Melnikov & Martin Standards Track [Page 6]
RFC 5804 ManageSieve July 2010
o 2028; LINE SEPARATOR
o 2029; PARAGRAPH SEPARATOR
Sieve script names MUST be at least one octet (and hence Unicode
character) long. Zero octets script name has a special meaning (see
Section 2.8). Servers MUST allow names of up to 128 Unicode
characters in length (which can take up to 512 bytes when encoded in
UTF-8, not counting the terminating NUL), and MAY allow longer names.
A server that receives a script name longer than its internal limit
MUST reject the corresponding operation, in particular it MUST NOT
truncate the script name.
1.7. Capabilities
Server capabilities are sent automatically by the server upon a
client connection, or after successful STARTTLS and AUTHENTICATE
(which establishes a Simple Authentication and Security Layer (SASL))
commands. Capabilities may change immediately after a successfully
completed STARTTLS command, and/or immediately after a successfully
completed AUTHENTICATE command, and/or after a successfully completed
UNAUTHENTICATE command (see Section 2.14.1). Capabilities MUST
remain static at all other times.
Clients MAY request the capabilities at a later time by issuing the
CAPABILITY command described later. The capabilities consist of a
series of lines each with one or two strings. The first string is
the name of the capability, which is case-insensitive. The second
optional string is the value associated with that capability. Order
of capabilities is arbitrary, but each capability name can appear at
most once.
The following capabilities are defined in this document:
IMPLEMENTATION - Name of implementation and version. This capability
MUST always be returned by the server.
SASL - List of SASL mechanisms supported by the server, each
separated by a space. This list can be empty if and only if STARTTLS
is also advertised. This means that the client must negotiate TLS
encryption with STARTTLS first, at which point the SASL capability
will list a non-empty list of SASL mechanisms.
SIEVE - List of space-separated Sieve extensions (as listed in Sieve
"require" action [SIEVE]) supported by the Sieve engine. This
capability MUST always be returned by the server.
Melnikov & Martin Standards Track [Page 7]
RFC 5804 ManageSieve July 2010
STARTTLS - If TLS [TLS] is supported by this implementation. Before
advertising this capability a server MUST verify to the best of its
ability that TLS can be successfully negotiated by a client with
common cipher suites. Specifically, a server should verify that a
server certificate has been installed and that the TLS subsystem has
successfully initialized. This capability SHOULD NOT be advertised
once STARTTLS or AUTHENTICATE command completes successfully. Client
and server implementations MUST implement the STARTTLS extension.
MAXREDIRECTS - Specifies the limit on the number of Sieve "redirect"
actions a script can perform during a single evaluation. Note that
this is different from the total number of "redirect" actions a
script can contain. The value is a non-negative number represented
as a ManageSieve string.
NOTIFY - A space-separated list of URI schema parts for supported
notification methods. This capability MUST be specified if the Sieve
implementation supports the "enotify" extension [NOTIFY].
LANGUAGE - The language (<Language-Tag> from [RFC5646]) currently
used for human-readable error messages. If this capability is not
returned, the "i-default" [RFC2277] language is assumed. Note that
the current language MAY be per-user configurable (i.e., it MAY
change after authentication).
OWNER - The canonical name of the logged-in user (SASL "authorization
identity") encoded in UTF-8. This capability MUST NOT be returned in
unauthenticated state and SHOULD be returned once the AUTHENTICATE
command succeeds.
VERSION - This capability MUST be returned by servers compliant with
this document or its successor. For servers compliant with this
document, the capability value is the string "1.0". Lack of this
capability means that the server predates this specification and thus
doesn't support the following commands: RENAMESCRIPT, CHECKSCRIPT,
and NOOP.
Section 2.14 defines some additional ManageSieve extensions and their
respective capabilities.
A server implementation MUST return SIEVE, IMPLEMENTATION, and
VERSION capabilities.
A client implementation MUST ignore any listed capabilities that it
does not understand.
Melnikov & Martin Standards Track [Page 8]
RFC 5804 ManageSieve July 2010
Example:
S: "IMPlemENTATION" "Example1 ManageSieved v001"
S: "SASl" "DIGEST-MD5 GSSAPI"
S: "SIeVE" "fileinto vacation"
S: "StaRTTLS"
S: "NOTIFY" "xmpp mailto"
S: "MAXREdIRECTS" "5"
S: "VERSION" "1.0"
S: OK
After successful authentication, this might look like this:
Example:
S: "IMPlemENTATION" "Example1 ManageSieved v001"
S: "SASl" "DIGEST-MD5 GSSAPI"
S: "SIeVE" "fileinto vacation"
S: "NOTIFY" "xmpp mailto"
S: "OWNER" "[email protected]"
S: "MAXREdIRECTS" "5"
S: "VERSION" "1.0"
S: OK
1.8. Transport
The ManageSieve protocol assumes a reliable data stream such as that
provided by TCP. When TCP is used, a ManageSieve server typically
listens on port 4190.
Before opening the TCP connection, the ManageSieve client first MUST
resolve the Domain Name System (DNS) hostname associated with the
receiving entity and determine the appropriate TCP port for
communication with the receiving entity. The process is as follows:
1. Attempt to resolve the hostname using a [DNS-SRV] Service of
"sieve" and a Proto of "tcp" for the target domain (e.g.,
"example.net"), resulting in resource records such as
"_sieve._tcp.example.net.". The result of the SRV lookup, if
successful, will be one or more combinations of a port and
hostname; the ManageSieve client MUST resolve the returned
hostnames to IPv4/IPv6 addresses according to returned SRV record
weight. IP addresses from the first successfully resolved
hostname (with the corresponding port number returned by SRV
lookup) are used to connect to the server. If connection using
one of the IP addresses fails, the next resolved IP address is
Melnikov & Martin Standards Track [Page 9]
RFC 5804 ManageSieve July 2010
used to connect. If connection to all resolved IP addresses
fails, then the resolution/connect is repeated for the next
hostname returned by SRV lookup.
2. If the SRV lookup fails, the fallback SHOULD be a normal IPv4 or
IPv6 address record resolution to determine the IP address, where
the port used is the default ManageSieve port of 4190.
1.9. Conventions Used in This Document
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [KEYWORDS].
In examples, "C:" and "S:" indicate lines sent by the client and
server respectively. Line breaks that do not start a new "C:" or
"S:" exist for editorial reasons.
Examples of authentication in this document are using DIGEST-MD5
[DIGEST-MD5] and GSSAPI [GSSAPI] SASL mechanisms.
2. Commands
This section and its subsections describe valid ManageSieve commands.
Upon initial connection to the server, the client's session is in
non-authenticated state. Prior to successful authentication, only
the AUTHENTICATE, CAPABILITY, STARTTLS, LOGOUT, and NOOP (see Section
2.13) commands are valid. ManageSieve extensions MAY define other
commands that are valid in non-authenticated state. Servers MUST
reject all other commands with a NO response. Clients may pipeline
commands (send more than one command at a time without waiting for
completion of the first command). However, a group of commands sent
together MUST NOT have an AUTHENTICATE (*), a STARTTLS, or a
HAVESPACE command anywhere but the last command in the list.
(*) - The only exception to this rule is when the AUTHENTICATE
command contains an initial response for a SASL mechanism that allows
clients to send data first, the mechanism is known to complete in one
round trip, and the mechanism doesn't negotiate a SASL security
layer. Two examples of such SASL mechanisms are PLAIN [PLAIN] and
EXTERNAL [SASL].
Melnikov & Martin Standards Track [Page 10]
RFC 5804 ManageSieve July 2010
2.1. AUTHENTICATE Command
Arguments: String - mechanism
String - initial data (optional)
The AUTHENTICATE command indicates a SASL [SASL] authentication
mechanism to the server. If the server supports the requested
authentication mechanism, it performs an authentication protocol
exchange to identify and authenticate the user. Optionally, it also
negotiates a security layer for subsequent protocol interactions. If
the requested authentication mechanism is not supported, the server
rejects the AUTHENTICATE command by sending the NO response.
The authentication protocol exchange consists of a series of server
challenges and client responses that are specific to the selected
authentication mechanism. A server challenge consists of a string
(quoted or literal) followed by a CRLF. The contents of the string
is a base-64 encoding [BASE64] of the SASL data. A client response
consists of a string (quoted or literal) with the base-64 encoding of
the SASL data followed by a CRLF. If the client wishes to cancel the
authentication exchange, it issues a string containing a single "*".
If the server receives such a response, it MUST reject the
AUTHENTICATE command by sending a NO reply.
Note that an empty challenge/response is sent as an empty string. If
the mechanism dictates that the final response is sent by the server,
this data MAY be placed within the data portion of the SASL response
code to save a round trip.
The optional initial-response argument to the AUTHENTICATE command is
used to save a round trip when using authentication mechanisms that
are defined to send no data in the initial challenge. When the
initial-response argument is used with such a mechanism, the initial
empty challenge is not sent to the client and the server uses the
data in the initial-response argument as if it were sent in response
to the empty challenge. If the initial-response argument to the
AUTHENTICATE command is used with a mechanism that sends data in the
initial challenge, the server MUST reject the AUTHENTICATE command by
sending the NO response.
The service name specified by this protocol's profile of SASL is
"sieve".
Reauthentication is not supported by ManageSieve protocol's profile
of SASL. That is, after a successfully completed AUTHENTICATE
command, no more AUTHENTICATE commands may be issued in the same
session. After a successful AUTHENTICATE command completes, a server
MUST reject any further AUTHENTICATE commands with a NO reply.
Melnikov & Martin Standards Track [Page 11]
RFC 5804 ManageSieve July 2010
However, note that a server may implement the UNAUTHENTICATE
extension described in Section 2.14.1.
If a security layer is negotiated through the SASL authentication
exchange, it takes effect immediately following the CRLF that
concludes the successful authentication exchange for the client, and
the CRLF of the OK response for the server.
When a security layer takes effect, the ManageSieve protocol is reset
to the initial state (the state in ManageSieve after a client has
connected to the server). The server MUST discard any knowledge
obtained from the client that was not obtained from the SASL (or TLS)
negotiation itself. Likewise, the client MUST discard any knowledge
obtained from the server, such as the list of ManageSieve extensions,
that was not obtained from the SASL (and/or TLS) negotiation itself.
(Note that a client MAY compare the advertised SASL mechanisms before
and after authentication in order to detect an active down-
negotiation attack. See below.)
Once a SASL security layer is established, the server MUST re-issue
the capability results, followed by an OK response. This is
necessary to protect against man-in-the-middle attacks that alter the
capabilities list prior to SASL negotiation. The capability results
MUST include all SASL mechanisms the server was capable of
negotiating with that client. This is done in order to allow the
client to detect an active down-negotiation attack. If a user-
oriented client detects such a down-negotiation attack, it SHOULD
either notify the user (it MAY give the user the opportunity to
continue with the ManageSieve session in this case) or close the
transport connection and indicate that a down-negotiation attack
might be in progress. If an automated client detects a down-
negotiation attack, it SHOULD return or log an error indicating that
a possible attack might be in progress and/or SHOULD close the
transport connection.
When both [TLS] and SASL security layers are in effect, the TLS
encoding MUST be applied (when sending data) after the SASL encoding.
Server implementations SHOULD support SASL proxy authentication so
that an administrator can administer a user's scripts. Proxy
authentication is when a user authenticates as herself/himself but
requests the server to act (authorize) as another user.
The authorization identity generated by this [SASL] exchange is a
"simple username" (in the sense defined in [SASLprep]), and both
client and server MUST use the [SASLprep] profile of the [StringPrep]
algorithm to prepare these names for transmission or comparison. If
preparation of the authorization identity fails or results in an
Melnikov & Martin Standards Track [Page 12]
RFC 5804 ManageSieve July 2010
empty string (unless it was transmitted as the empty string), the
server MUST fail the authentication.
If an AUTHENTICATE command fails with a NO response, the client MAY
try another authentication mechanism by issuing another AUTHENTICATE
command. In other words, the client may request authentication types
in decreasing order of preference.
Note that a failed (NO) response to the AUTHENTICATE command may
contain one of the following response codes: AUTH-TOO-WEAK, ENCRYPT-
NEEDED, or TRANSITION-NEEDED. See Section 1.3 for detailed
description of the relevant conditions.
To ensure interoperability, both client and server implementations of
the ManageSieve protocol MUST implement the SCRAM-SHA-1 [SCRAM] SASL
mechanism, as well as [PLAIN] over [TLS].
Note: use of PLAIN over TLS reflects current use of PLAIN over TLS in
other email-related protocols; however, a longer-term goal is to
migrate email-related protocols from using PLAIN over TLS to SCRAM-
SHA-1 mechanism.
Examples (Note that long lines are folded for readability and are not
part of protocol exchange):
S: "IMPLEMENTATION" "Example1 ManageSieved v001"
S: "SASL" "DIGEST-MD5 GSSAPI"
S: "SIEVE" "fileinto vacation"
S: "STARTTLS"
S: "VERSION" "1.0"
S: OK
C: Authenticate "DIGEST-MD5"
S: "cmVhbG09ImVsd29vZC5pbm5vc29mdC5leGFtcGxlLmNvbSIsbm9uY2U9Ik
9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgiLGFsZ29yaXRobT1tZDUtc2Vz
cyxjaGFyc2V0PXV0Zi04"
C: "Y2hhcnNldD11dGYtOCx1c2VybmFtZT0iY2hyaXMiLHJlYWxtPSJlbHdvb2
QuaW5ub3NvZnQuZXhhbXBsZS5jb20iLG5vbmNlPSJPQTZNRzl0RVFHbTJo
aCIsbmM9MDAwMDAwMDEsY25vbmNlPSJPQTZNSFhoNlZxVHJSayIsZGlnZX
N0LXVyaT0ic2lldmUvZWx3b29kLmlubm9zb2Z0LmV4YW1wbGUuY29tIixy
ZXNwb25zZT1kMzg4ZGFkOTBkNGJiZDc2MGExNTIzMjFmMjE0M2FmNyxxb3
A9YXV0aA=="
S: OK (SASL "cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZ
mZmZA==")
Melnikov & Martin Standards Track [Page 13]
RFC 5804 ManageSieve July 2010
A slightly different variant of the same authentication exchange is:
S: "IMPLEMENTATION" "Example1 ManageSieved v001"
S: "SASL" "DIGEST-MD5 GSSAPI"
S: "SIEVE" "fileinto vacation"
S: "VERSION" "1.0"
S: "STARTTLS"
S: OK
C: Authenticate "DIGEST-MD5"
S: {136}
S: cmVhbG09ImVsd29vZC5pbm5vc29mdC5leGFtcGxlLmNvbSIsbm9uY2U9Ik
9BNk1HOXRFUUdtMmhoIixxb3A9ImF1dGgiLGFsZ29yaXRobT1tZDUtc2Vz
cyxjaGFyc2V0PXV0Zi04
C: {300+}
C: Y2hhcnNldD11dGYtOCx1c2VybmFtZT0iY2hyaXMiLHJlYWxtPSJlbHdvb2
QuaW5ub3NvZnQuZXhhbXBsZS5jb20iLG5vbmNlPSJPQTZNRzl0RVFHbTJo
aCIsbmM9MDAwMDAwMDEsY25vbmNlPSJPQTZNSFhoNlZxVHJSayIsZGlnZX
N0LXVyaT0ic2lldmUvZWx3b29kLmlubm9zb2Z0LmV4YW1wbGUuY29tIixy
ZXNwb25zZT1kMzg4ZGFkOTBkNGJiZDc2MGExNTIzMjFmMjE0M2FmNyxxb3
A9YXV0aA==
S: {56}
S: cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZA==
C: ""
S: OK
Melnikov & Martin Standards Track [Page 14]
RFC 5804 ManageSieve July 2010
Another example demonstrating use of SASL PLAIN mechanism under TLS
follows. This example also demonstrate use of SASL "initial
response" (the second parameter to the Authenticate command):
S: "IMPLEMENTATION" "Example1 ManageSieved v001"
S: "VERSION" "1.0"
S: "SASL" ""
S: "SIEVE" "fileinto vacation"
S: "STARTTLS"
S: OK
C: STARTTLS
S: OK
<TLS negotiation, further commands are under TLS layer>
S: "IMPLEMENTATION" "Example1 ManageSieved v001"
S: "VERSION" "1.0"
S: "SASL" "PLAIN"
S: "SIEVE" "fileinto vacation"
S: OK
C: Authenticate "PLAIN" "QJIrweAPyo6Q1T9xu"
S: NO
C: Authenticate "PLAIN" "QJIrweAPyo6Q1T9xz"
S: NO
C: Authenticate "PLAIN" "QJIrweAPyo6Q1T9xy"
S: BYE "Too many failed authentication attempts"
<Server closes connection>
Melnikov & Martin Standards Track [Page 15]
RFC 5804 ManageSieve July 2010
The following example demonstrates use of SASL "initial response".
It also demonstrates that an empty response can be sent as a literal
and that negotiating a SASL security layer results in the server
re-issuing server capabilities:
C: AUTHENTICATE "GSSAPI" {1488+}
C: YIIE[...1480 octets here ...]dA==
S: {208}
S: YIGZBgkqhkiG9xIBAgICAG+BiTCBhqADAgEFoQMCAQ+iejB4oAMCARKic
[...114 octets here ...]
/yzpAy9p+Y0LanLskOTvMc0MnjgAa4YEr3eJ6
C: {0+}
C:
S: {44}
S: BQQF/wAMAAwAAAAAYRGFAo6W0vIHti8i1UXODgEAEAA=
C: {44+}
C: BQQE/wAMAAwAAAAAIsT1iv9UkZApw471iXt6cwEAAAE=
S: OK
<Further commands/responses are under SASL security layer>
S: "IMPLEMENTATION" "Example1 ManageSieved v001"
S: "VERSION" "1.0"
S: "SASL" "PLAIN DIGEST-MD5 GSSAPI"
S: "SIEVE" "fileinto vacation"
S: "LANGUAGE" "ru"
S: "MAXREDIRECTS" "3"
S: ok
2.1.1. Use of SASL PLAIN Mechanism over TLS
This section is normative for ManageSieve client implementations that
support SASL [PLAIN] over [TLS].
If a ManageSieve client is willing to use SASL PLAIN over TLS to
authenticate to the ManageSieve server, the client MUST verify the
server identity (see Section 2.2.1). If the server identity can't be
verified (e.g., the server has not provided any certificate, or if
the certificate verification fails), the client MUST NOT attempt to
authenticate using the SASL PLAIN mechanism.
2.2. STARTTLS Command
Support for STARTTLS command in servers is optional. Its
availability is advertised with "STARTTLS" capability as described in
Section 1.7.
The STARTTLS command requests commencement of a TLS [TLS]
negotiation. The negotiation begins immediately after the CRLF in
the OK response. After a client issues a STARTTLS command, it MUST
Melnikov & Martin Standards Track [Page 16]
RFC 5804 ManageSieve July 2010
NOT issue further commands until a server response is seen and the
TLS negotiation is complete.
The STARTTLS command is only valid in non-authenticated state. The
server remains in non-authenticated state, even if client credentials
are supplied during the TLS negotiation. The SASL [SASL] EXTERNAL
mechanism MAY be used to authenticate once TLS client credentials are
successfully exchanged, but servers supporting the STARTTLS command
are not required to support the EXTERNAL mechanism.
After the TLS layer is established, the server MUST re-issue the
capability results, followed by an OK response. This is necessary to
protect against man-in-the-middle attacks that alter the capabilities
list prior to STARTTLS. This capability result MUST NOT include the
STARTTLS capability.
The client MUST discard cached capability information and replace it
with the new information. The server MAY advertise different
capabilities after STARTTLS.
Example:
C: StartTls
S: oK
<TLS negotiation, further commands are under TLS layer>
S: "IMPLEMENTATION" "Example1 ManageSieved v001"
S: "SASL" "PLAIN DIGEST-MD5 GSSAPI"
S: "SIEVE" "fileinto vacation"
S: "VERSION" "1.0"
S: "LANGUAGE" "fr"
S: ok
2.2.1. Server Identity Check
During the TLS negotiation, the ManageSieve client MUST check its
understanding of the server hostname/IP address against the server's
identity as presented in the server Certificate message, in order to
prevent man-in-the-middle attacks. In this section, the client's
understanding of the server's identity is called the "reference
identity".
Checking is performed according to the following rules:
o If the reference identity is a hostname:
1. If a subjectAltName extension of the SRVName [X509-SRV],
dNSName [X509] (in that order of preference) type is present
in the server's certificate, then it SHOULD be used as the
Melnikov & Martin Standards Track [Page 17]
RFC 5804 ManageSieve July 2010
source of the server's identity. Matching is performed as
described in Section 2.2.1.1, with the exception that no
wildcard matching is allowed for SRVName type. If the
certificate contains multiple names (e.g., more than one
dNSName field), then a match with any one of the fields is
considered acceptable.
2. The client MAY use other types of subjectAltName for
performing comparison.
3. The server's identity MAY also be verified by comparing the
reference identity to the Common Name (CN) [RFC4519] value in
the leaf Relative Distinguished Name (RDN) of the subjectName
field of the server's certificate. This comparison is
performed using the rules for comparison of DNS names in
Section 2.2.1.1, below. Although the use of the Common Name
value is existing practice, it is deprecated, and
Certification Authorities are encouraged to provide
subjectAltName values instead. Note that the TLS
implementation may represent DNs in certificates according to
X.500 or other conventions. For example, some X.500
implementations order the RDNs in a DN using a left-to-right
(most significant to least significant) convention instead of
LDAP's right-to-left convention.
o When the reference identity is an IP address, the iPAddress
subjectAltName SHOULD be used by the client for comparison. The
comparison is performed as described in Section 2.2.1.2.
If the server identity check fails, user-oriented clients SHOULD
either notify the user (clients MAY give the user the opportunity to
continue with the ManageSieve session in this case) or close the
transport connection and indicate that the server's identity is
suspect. Automated clients SHOULD return or log an error indicating
that the server's identity is suspect and/or SHOULD close the
transport connection. Automated clients MAY provide a configuration
setting that disables this check, but MUST provide a setting that
enables it.
Beyond the server identity check described in this section, clients
should be prepared to do further checking to ensure that the server
is authorized to provide the service it is requested to provide. The