<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>shapeshifter.se &#187; postfix</title>
	<atom:link href="http://www.shapeshifter.se/tag/postfix/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shapeshifter.se</link>
	<description>Mostly miscellaneous technical mumbo-jumbo.</description>
	<lastBuildDate>Mon, 11 Jul 2011 14:19:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Obscuring SMTP auth headers &#8211; with IPv6</title>
		<link>http://www.shapeshifter.se/2008/12/10/obscuring-smtp-auth-headers-with-ipv6/</link>
		<comments>http://www.shapeshifter.se/2008/12/10/obscuring-smtp-auth-headers-with-ipv6/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 16:01:19 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[IPv6]]></category>
		<category><![CDATA[postfix]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/?p=410</guid>
		<description><![CDATA[
The FreeBSD Diary and Riseup labs describe a way to anonymize the first &#8220;received from&#8221; header with usually contain the IP-address of the computer the mail was sent from.  This information is removed by taking advantage of the &#8220;Authenticated sender&#8221; and the header_checks directive in Postfix.
The &#8220;Authenticated sender&#8221; is added when a user has been [...]]]></description>
			<content:encoded><![CDATA[<p><!-- WSA: rules for context 'adsense-post-top' did not apply --><br />
The <a href="http://www.freebsddiary.org/smtp-headers-rewrite-auth.php">FreeBSD Diary</a> and <a href="http://riseuplabs.org/privacy/postfix/">Riseup labs</a> describe a way to anonymize the first &#8220;received from&#8221; header with usually contain the IP-address of the computer the mail was sent from.  This information is removed by taking advantage of the &#8220;Authenticated sender&#8221; and the header_checks directive in Postfix.</p>
<p>The &#8220;Authenticated sender&#8221; is added when a user has been authenticated by the MTA through SASL and the directive smtpd_sasl_authenticated_header have been set to yes.  The header_checks directive takes a file containing a regular expression which rewrites the header data and removes sensitive information.</p>
<p>This all works well &#8211; with IPv4. The regular expression posted on the pages mentioned above does not take IPv6 addresses into account, I modified it slightly to accept both IPv4 and IPv6 addresses.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #339933;">/^</span>Received<span style="color: #339933;">:</span> from <span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span> \<span style="color: #009900;">&#40;</span>\<span style="color: #009900;">&#91;</span><span style="color: #339933;">?</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">-.</span>_<span style="color: #009900;">&#91;</span><span style="color: #339933;">:</span>alnum<span style="color: #339933;">:</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span>\<span style="color: #009900;">&#93;</span><span style="color: #339933;">?</span> \<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>\<span style="color: #339933;">.</span>0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">15</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">|</span>IPv6<span style="color: #009900;">&#91;</span>\<span style="color: #339933;">:</span>a<span style="color: #339933;">-</span>fA<span style="color: #339933;">-</span>F0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span>\<span style="color: #009900;">&#93;</span>\<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span>
\<span style="color: #009900;">&#40;</span>Authenticated sender<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">^</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span>\<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>by mx1\<span style="color: #339933;">.</span>example\<span style="color: #339933;">.</span>com<span style="color: #009900;">&#41;</span> \<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">^</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span>\<span style="color: #009900;">&#41;</span> with <span style="color: #009900;">&#40;</span>E<span style="color: #339933;">?</span>SMTPS<span style="color: #339933;">?</span>A<span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span> id
 <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>A<span style="color: #339933;">-</span>F<span style="color: #009900;">&#91;</span><span style="color: #339933;">:</span>digit<span style="color: #339933;">:</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span> REPLACE Received<span style="color: #339933;">:</span> from smtp<span style="color: #339933;">-</span>auth<span style="color: #339933;">.</span>example<span style="color: #339933;">.</span>com <span style="color: #009900;">&#40;</span>smtp<span style="color: #339933;">-</span>auth<span style="color: #339933;">.</span>example<span style="color: #339933;">.</span>com
 <span style="color: #009900;">&#91;</span>127<span style="color: #339933;">.</span>0<span style="color: #339933;">.</span>0<span style="color: #339933;">.</span>1<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>Authenticated sender<span style="color: #339933;">:</span> hidden<span style="color: #009900;">&#41;</span><span style="color: #0000ff;">$5</span><span style="color: #0000ff;">$6</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$7</span><span style="color: #009900;">&#41;</span> with <span style="color: #0000ff;">$8</span> id <span style="color: #0000ff;">$9</span> <span style="color: #0000ff;">$10</span></pre></div></div>

<p>Note that this should be one single line.</p>
<p>Put this in a file, for example /usr/local/etc/postfix/obscure_smtp_auth and add the following to your Postfix configuration (assuming you have SASL working).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">header_checks <span style="color: #339933;">=</span> pcre<span style="color: #339933;">:/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>postfix<span style="color: #339933;">/</span>obscure_smtp_auth
smtpd_sasl_authenticated_header <span style="color: #339933;">=</span> yes</pre></div></div>

<p>The first header will now be rewritten, for both IPv4 and IPv6 clients and will look something like this.</p>
<pre>
Received: from smtp-auth.example.com (smtp-auth.example.com [127.0.0.1]) 127.0.0.1 (Authenticated sender: hidden)
	by mx1.example.com (Postfix) with ESMTPSA id 3677033C6F
	for &#038;lthostmaster@example.se&gt;; Wed, 10 Dec 2008 16:31:51 +0100 (CET)
</pre>
<p>instead of</p>
<pre>
Received: from [IPv6:2001:xxxx:xxxx:xxxx:xxxx:xxxx:fedd:7914] (unknown [IPv6:2001:xxxx:xxxx:xxxx:xxxx:xxxx::fedd:7914])
	(Authenticated sender: someuser@example.com)
	by mx1.example.com (Postfix) with ESMTPSA id 3677033C6F
	for  &#038;lthostmaster@example.se&gt;;  Wed, 10 Dec 2008 16:31:51 +0100 (CET)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2008/12/10/obscuring-smtp-auth-headers-with-ipv6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

