Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux Bash Shellshock 漏洞(CVE-2014-6271)緊急修復指南

編輯:Linux 教學

漏洞背景與影響

2014 年 9 月披露的 Shellshock (CVE-2014-6271) 是 Bash 解析環境變數時的程式碼注入漏洞。攻擊者可透過精心構造的環境變數,在 Bash 啟動時執行任意命令,影響範圍極廣:

  • 所有使用 Bash 作為預設 Shell 的 Linux 發行版(CentOS、Debian、Red Hat、Ubuntu 等)。
  • 透過 CGI 腳本、SSH ForceCommand、DHCP 用戶端腳本等觸發遠端程式碼執行 (RCE)。

快速檢測

在終端執行以下命令:

env x='() { :;}; echo vulnerable' bash -c "echo this is a test"

輸出判讀

輸出內容狀態
vulnerable
this is a test
存在漏洞,須立即修補
bash: warning: x: ignoring function definition attempt
bash: error importing function definition for 'x'
this is a test
已修補(安全版本)

各發行版修復命令

Red Hat / CentOS / Fedora (yum/dnf)

# 更新 bash 套件
sudo yum update bash -y
# 或 dnf
sudo dnf update bash -y
# 建議重啟系統或重啟受影響服務
sudo reboot

Debian / Ubuntu (apt)

sudo apt-get update
sudo apt-get install --only-upgrade bash -y
# Ubuntu 通常無需重啟,但建議重啟相關服務

手動編譯升級(無套件源環境)

wget https://ftp.gnu.org/gnu/bash/bash-5.2.tar.gz
tar xf bash-5.2.tar.gz
cd bash-5.2
./configure --prefix=/usr --bindir=/bin
make
sudo make install
# 驗證版本
bash --version

修補後驗證

再次執行檢測命令,確認輸出為「warning/error importing」即表示修補成功。

進階防護建議

  • 更換預設 Shell:非互動腳本改用 dash 或 sh(#!/bin/sh),減少攻擊面。
  • WAF/IDS 規則:部署針對 () { :;} 模式的封鎖規則。
  • 容器掃描:掃描 Docker 映像內的 Bash 版本,重建基礎映像。
  • 關注後續 CVE:Shellshock 後續衍生出 CVE-2014-7169、CVE-2014-7186/7187 等,持續更新至最新版本。

總結

Shellshock 是近十年影響範圍最廣的 Linux 基礎設施漏洞之一。核心對策只有一條:第一時間更新 Bash 至廠商提供的修補版本。建立自動化修補流程、納入漏洞掃描體系,才能從根本上降低類似風險。

Copyright © Windows教程網 All Rights Reserved