Just like DNS way, way, waaaaaaaay too many seem to mess up NTP. So I wrote a thing about monitoring NTP with OpenSearch/ElasticSearch.

https://www.infosecworrier.dk/blog/2025/03/ntpmonitoring/

#ElasticSearch #OpenSearch #NTP #NTPd #NTPSec #CriticalInfrastructure

NTP Server Monitoring with Filebeat and ELK

there is a wide gap in the understanding of NTP (and PTP) amongst many IT Organizations. Most appear to be ignorant of RFC8633 containing Best Current Practice (BCP), including recommendations for the stable, accurate, and secure operation of NTP infrastructure.

Infosec Worrier
@SakuraCatMoe @SourLemonJuice 没有特别需求,用chrony就好。

https://madaidans-insecurities.github.io/guides/linux-hardening.html
某人写的Linux安全加固指南:

######

10.5.4 Time synchronisation

Time synchronisation is vital for anonymity and security. A wrong system clock can expose you to clock skew fingerprinting attacks or can be used to feed you outdated HTTPS certificates, bypassing certficate expiry or revocation.

The most popular time synchronisation method, NTP, is insecure, as it is unencrypted and unauthenticated, allowing an attacker to trivially intercept and modify requests. NTP also leaks your local system time in NTP timestamp format, which can be used for clock skew fingerprinting, as briefly mentioned before.

Thus, you should uninstall any NTP clients and disable systemd-timesyncd if it is in use. Instead of NTP, you can connect to a trusted website over a secure connection (HTTPS or, preferably, a Tor onion service) and extract the current time from the HTTP header. Tools that accomplish this are sdwdate or my own secure-time-sync.

机器翻译:

10.5.4时间同步


时间同步对于匿名性和安全性至关重要。错误的系统时钟可能使您暴露于时钟倾斜指纹攻击,或者可以用来提供过期的HTTPS证书,绕过证书过期或撤销。


最流行的时间同步方法NTP是不安全的,因为它未加密和未经身份验证,允许攻击者轻松拦截和修改请求。NTP还以NTP时间戳格式泄露您的本地系统时间,这可以用于时钟倾斜指纹,正如前面简要提到的那样。


因此,您应该卸载所有NTP客户端,并禁用system-timesyncd。代替NTP,你可以通过安全连接(HTTPS,或者最好是Tor洋葱服务)连接到一个受信任的网站,并从HTTP报头中提取当前时间。完成此任务的工具是sddate或我自己的secure-time-sync。
[secure-time-sync] https://gitlab.com/madaidan/secure-time-sync

######

传统的 #ntp 协议没加密。攻击者可以搞流量分析,即深度数据包检测 #DPI 。有时候会引起断网和QoS。有些厂商喜欢分析你的NTP流量,透过流量分析,人家猜到你家局域网里有几台电脑,收集数据,有时候会根据分析结果来自动封锁你的网络。某些大学会有类似现象,网络服务商ISP禁止每台路由器下面连多台电脑手机,想要多收几份宽带费,他们的设备会检测NTP流量。

ntp协议没有验证,为UDP放大攻击大开方便之门?貌似打不到客户端那边,受害的都是运行ntpd的服务器?

ntp协议的流量没有验证,可以修改数据包。局域网内的攻击者,还有广域网链路上的攻击者,他们可以改你的数据包,把ntp服务器返回给你的数据包给改了?轻则修改你的系统时间,重则缓冲区溢出攻击。缓冲区溢出攻击能打到你的个人电脑,可能导致程序崩溃,可能是执行远程的恶意代码。

对于服务器来说,数据包被修改,可能会导致IDS入侵检测系统的日志文件里的时间戳错乱。本来能及时发出警报,警报要拖到几个月后才发出。甚至时间戳有错,安全警报被程序“智能”地忽略了,本来被入侵有警报,现在警报系统变哑巴了。乱改你的系统时间,通常会导致TLS错误,你的网站会打不开。

对于需要匿名上网的桌面用户来说,系统时间被ntp泄漏,潜在的攻击者可以分析流量,计算出你的电脑的唯一身份标识符,用于指纹识别和跟踪真实身份。在现实世界里这类跟踪人身份的攻击发生得有多频繁呢?

chrony 和 ntpsec 两个软件都可以开NTS协议。NTS协议把传统ntp协议改了,加了加密和认证。由于NTS协议本身比较复杂,支持NTS协议的客户端程序要加入很多很多代码,对于有着高度安全需求的用户来说,chrony 和 ntpsec 的攻击面还是太大了。因此 #Linux安全加固指南 的作者推荐你放弃它们两个,改用一个代码量很短的bash shell脚本,用shell脚本定时修改系统时间。

[CloudFlare 开源网络时间安全协议:同时支持 NTP 和 NTS] https://www.infoq.cn/article/2xsJ9Ixjrrur10qPkCk1

对于一般人来说,直接用 chrony 吧。chrony 有红帽公司善后, #redhat 不会放着不管的,毕竟是付费服务。如果你觉得红帽公司不放心,你只能选 #ntpsec 。有些人觉得红帽公司所定义的“安全”和你所需要的“安全”不是同一种“安全”。毕竟红帽公司的总部在美国,和Linux一样,懂的都懂的。ntpsec这个项目貌似是受捐款的,跟红帽公司的运作模式理论上不太一样。

[ntpsec]的捐款链接 https://liberapay.com/ntpsec/donate

ntpsec据说沿用了老版ntp的代码。chrony估计是重头开始写的,是全新的。据说砍掉了70%的代码,理论上来说,减少了很多安全风险,以后安全漏洞会少一些。每隔1000行代码就有1个BUG。代码越少,BUG越少,高危漏洞也越少。

ntpsec:沿用老代码,老代码经过时间的考验,砍掉70%老代码,这样安全吗?
chrony:重新写一个ntp客户端,代码都是新的,做完旧功能,再做新功能,把NTS协议也做了,保证新的代码不出BUG,这样安全吗?
A好还是B好?哪一种工程做法更加安全呢?目前我们找不到科学的判断办法。

[Differences from NTP Classic] https://docs.ntpsec.org/latest/ntpsec.html

对于少数有高度安全需求的桌面用户来说,应该用 secure-time-sync 。对于那些需要做信息安全等级保护测评2.0的企业用户来说,你ntp流量不加密,肯定是要扣分的。对于安全需求低一些的个人用户,用 #chrony 。对红帽公司不放心的,改用 #ntpsec

systemd-timesyncd 没什么特别的优点。在debian那边,传统的ntp包慢慢被ntpsec取代。 systemd-timesyncd 没有很多安全方面的卖点。隔壁 chrony 和 ntpsec 主打安全,都是可以用NTS协议的。systemd-timesyncd 既不是代码量少,又不支持NTS协议。systemd-timesyncd 本身有多少双眼睛盯着看呢?跟 chrony 和 ntpsec 相比,网上的关注度更加低。systemd-timesyncd 的BUG修复速度如何,安全编程的水准如何,几乎找不到任何情报。

RE: https://mastodon.social/@SakuraCatMoe/113929277774035990
Linux Hardening Guide | Madaidan's Insecurities

holy shit, das #logging vom #ntpsec #ntpd ist ja mal so mies

die _haben_ extra eine relativ feingliedrige "LOGIF"-Infrastruktur gebaut, die es erlaubt spezifische Meldungen in einer Matrix aus Klassen und Kategorien ein- und auszuschalten, und sie nutzen es intern einfach nicht sondern blasen alles in den Syslog.

Bedeutet dass der Syslog voll ist mit DNS errors wenn die Leitung weg ist, weil "einen anbleibenden Fehlerzustand nicht erneut loggen" ist anscheinend auch zu viel verlangt. ⁉️

TIL, much to my chagrin, that evidently the default install of raspbian now checks for new APT and automatically upgrades daily.

I learned this because something hinkey happened.

My Stratum 1 NTP server jumped from
Nov 28 19:13:45 [2022]
Sep 13 01:59:01 [2022]
Then to
Feb 13 12:30:05 [2023]

So my stats are fubar.

So next time someone wants to make an argument that automatic updates are they way to go, tell them about this, and point them at the nearest beach.

#Raspberrypi #ntpsec