Mailing List Archive

Dovecot pidgeonhole transport untaint $sender
Morning all.

How do I untaint $sender?

On my personal server I am trying to install sieve like services using
dovecot-pidgeonhole.

I have amended my localuser router and created a transport
dovecot_delivery - see below

The instructions were taken from https://wiki.dovecot.org/LDA/Exim

However, when I sent a test email I got the following log entries and
the email was rejected:

2023-05-10 21:28:56 1pwqQi-00057k-1N <= some.testuser@gmail.com
H=hub.ringways.co.uk (ringways.co.uk) [88.211.105.30] P=esmtps
X=TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256 CV=no K S=5388 DKIM=gmail.com
id=CA+GsGL6gvYJAuKmR8nTNGTkKZ8GTLxNhLSwkWivE3SxWnjaJsQ@mail.gmail.com
T="JATE 2128"
2023-05-10 21:28:56 Warning: purging the environment.
 Suggested action: use keep_environment.
2023-05-10 21:28:56 1pwqQi-00057k-1N ** some@testuser.com R=localuser
T=dovecot_delivery: Tainted arg 2 for dovecot_delivery transport
command: 'some.testuser@gmail.com'
2023-05-10 21:28:56 Warning: purging the environment.
 Suggested action: use keep_environment.
2023-05-10 21:28:57 1pwqQi-00057s-3C <= <> R=1pwqQi-00057k-1N U=exim
P=local S=6669 T="Mail delivery failed: returning message to sender"
2023-05-10 21:28:57 Warning: purging the environment.
 Suggested action: use keep_environment.
2023-05-10 21:28:57 1pwqQi-00057k-1N Completed

I know how to untaint $local_part and $domain using lookups, but I have
no idea how to untaint $sender.

localuser:
  debug_print = "R: local_user $local_part @ $domain"
  domains = +local_domains
  driver = accept
  condition = ${lookup pgsql{select lu_userID from local_user_details \
                       where lu_localpart = '${quote_pgsql:$local_part}' \
                        and domain='${quote_pgsql:$domain}'}}
  check_local_user

# amended 2023-05-10
# transport = local_delivery
  transport = dovecot_delivery


dovecot_delivery:
  driver = pipe

  # Use /usr/lib/dovecot/dovecot-lda  if using Debian's package.
  # You may or may not want to add -d $local_part@$domain depending on
if you need a userdb lookup done.
  command = /usr/local/libexec/dovecot/dovecot-lda -f $sender_address

  message_prefix =
  message_suffix =
  log_output
  delivery_date_add
  envelope_to_add
  return_path_add
  #group = mail
  #mode = 0660
  temp_errors = 64 : 69 : 70: 71 : 72 : 73 : 74 : 75 : 78



--

Kind regards

Gary Stainburn

*Group I.T. Manager - D.M.Keith Ford/Kia After-Sales*

*Switchboard* 0113 2634 222

*Address:* D.M.Keith Ford/Kia Aftersales | Hales Road | Leeds | LS12 4TG


/*Branches throughout Yorkshire and North Lincolnshire.*/

*Ford Leeds *0113 263 4222 | *Transit Centre Leeds* 0113 2634222 |
*Skoda Leeds* 0113 2771777 | *KiaLeeds* 0113426 8111 | *Kia Doncaster*
01302 384350 | *Skoda Bradford* 01274 741200 | *Skoda Wakefield* 01924
246900 | *Skoda Huddersfield*01484 435499 | *Skoda York* 01904 692921|
*SEAT York* 01904 692921 | *Cupra York* 01904 692921 | *Skoda Hull*
01482 802000 | *Skoda Grimsby* 01472 803 545 | *SEAT Grimsby* 01472 348
348 | *Honda Grimsby* 01472 358 625 | *SEAT MO* 01472 348 348 | *Trade
Car Outlet Ossett* 01924 255476 | *Ringways Hire & Leasing Ltd* 0344
4146789.

/This email message is confidential and may contain legally privileged
information. It may be monitored (whether you are the sender or
recipient) and recorded and retained by D.M.Keith Ltd, Ringways Garages
(Leeds) Ltd, Ringways Garages (Doncaster) Ltd, Ringways Hire & Leasing
Limited and or its other Group Companies. Under the “Lawful Business
Practices Interception of Communication Regulations 2000” email and
telephone monitoring and or recording software may be used, and email or
telephone call content may be reviewed at any time. If you are not the
intended recipient you should not read, copy, distribute, disclose or
otherwise use the information in this e-mail. Please also contact
D.M.Keith Ltd by emailing _privacy@dmkeith.com_ or fax us on 0113
2703641, immediately and delete the message from your system. Copyright
in this email belongs to D.M.Keith Ltd., ALL RIGHTS RESERVED. Whilst
every effort has been made to check for viruses, D.M.Keith Ltd and its
Group Companies does not warrant that it is free of viruses. E-mail may
be susceptible to data corruption, interception and unauthorised
amendment, and we do not accept liability for any such corruption,
interception or amendment or the consequences thereof. D.M. Keith Ltd is
registered under the Data Protection Act 1998 registration No. Z7389610,
Ringways Garages (Leeds) Ltd is registered under the Data Protection Act
1998 registration No. Z5414640 , Ringways Garages (Doncaster) Ltd is
registered under the Data Protection Act 1998 registration No. Z5414654.
D.M.Keith Limited and its other Group companies are an appointed
representative of ITC Compliance Limited which is authorised and
regulated by the Financial Conduct Authority (their registration number
is 313486). Permitted activities include advising on and arranging
general insurance contracts and acting as a credit broker not a lender.
We can introduce you to a limited number of finance providers. We do not
charge fees for our Consumer Credit services. We may receive a
payment(s) or other benefits from finance providers should you decide to
enter into an agreement with them, typically either a fixed fee or a
fixed percentage of the amount you borrow. The payment we receive may
vary between finance providers and product types. The payment received
does not impact the finance rate offered. All finance applications are
subject to status, terms and conditions apply, UK residents only, 18’s
or over, Guarantees may be required. D.M. Keith Ltd and its group
companies are as follows: - D M Keith Ltd, Company registration No.
00749256 Registered office, Thwaite Gate, Leeds, LS10 1DY. Ringways
Garages (Leeds) Ltd, Company registration No. 00543323 trading as D M
Keith Kia Leeds and D M Keith Ford Leeds Registered office, Whitehall
Road, Leeds, LS12 5NL. Ringways Garages (Doncaster) Ltd, Company
registration No. 00282527 trading as D M Keith Kia Doncaster. Registered
office, Whitehall Road, Leeds, LS12 5NL, Ringways (HIRE & LEASING) LTD,
company registration No. 00470274, Registered Office, Whitehall Road,
Leeds, LS12 5NL. All group companies VAT registration No. 169785889. All
goods and services are sold subject to our Conditions of Sale which can
be found along with our; Data Protection Policy, Security Policy,
Privacy & Cookie Policy, Anti-Slavery Human-Trafficking Statement, Job
Applicant Privacy Notice, Gender Pay Gap Statement, Treating Customers
Fairly Policy & FCA Status Disclosure. These can be found on the link
_https://www.dmkeith.com/website-privacy-and-legal-information_ E&O.E./



 

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
On 11/05/2023 09:31, Gary Stainburn via Exim-users wrote:
>   command = /usr/local/libexec/dovecot/dovecot-lda -f $sender_address

> How do I untaint $sender?

There's no principled way to do so (barring knowing all your possible
correspondents). And since you're using an external program, not part
of Exim, we can't know what security issues it might have with attacker-sourced
information.

Could you use LMTP to talk to Dovecot, rather than a command-line?
--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
Hello.

On Thu, May 11, 2023 at 09:31:49AM +0100, Gary Stainburn via Exim-users wrote:
> I know how to untaint $local_part and $domain using lookups, but I have no
> idea how to untaint $sender.
...
> dovecot_delivery:
> ? driver = pipe
>
> ? # Use /usr/lib/dovecot/dovecot-lda? if using Debian's package.
> ? # You may or may not want to add -d $local_part@$domain depending on if
> you need a userdb lookup done.
> ? command = /usr/local/libexec/dovecot/dovecot-lda -f $sender_address

What about proposal in 1st comment to strip out "-f $sender_address"?

IMHO, dovecot-lda doesn't need sender address. Unless sieve is used,
with explicit reference to sender address.
--
Eugene Berdnikov

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
On 11/05/2023 16:12, Evgeniy Berdnikov via Exim-users wrote:
> What about proposal in 1st comment to strip out "-f $sender_address"?
>
> IMHO, dovecot-lda doesn't need sender address. Unless sieve is used,
> with explicit reference to sender address.

I assumed the most likely use of something called "pidginhole"
was delivery to distinct folders, often by inspecting the sender.
But perhaps it can use the From: header?
--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
Am 11.05.23 um 17:25 schrieb Jeremy Harris via Exim-users:
> On 11/05/2023 16:12, Evgeniy Berdnikov via Exim-users wrote:
>>   What about proposal in 1st comment to strip out "-f $sender_address"?
>>
>>   IMHO, dovecot-lda doesn't need sender address. Unless sieve is used,
>>   with explicit reference to sender address.
>
> I assumed the most likely use of something called "pidginhole"
> was delivery to distinct folders, often by inspecting the sender.
> But perhaps it can use the From: header?

If I read the dovecot docs correctly, lda will use the From: header if
present and no -f <sender address> is given:

"-f <address>: Envelope sender address. If not specified and message
data begins with a valid mbox-style “From ” line, the address is taken
from it."
(https://doc.dovecot.org/configuration_manual/protocols/lda/)

However, pidginhole provides extensive sieve language support and you
can use almost any piece of an email to move, copy, filter, forward,
autoreply, etc.
(https://datatracker.ietf.org/doc/html/rfc5228)
(https://pigeonhole.dovecot.org/)

My guess is: Just removing the -f $sender_address just might change mail
processing for some people.

Martin

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
On 2023-05-11 at 11:39:50 UTC-0400 (Thu, 11 May 2023 17:39:50 +0200)
Martin Waschbüsch via Exim-users <martin@waschbuesch.de>
is rumored to have said:

> Am 11.05.23 um 17:25 schrieb Jeremy Harris via Exim-users:
>> On 11/05/2023 16:12, Evgeniy Berdnikov via Exim-users wrote:
>>>   What about proposal in 1st comment to strip out "-f
>>> $sender_address"?
>>>
>>>   IMHO, dovecot-lda doesn't need sender address. Unless sieve is
>>> used,
>>>   with explicit reference to sender address.
>>
>> I assumed the most likely use of something called "pidginhole"
>> was delivery to distinct folders, often by inspecting the sender.
>> But perhaps it can use the From: header?
>
> If I read the dovecot docs correctly, lda will use the From: header if
> present and no -f <sender address> is given:
>
> "-f <address>: Envelope sender address. If not specified and message
> data begins with a valid mbox-style “From ” line, the address is
> taken from it."
> (https://doc.dovecot.org/configuration_manual/protocols/lda/)

That's not the "From:" RFC5322 message header, it is the prepended "From
" (no colon) line that acts as a delimiter for mbox files. That's good,
because that line contains the envelope sender, which the "From:"
message header may not.

> However, pidginhole provides extensive sieve language support and you
> can use almost any piece of an email to move, copy, filter, forward,
> autoreply, etc.
> (https://datatracker.ietf.org/doc/html/rfc5228)
> (https://pigeonhole.dovecot.org/)
>
> My guess is: Just removing the -f $sender_address just might change
> mail processing for some people.

Provided Exim is properly adding the no-colon From line to messages that
it pipes into dovecot-lda, there should be no change.

--
Bill Cole
bill@scconsult.com or billcole@apache.org
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not Currently Available For Hire

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
Am 11.05.23 um 20:36 schrieb Bill Cole via Exim-users:
> On 2023-05-11 at 11:39:50 UTC-0400 (Thu, 11 May 2023 17:39:50 +0200)
> Martin Waschbüsch via Exim-users <martin@waschbuesch.de>
> is rumored to have said:
>
>> Am 11.05.23 um 17:25 schrieb Jeremy Harris via Exim-users:
>>> On 11/05/2023 16:12, Evgeniy Berdnikov via Exim-users wrote:
>>>>   What about proposal in 1st comment to strip out "-f $sender_address"?
>>>>
>>>>   IMHO, dovecot-lda doesn't need sender address. Unless sieve is used,
>>>>   with explicit reference to sender address.
>>>
>>> I assumed the most likely use of something called "pidginhole"
>>> was delivery to distinct folders, often by inspecting the sender.
>>> But perhaps it can use the From: header?
>>
>> If I read the dovecot docs correctly, lda will use the From: header if
>> present and no -f <sender address> is given:
>>
>> "-f <address>: Envelope sender address. If not specified and message
>> data begins with a valid mbox-style “From ” line, the address is taken
>> from it."
>> (https://doc.dovecot.org/configuration_manual/protocols/lda/)
>
> That's not the "From:" RFC5322 message header, it is the prepended "From
> " (no colon) line that acts as a delimiter for mbox files. That's good,
> because that line contains the envelope sender, which the "From:"
> message header may not.

Important difference. Thank you!

>> However, pidginhole provides extensive sieve language support and you
>> can use almost any piece of an email to move, copy, filter, forward,
>> autoreply, etc.
>> (https://datatracker.ietf.org/doc/html/rfc5228)
>> (https://pigeonhole.dovecot.org/)
>>
>> My guess is: Just removing the -f $sender_address just might change
>> mail processing for some people.
>
> Provided Exim is properly adding the no-colon From line to messages that
> it pipes into dovecot-lda, there should be no change.

Under what circumstances would exim add that line? Those lines are not
currently added on my setup.

(And I would assume for the purpose of the pipe transport, exim is not
adding anything that is storage-format format-specific?)

I could manually force such a line to be written using e.g.
message_prefix, I suppoe. Hm... Would that take us full circle and be
considered using tainted data? :-)

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
On 11/05/2023 20:32, Martin Waschbüsch via Exim-users wrote:
> Under what circumstances would exim add that line? Those lines are not currently added on my setup.

When writing an mbox-format file, done by the appendfile driver.
Which you're not using.


Did you look into the LMTP possibility?
--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
D?a 11. mája 2023 19:32:03 UTC používate? "Martin Waschbüsch via Exim-users" <exim-users@lists.exim.org> napísal:

>Under what circumstances would exim add that line? Those lines are not currently added on my setup.

See message_prefix pipe transport option, it is added by
default, if not defined

regards


--
Slavko
https://www.slavino.sk/

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
Am 11.05.23 um 21:54 schrieb Jeremy Harris via Exim-users:
> On 11/05/2023 20:32, Martin Waschbüsch via Exim-users wrote:
>> Under what circumstances would exim add that line? Those lines are not
>> currently added on my setup.
>
> When writing an mbox-format file, done by the appendfile driver.
> Which you're not using.
>
>
> Did you look into the LMTP possibility?

Not yet.
I will try LMTP and will give feedback once I have done so.

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
Am 11.05.23 um 21:54 schrieb Jeremy Harris via Exim-users:
> On 11/05/2023 20:32, Martin Waschbüsch via Exim-users wrote:
>> Under what circumstances would exim add that line? Those lines are not
>> currently added on my setup.
>
> When writing an mbox-format file, done by the appendfile driver.
> Which you're not using.
>
>
> Did you look into the LMTP possibility?

LMTP works for me. I had to redo some routing so that Mail identified as
Spam goes directly into the appropriate Mailbox (I used +Spam address
suffix and appropriate options on dovecot side for that)

And using LMTP over unix socket actually measurably reduces load by not
having to spwan a new dovecot-lda all the time. Added benefit! :-)

Thanks,

Martin

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Dovecot pidgeonhole transport untaint $sender [ In reply to ]
On 12/05/2023 09:04, Martin Waschbüsch via Exim-users wrote:
> LMTP works for me. I had to redo some routing so that Mail identified as Spam goes directly into the appropriate Mailbox (I used +Spam address suffix and appropriate options on dovecot side for that)
>
> And using LMTP over unix socket actually measurably reduces load by not having to spwan a new dovecot-lda all the time. Added benefit! :-)

Thanks for confirming. I wonder if the dovecot community could
update that wiki page? It's not open-access for edits.
--
Cheers,
Jeremy


--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-users.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-users-unsubscribe@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/