# Linux Kernel 漏洞防護實戰:9年老 Bug 都可以一招 Root,你部 Server 安全嗎?
話說最近有個新聞幾震撼 — 一個潛伏咗 **9 年嘅 Linux Kernel 漏洞**俾人掘咗出嚟,影響絕大部分主流 Distro(Ubuntu、Debian、RHEL、CentOS 全部中招),攻擊者只要喺 local 環境 trigger 到,就可以 **直接 escalate 去 root 權限**。你冇睇錯,9年!即係你部 Server 呢 9 年嚟一直都帶住個隱形炸彈行緊。
👉 延伸閱讀:Linux Server 安全加固 6 步搞掂 — Defense in Depth 實戰指南
今日就同大家 step-by-step 實戰,學識點樣保護你啲 Linux Kernel 環境,唔好做下一個受害者。我用返粵語口語講,夠曬貼地,唔使驚睇唔明。
## 咩係 Linux Kernel 漏洞?
Linux Kernel 漏洞係指 Linux 核心代碼本身存在嘅安全缺陷。呢啲漏洞通常出現喺驅動程式、記憶體管理、filesystem 或者 network stack 入面。因為 Kernel 係 OS 嘅心臟,所以任何 Kernel 層級嘅漏洞,影響力都係災難級 — 一旦被 exploit,攻擊者就直接攞到最高權限 (root),所有 security boundary 當場作廢。
今次呢個 9 年老 Bug(CVE-2024-XXXXX)就係喺 `netfilter` 子系統入面嘅 use-after-free 漏洞,存在咗足足 9 年冇人發現。你話驚唔驚?
## Linux Kernel 漏洞防護 Step 1:Check 你個 Kernel 版本
第一步梗係知道自己行緊咩 Kernel 啦。打開 terminal:
uname -r
# 輸出例如:5.15.0-91-generic
記低個版本號,然後對返你個 Distro 嘅 security advisory 睇下有冇中招。
# Ubuntu / Debian
apt list --installed | grep linux-image
# RHEL / CentOS / Rocky
rpm -q kernel
## 點樣防護 Linux Kernel 漏洞?實戰 Checklist
好多人以為「我冇 expose service 出街就安全啦」,錯!Linux Kernel 漏洞好多係 local privilege escalation(LPE),意思係只要 attacker 有辦法喺你部機上面 run 到 code(例如透過 web app vulnerability、phishing、甚至係 CI/CD pipeline),就可以利用 Kernel bug 升權做 root。
以下係實戰防護 checklist:
### 1. 立即更新 Kernel(最重要!)
# Ubuntu / Debian
sudo apt update && sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo reboot
# RHEL / CentOS
sudo yum update kernel -y
sudo reboot
# 確認更新後版本
uname -r
**Pro tip:** 生產環境建議用 `livepatch` 做到 zero-downtime patching:
# Ubuntu Livepatch
sudo snap install canonical-livepatch
sudo canonical-livepatch enable <your-token>
# KernelCare (第三方,支援更多 Distro)
curl -s https://repo.kernelcare.com/installer.sh | sudo bash
sudo kcarectl --register <key>
### 2. 啟用 Kernel Hardening 參數
編輯 `/etc/sysctl.conf` 或者 `/etc/sysctl.d/99-hardening.conf`:
sudo tee -a /etc/sysctl.d/99-hardening.conf <<EOF
# 防止 kernel pointer leak
kernel.kptr_restrict = 2
# 限制 dmesg access
kernel.dmesg_restrict = 1
# 啟用 ASLR 強化
kernel.randomize_va_space = 2
# 防止一般 user mount filesystem(減少 attack surface)
kernel.unprivileged_userns_clone = 0
# 限制 BPF(減少 kernel exploit surface)
kernel.unprivileged_bpf_disabled = 1
# 限制 userfaultfd
vm.unprivileged_userfaultfd = 0
EOF
sudo sysctl --system
### 3. 用 AppArmor / SELinux 限制 Process
唔好熄 SELinux!好多人裝完 CentOS 第一件事就係 `setenforce 0`,呢個係好危險嘅習慣。
# Check SELinux status
getenforce
# 應該係 Enforcing
# Check AppArmor (Ubuntu)
sudo aa-status
### 4. Linux Kernel 漏洞防護:定期做 Vulnerability Scan
用 OpenSCAP 或者 Lynis 定期 scan 你嘅 Linux Kernel 安全狀況:
# 安裝 Lynis
sudo apt install lynis -y # Ubuntu
sudo yum install lynis -y # RHEL
# 執行 audit
sudo lynis audit system --tests-from-group kernel
# 或者直接用 OpenSCAP
sudo apt install libopenscap8 -y
sudo oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_standard \
/usr/share/xml/scap/ssg/content/ssg-ubuntu2204-ds.xml
### 5. Linux Kernel 漏洞防護:限制 sudo 權限 + Audit Logging
最小權限原則:唔好個個 user 都有 `sudo ALL`。
# Check sudoers
sudo visudo
# 開啟 kernel audit logging
sudo auditctl -e 1
sudo auditctl -a always,exit -F arch=b64 -S execve
## 總結:Linux Kernel 漏洞防護不是 Optional
Linux Kernel 漏洞係一個永遠存在嘅威脅。今次呢個 9 年老 Bug 更加印證咗:你永遠唔知自己部機有幾多個未爆嘅炸彈。上面嘅 Checklist 做齊曬,至少可以大幅降低 risk。
記住三個字:**Update、Harden、Monitor**。做好 Linux Kernel 漏洞防護其實唔難,關鍵係養成習慣。
延伸閱讀:
– [CISA Known Exploited Vulnerabilities Catalog](https://www.cisa.gov/known-exploited-vulnerabilities-catalog)
– [Kernel.org Security](https://www.kernel.org/category/security.html)
> 📌 **延伸閱讀:**
> – [Linux Server 安全加固 6 步曲](https://molious.com/linux-server-security-guide/) — 由 firewall 到 audit log,全方位 Linux 安全
> – [2026年5月重大資安漏洞速報](https://molious.com/?p=644) — 最新 CVE 同 industry threat update
#LinuxKernel #Kernel安全 #LinuxHardening #資安防護 #DevSecOps



