Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DENY, DENYSOFT, and DISCONNECT are ignored in ehlo_hook #3269

Closed
lnedry opened this issue Jan 19, 2024 · 4 comments
Closed

DENY, DENYSOFT, and DISCONNECT are ignored in ehlo_hook #3269

lnedry opened this issue Jan 19, 2024 · 4 comments

Comments

@lnedry
Copy link
Contributor

lnedry commented Jan 19, 2024

DENY, DENYSOFT, and DISCONNECT are ignored in ehlo_hook. DENYDISCONNECT is not ignored.

I expected that inbound email would be rejected and/or the connection dropped when DENY is passed to next().

After DENY, DENYSOFT, or DISCONNECT in the ehlo_hook, Haraka will continue to run hooks and deliver the email.

This is a new install of Debian 11 and Haraka 3.0.2. Only software necessary for Haraka to operate has been installed along with a few tools for testing.

# cat /etc/haraka/config/plugins
syslog
test
rcpt_to.in_host_list
queue/smtp_forward
# cat /etc/haraka/plugins/test.js
exports.hook_ehlo = function (next, connection, ehlo) {
    return next(DENY, 'DENIED');
}
% ./swaks --server 192.168.1.99 --port 2525 --to [email protected] --from [email protected]
=== Trying 192.168.1.99:2525...
=== Connected to 192.168.1.99.
<-  220 lab.local ESMTP Haraka/3.0.2 ready
 -> EHLO imac.local
<** 550 DENIED
 -> HELO imac.local
<-  250 lab.local Hello [192.168.1.250]Haraka is at your service.
 -> MAIL FROM:<[email protected]>
<-  250 sender <[email protected]> OK
 -> RCPT TO:<[email protected]>
<-  250 recipient <[email protected]> OK
 -> DATA
<-  354 go ahead, make my day
 -> Date: Fri, 19 Jan 2024 15:20:48 -0500
 -> To: [email protected]
 -> From: [email protected]
 -> Subject: test Fri, 19 Jan 2024 15:20:48 -0500
 -> Message-Id: <[email protected]>
 -> X-Mailer: swaks v20240103.0 jetmore.org/john/code/swaks/
 -> 
 -> This is a test mailing
 -> 
 -> 
 -> .
<-  250 OK id=1rQvM8-0000c8-Dq (75388EB8-9402-4FB4-8B6C-DFE4796775C5.1)
 -> QUIT
<-  221 lab.local closing connection. Have a jolly good day.
=== Connection closed with remote host.
Jan 19 15:20:48 lab haraka[2263]: [NOTICE] [75388EB8-9402-4FB4-8B6C-DFE4796775C5] [core] connect ip=192.168.1.250 port=49961 local_ip=192.168.1.99 local_port=2525
Jan 19 15:20:48 lab haraka[2263]: [INFO] [75388EB8-9402-4FB4-8B6C-DFE4796775C5] [core]  hook=ehlo plugin=test function=hook_ehlo params=imac.local retval=DENY msg=DENIED
Jan 19 15:20:48 lab haraka[2263]: [NOTICE] [75388EB8-9402-4FB4-8B6C-DFE4796775C5.1] [core] sender <[email protected]> code=CONT msg=""
Jan 19 15:20:48 lab haraka[2263]: [INFO] [75388EB8-9402-4FB4-8B6C-DFE4796775C5.1] [core]  hook=rcpt plugin=rcpt_to.in_host_list function=hook_rcpt params=<[email protected]> retval=OK msg=""
Jan 19 15:20:48 lab haraka[2263]: [NOTICE] [75388EB8-9402-4FB4-8B6C-DFE4796775C5.1] [core] recipient <[email protected]> code=OK msg="" [email protected]
Jan 19 15:20:48 lab haraka[2263]: [NOTICE] [75388EB8-9402-4FB4-8B6C-DFE4796775C5.1] [core] message mid=<[email protected]> size=274 rcpts=1/0/0 delay=0 code=CONT msg=""
Jan 19 15:20:48 lab haraka[2263]: [INFO] [-] [core] [smtp_client] uuid=9ABC6307-B5E7-4B74-8CEF-20CB5AF93EE1 host=192.168.1.99 port=25 created
Jan 19 15:20:48 lab haraka[2263]: [INFO] [75388EB8-9402-4FB4-8B6C-DFE4796775C5.1] [queue/smtp_forward] forwarding to 192.168.1.99:25
Jan 19 15:20:48 lab haraka[2263]: [INFO] [75388EB8-9402-4FB4-8B6C-DFE4796775C5.1] [core]  hook=queue plugin=queue/smtp_forward function=queue_forward params="" retval=OK msg="OK id=1rQvM8-0000c8-Dq"
Jan 19 15:20:48 lab haraka[2263]: [NOTICE] [75388EB8-9402-4FB4-8B6C-DFE4796775C5.1] [core] queue code=OK msg="OK id=1rQvM8-0000c8-Dq (75388EB8-9402-4FB4-8B6C-DFE4796775C5.1)"
Jan 19 15:20:48 lab haraka[2263]: [NOTICE] [75388EB8-9402-4FB4-8B6C-DFE4796775C5.1] [core] disconnect ip=192.168.1.250 rdns=NXDOMAIN helo=imac.local relay=N early=N esmtp=N tls=N pipe=N errors=0 txns=1 rcpts=1/0/0 msgs=1/0/0 bytes=274 lr="550 DENIED" time=0.065
Haraka Haraka.js — Version: 3.0.2
Node v20.11.0
OS Linux lab.local 5.10.0-27-amd64 #1 SMP Debian 5.10.205-2 (2023-12-31) x86_64 GNU/Linux
openssl OpenSSL 1.1.1w 11 Sep 2023
@baudehlo
Copy link
Collaborator

baudehlo commented Jan 19, 2024 via email

@lnedry
Copy link
Contributor Author

lnedry commented Jan 19, 2024

Am I misunderstanding RFC 5321 4.3.2?

Specific sequences are:
EHLO or HELO
S: 250
E: 504 (a conforming implementation could return this code only
in fairly obscure cases), 550, 502 (permitted only with an old-
style server that does not support EHLO)

@baudehlo
Copy link
Collaborator

baudehlo commented Jan 19, 2024 via email

@msimerson
Copy link
Member

I expected that inbound email would be rejected and/or the connection dropped when DENY is passed to next().

I believe your expectations are incorrect. When configured as you describe above, Haraka does, near as I can tell from reading RFC 5321, The Right Thing:

❯ nc localhost 25
220 home.simerson.net ESMTP Haraka/3.0.3/2e6ff612 ready
ehlo imac27.local
550 DENIED
ehlo matt
550 DENIED
helo matt
250 home.simerson.net Hello mysql [::1]Haraka is at your service.

If you don't ask Haraka to disconnect, then it should not disconnect, right? If you want it to disconnect, you know how to configure that in your plugin.

inbound email would be rejected

Why would you expect this from a HELO/EHLO hook that you didn't disconnect? At this phase in the dialogue, we're not in a transaction, so why would future transactions be affected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants