AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1147667
Accepted
user2690527
user2690527
Asked: 2023-11-11 22:47:58 +0800 CST2023-11-11 22:47:58 +0800 CST 2023-11-11 22:47:58 +0800 CST

Postfix 虚假地检查经过身份验证的提交邮件客户端的 SPF 策略

  • 772

我在 Ubuntu 23.10 上运行 Postfix 3.8.1。Postfix 为来自其他 MTA 的传入邮件提供端口 25,为经过身份验证的 MUA 提供端口 587。

Postfix 应该在端口 25 上检查来自其他 MTA 的邮件的 SPF,但不会检查端口 587 上来自经过身份验证的 MUA 的邮件。但是,Postfix 会虚假地对经过身份验证的 MUA 执行此操作,并且 SPF 失败(因为该 MUA 没有被列为允许的邮件服务器) )。

我感觉好像 Postfix 简单地忽略了 MUA 的特殊规则,但我没有发现我的配置错误。

我的master.cnf

# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (no)    (never) (100)
# ==========================================================================
smtp      inet  n       -       y       -       -       smtpd
submission inet n       -       y       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o cleanup_service_name=header_cleanup
  -o smtpd_client_restrictions=$mua_client_restrictions
  -o smtpd_helo_restrictions=$mua_helo_restrictions
  -o smtpd_sender_restrictions=$mua_sender_restrictions
  -o smtpd_relay_restrictions=$mua_relay_restrictions
header_cleanup unix n   -       -       -       0       cleanup
  -o header_checks=regexp:/etc/postfix/submission_header_cleanup.cf

上面配置的想法是smtpd在端口 587 ( submission) 上应该使用一些特殊的配置。

我的main.cf

smtpd_delay_reject = yes

smtpd_client_restrictions =
  reject_unauth_pipelining,
  reject_unknown_client_hostname
mua_client_restrictions =
  reject_unauth_pipelining

smtpd_helo_required = yes

smtpd_helo_restrictions =
  reject_invalid_helo_hostname,
  reject_non_fqdn_helo_hostname,
  reject_unknown_helo_hostname
mua_helo_restrictions =
  reject_invalid_helo_hostname

strict_rfc821_envelopes = yes

smtpd_sender_restrictions =
  reject_non_fqdn_sender,
  reject_unknown_sender_domain
mua_sender_restrictions =
  reject_non_fqdn_sender,
  reject_unknown_sender_domain
  reject_plaintext_session,
  reject_sender_login_mismatch

smtpd_relay_restrictions =
  reject_non_fqdn_recipient,
  reject_unknown_recipient_domain,
  reject_unauth_destination
mua_relay_restrictions =
  reject_non_fqdn_recipient,
  reject_unknown_recipient_domain,
  permit_sasl_authenticated,
  reject

smtpd_recipient_restrictions =
  check_policy_service unix:private/policyd-spf,
  permit

policyd-spf_time_limit = 3600

smtpd_sasl_type=dovecot
smtpd_sasl_path=private/auth
smtpd_sasl_auth_enable=no

这个想法是,经过mua_relay_restrictions身份验证的客户端将被无条件允许,而其他一切都会被拒绝。这意味着对于经过身份验证的客户端,访问控制应该停止于此。这也是为什么smtpd_recipient_restrictions端口 25 上只有客户端而没有对应的原因mua_recipient_restriction,因为 Postfix 永远不应该到达那个点。

但是,如果我使用邮件客户端通过 Postfix 邮件服务器将提交的邮件发送到我的另一个邮箱(外部托管),我会在邮件服务器上看到以下日志:

postfix/submission/smtpd[515502]: Anonymous TLS connection established from pd9ecf27b.dip0.t-ipconnect.de[217.236.242.123]: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-sign>
policyd-spf[515508]: : prepend Received-SPF: Softfail (mailfrom) identity=mailfrom; client-ip=217.236.242.123; helo=my-touchpad.localnet; [email protected]; receiver=other-domain.tld

SPF 必然会失败,这是显而易见的。MUA 是拨号线路 (pd9ecf27b.dip0.t-ipconnect.de[217.236.242.123]) 上的客户端 (my-touchpad.localnet),其未在 的 SPF 策略中列出my-domain.tld。当然,这并不是因为 SPF 策略只列出了邮件服务器本身。

然而,我想知道为什么 Postfix 首先要执行该检查。检查 SPF 只是其中的一部分smtpd_recipient_restrictions,不应应用于经过身份验证的 MUA。

postfix
  • 2 2 个回答
  • 44 Views

2 个回答

  • Voted
  1. Best Answer
    Esa Jokinen
    2023-11-12T16:26:19+08:002023-11-12T16:26:19+08:00

    检查 SPF 只是其中的一部分smtpd_recipient_restrictions,不应应用于经过身份验证的 MUA。

    这是一个错误的假设。smtpd_recipient_restrictions仅当配置为在检查 SPF 策略之前允许经过身份验证的 MUA 时,才会执行此操作,例如,

    smtpd_recipient_restrictions =
      permit_sasl_authenticated,
      check_policy_service unix:private/policyd-spf,
      permit
    

    因为...

    限制按指定的顺序应用;第一个匹配的限制获胜。

    您当前对所有 smtpd 实例都有一个全局设置,包括检查 SPF 并允许任何邮件通过 SPF 检查的提交:

    smtpd_recipient_restrictions =
      check_policy_service unix:private/policyd-spf,
      permit
    

    为了不将此应用于经过身份验证的 MUA,该参数对于提交应该是不同的,这是通过覆盖中的参数来实现的master.cf:

    submission inet n       -       y       -       -       smtpd
      . . .
      -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
    

    或者,如果您遵循在您的中定义自定义变量(即不是Postfix Configuration Parameter)并将它们用作 中的变量的模式,您将拥有:mua_*_restrictionsmain.cfmaster.cf

    • 在main.cf:

      mua_recipient_restrictions =
         permit_sasl_authenticated,
         reject
      
    • 在master.cf:

      submission inet n       -       y       -       -       smtpd
         . . .
         -o smtpd_recipient_restrictions=$mua_recipient_restrictions
      
    • 2
  2. anx
    2023-11-12T09:23:59+08:002023-11-12T09:23:59+08:00

    我没有看到-o smtpd_recipient_restrictions=$mua_recipient_restrictions你的任何行master.cf会覆盖你的 main.cf 全局默认值。

    这不应该应用于经过身份验证的 MUA

    您认为不应该应用的内容并不是专门为端口 25 实例配置的。由于您将其放在 main.cf 中,因此它作为两者的默认值。smtpdPostfix 正在为两个实例(服务 MX 角色和处理经过身份验证的提交)应用相同的收件人限制类,因为您修改了全局默认值,并且没有针对该特殊提交服务将其更改回来。

    您可以(不是唯一的解决方案,但似乎是到达您想要的位置的一致且可读的方式)覆盖它,就像您对其他限制类所做的那样。

    mua_recipient_restrictions = permit_sasl_authenticated, reject

    • 1

相关问题

  • Postfix 在特定端口上接受邮件

  • 让 Postfix 以两种方式处理垃圾邮件

  • Postfix 或 exim:自动/程序化和转发电子邮件设置

  • 后缀电子邮件地址

  • 什么是最好的开源电子邮件解决方案包

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve