OpenSSH 引入了惩罚不良行为的选项
OpenSSH introduces options to penalize undesirable behavior

原始链接: https://undeadly.org/cgi?action=article;sid=20240607042157

OpenBSD 的 SSH 守护进程 (sshd) 的最新更新包括新的配置选项 PerSourcePenalties 和 PerSourcePenaltyExemptList,由 Damien Miller 在最近的提交中添加。 这些选项旨在解决不需要的行为并保护 sshd 本身内的特定客户端。 启用 PerSourcePenalties 后,sshd 会监视其子预身份验证会话的退出状态。 任何未经验证的尝试或崩溃都会触发惩罚期。 超过设定限制后,发起者的连接将与​​同一子网块大小内的其他连接一起被拒绝。 后续违规行为会增加处罚的严重程度,直至达到配置的最大值。 PerSourcePenaltyExemptList 下列出的客户不受这些处罚的影响。 这些功能应该有助于增强安全性,防止针对 sshd 中的弱密码或漏洞的攻击。 最初,它们仅在 OpenBSD 当前版本中可用,但很可能包含在下一个正式版本 OpenBSD 7.6 中。 默认情况下,PerSourcePenalties 处于关闭状态,但计划要求在 7.6 版本发布后不久自动启用。 请记住,在大型 NAT 块、代理或需要单个 IP 后面的多个用户的类似系统后面运行 sshd 可能会导致合法流量因惩罚系统而被阻止。 要进行微调,请参阅 sshd_config 文件中提供的 PerSourcePenalties、PerSourcePenaltyExemptList 和 PerSourceNetBlockSize 选项的联机帮助页。

本文讨论了有关新 SSH 服务器设置的问题,这些设置限制了来自特定来源的失败登录尝试的次数。 作者对这些变化表示担忧,指出对 CGN 环境中无意共享 IP 地址的潜在负面影响、对使用 IPv6 的坚定攻击者缺乏有效性,以及与 Fail2ban 等现有解决方案相比带来不必要的复杂性。 他们主张采取更基本的安全措施,例如限制对受信任网络的访问和采用多因素身份验证方法。 文中还提到了见证不安全 SSH 配置的个人经历,并提供了 Tatu Ylonen 的一篇研究论文的链接,该论文涉及围绕 SSH 安全性的未解决的挑战。
相关文章

原文

Contributed by Peter N. M. Hansteen on from the sshd to carry a big stick dept.

In a recent commit, Damien Miller (djm@) introduced the new sshd(8) configurations options, PerSourcePenalties and PerSourcePenaltyExemptList, to provide a built in facility in sshd(8) itself to penalize undesirable behavior, and to shield specific clients from penalty, respectively.

The commit message reads,


List:       openbsd-cvs
Subject:    CVS: cvs.openbsd.org: src
From:       Damien Miller <djm () cvs ! openbsd ! org>
Date:       2024-06-06 17:15:26

CVSROOT:	/cvs
Module name:	src
Changes by:	[email protected]	2024/06/06 11:15:26

Modified files:
	usr.bin/ssh    : misc.c misc.h monitor.c monitor_wrap.c 
	                 servconf.c servconf.h srclimit.c srclimit.h 
	                 sshd-session.c sshd.c sshd_config.5 

Log message:
Add a facility to sshd(8) to penalise particular problematic client
behaviours, controlled by two new sshd_config(5) options:
PerSourcePenalties and PerSourcePenaltyExemptList.

When PerSourcePenalties are enabled, sshd(8) will monitor the exit
status of its child pre-auth session processes. Through the exit
status, it can observe situations where the session did not
authenticate as expected. These conditions include when the client
repeatedly attempted authentication unsucessfully (possibly indicating
an attack against one or more accounts, e.g. password guessing), or
when client behaviour caused sshd to crash (possibly indicating
attempts to exploit sshd).

When such a condition is observed, sshd will record a penalty of some
duration (e.g. 30 seconds) against the client's address. If this time
is above a minimum threshold specified by the PerSourcePenalties, then
connections from the client address will be refused (along with any
others in the same PerSourceNetBlockSize CIDR range).

Repeated offenses by the same client address will accrue greater
penalties, up to a configurable maximum. A PerSourcePenaltyExemptList
option allows certain address ranges to be exempt from all penalties.

We hope these options will make it significantly more difficult for
attackers to find accounts with weak/guessable passwords or exploit
bugs in sshd(8) itself.

PerSourcePenalties is off by default, but we expect to enable it
automatically in the near future.

much feedback markus@ and others, ok markus@
This new facility comes in addition to the already well known and loved pf.conf state tracking options, and is for now available only in OpenBSD-current, but is almost certainly to be available in the upcoming OpenBSD 7.6 release.

At first we were wondering whether these options would be enabled by default before the new release. We did not have to wait long. This subsequent commit settled the issue:


List:       openbsd-cvs
Subject:    CVS: cvs.openbsd.org: src
From:       Damien Miller <djm () cvs ! openbsd ! org>
Date:       2024-06-06 20:25:48

CVSROOT:	/cvs
Module name:	src
Changes by:	[email protected]	2024/06/06 14:25:48

Modified files:
	usr.bin/ssh    : servconf.c 

Log message:
enable PerSourcePenalties by default.

ok markus

NB. if you run a sshd that accepts connections from behind large NAT
blocks, proxies or anything else that aggregates many possible users
behind few IP addresses, then this change may cause legitimate traffic
to be denied.

Please read the PerSourcePenalties, PerSourcePenaltyExemptList and
PerSourceNetBlockSize options in sshd_config(5) for how to tune your
sshd(8) for your specific circumstances.
So now we know: starting with OpenBSD 7.6, PerSourcePenalties will be enabled by default, and admins who do not themselves run PF or other network translation mechanisms will need to keep the consequences of inconsiderate NAT use in mind.
联系我们 contact @ memedata.com