Network Working Group Jutta Degener Internet Draft Sendmail, Inc. Expires: July 2004 January 2004 Sieve -- "editheader" extension Status of this memo This document is an Internet-Draft and is subject to all provisions of Section 10 of RFC2026. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet-Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet- Drafts as reference material or to cite them other than as "work in progress." The list of current Internet-Drafts can be accessed at http://www.ietf.org/1id-abstracts.html The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html Abstract This document defines two new actions for the "sieve" language that add and delete e-mail header fields. 1. Introduction Email headers are a flexible and easy to understand means of communication between email processors. This extension enables sieve scripts to interact with other components that consume or produce header fields by allowing the script to delete and add header fields. 2. Conventions used. Conventions for notations are as in [SIEVE] section 1.1, including use of [KEYWORDS] and "Syntax:" label for the definition of action and tagged arguments syntax. The term "header field" is used here as in [RFC-2822] to mean a logical line of an e-mail message header. The capability string associated with extension defined in this document is "editheader". 3. Action addheader Syntax: "addheader" [":last"] The addheader action adds a header field to the existing message header. The name MUST be a valid 7-bit US-ASCII header field name as described by [RFC-2822] "field-name" nonterminal. If the specified field value does not match the RFC 2822 "unstructured" nonterminal or exceeds a length limit set by the implementation, the implementation MUST either flag an error or encode the field using folding white space and the encodings described in RFC 2047 or RFC 2231 to be compliant with RFC 2822. An implementation MAY impose a length limit onto the size of the encoded header field; such a limit MUST NOT be less than 998 characters, not including the terminating CRLF supplied by the implementation. By default, the header field is inserted at the beginning of the existing header. If the optional flag ":last" is specified, it is appended at the end. Example: /* Don't redirect if we already redirected */ if not header :contains "X-Sieve-Filtered" ["", ""] { addheader "X-Sieve-Filtered" ""; redirect "kim@home.tld"; } 4. Action deleteheader Syntax: "deleteheader" [":index" [":last"]] [COMPARATOR] [MATCH-TYPE] [] By default, the deleteheader action deletes all occurrences of the named header field. The field-name is mandatory and always matched as a case-insensitive us-ascii string. The value-patterns, if specified, are matched according to the match type and comparator. If none are specified, all values match. The field-name MUST be a valid 7-bit header field name as described by the [RFC-2822] "field-name" nonterminal. If :index is specified, the attempts to match a value are limited to the header field (beginning at 1, the first named header field). If :last is specified, the count is backwards; 1 denotes the last named header field, 2 the second to last, and so on. The counting happens before the match, if any; deleteheader :index 2 :contains "Received" "via carrier-pidgeon" deletes the second "Received:" header field if it contains the string "via carrier-pidgeon" (not the second Received: field that contains "via carrier-pidgeon"). 5. Interaction with Other Sieve Extensions Tests and actions such as "exist" or "header" that examine header fields MUST examine the current state of a header as modified by any actions that have taken place so far. As an example, the "header" test in the following fragment will always evaluate to true, regardless of whether the incoming message contained an "X-Hello" header field or not: addheader "X-Hello" "World"; if header :contains "X-Hello" "World" { fileinto "Hi"; } Actions that create messages in storage or in transport to MTAs MUST store and send messages with the current set of header fields. A message modified by addheader or deleteheader MUST NOT be considered the same as the original message unless it matches the original message exactly. For example, the following code fragment keep; addheader "X-Flavor: vanilla" keep; files two messages, not one. The "implicit keep" is thought to be executed at the end of the script, after the headers have been modified. 6. Security Considerations Someone with write access to a user's script storage may use this extension to generate headers that a user would otherwise be shielded from (by a gateway MTA that removes them). A sieve filter that removes headers may unwisely destroy evidence about the path a header has taken. Any change in a message content may interfere with digital signature mechanisms that include the header in the signed material. Any decision mechanism in a user's filter that is based on headers is vulnerable to header spoofing. For example, if the user adds an APPROVED header or tag, a malicious sender may add that tag or header themselves. One way to guard against this is to delete or rename any such headers or stamps prior to processing the message. 7. Acknowledgments Thanks to Eric Allman, Ned Freed, Philip Guenther, Simon Josefsson, Will Lee, Chris Markle, Randall Schwartz, Kjetil Torgrim Homme, and Rand Wacker for extensive corrections and suggestions. 8. Author's Address Jutta Degener Sendmail, Inc. 6425 Christie Ave, 4th Floor Emeryville, CA 94608 Email: jutta@sendmail.com 9. Discussion This section will be removed when this document leaves the Internet-Draft stage. This draft is intended as an extension to the Sieve mail filtering language. Sieve extensions are discussed on the MTA Filters mailing list at . Subscription requests can be sent to (send an email message with the word "subscribe" in the body). More information on the mailing list along with a WWW archive of back messages is available at . 9.1 Changes from the previous version Removed "replaceheader" action and reference to variables. Expanded discussion of interactions with existing sieve primitives. Referenced RFC 2822's definition of "header field". Changed insertion position default to beginning of header, and added :last parameter to restore the original default. Appendices Appendix A. References [RFC-2822] Resnick, P., "Internet Message Format", RFC 2822, April 2001. [SIEVE] Showalter, T., "Sieve: A Mail Filtering Language", RFC 3028, January 2001. [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", RFC 2119, March 1997. Appendix B. Full Copyright Statement Copyright (C) The Internet Society 2004. All Rights Reserved. This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this paragraph are included on all such copies and derivative works. However, this document itself may not be modified in any way, such as by removing the copyright notice or references to the Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English. The limited permissions granted above are perpetual and will not be revoked by the Internet Society or its successors or assigns. This document and the information contained herein is provided on an "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.