C
月内に
Hack The Boxの「WingData」マシンを題材に、Linux環境での権限昇格手法を解説した記事です
📌 一言でいうと
Hack The Boxの「WingData」マシンを題材に、Linux環境での権限昇格手法を解説した記事です。Pythonのtarfileモジュールにおけるアーカイブ展開時のパス・トラバーサル脆弱性を利用し、特権スクリプトを通じて任意のファイルを書き込むことでルート権限を取得する手順が示されています。また、Wing FTPの脆弱性を利用した初期侵入からパスワードクラッキングまでのプロセスも含まれています。
🔍該当判定
- Linuxサーバーで「Wing FTP Server」を運用している
- Pythonの「tarfile」モジュールを使用して、ユーザーがアップロードしたアーカイブファイルを自動解凍する仕組みを自社開発している
- Linuxサーバー上で、一般ユーザーが実行できるsudo権限付きのスクリプトに「ファイルの解凍処理」が含まれている
上記いずれにも該当しない → 静観でOK
✅該当時の対応
特権で動作するスクリプトでユーザー提供のアーカイブを展開する場合、展開先のパスを厳格に検証し、ディレクトリ・トラバーサル攻撃を防ぐ対策を講じてください。また、不要なsudo権限を制限し、最新のライブラリを維持してください。
📧 メール案を見る (管理者向け)
⚠️ これは AI が生成した参考例です。配信前に必ず内容をご確認のうえ、貴社の状況に合わせて編集してご利用ください。実際の被害状況や自社の利用環境を踏まえた判断は、貴社のセキュリティ責任者にご確認ください。
件名: 【共有】Python tarfileモジュールを利用した権限昇格リスクについて
お疲れさまです。特権スクリプトにおける脆弱性に関する情報共有です。
■ 概要
Pythonのtarfileモジュールを使用してアーカイブを展開する際、適切にパスを検証していない場合にディレクトリ・トラバーサルが発生し、任意の場所にファイルを書き込まれるリスクがあります。これにより、特権スクリプトを介してルート権限を奪取される可能性があります。
■ 影響範囲
- Pythonのtarfileモジュールを用いてユーザー提供のアーカイブを特権(sudo等)で展開しているシステム
■ 対応手順
1. 特権で動作するPythonスクリプト内でtarfile.extractall()等を使用していないか確認する
2. 展開先のディレクトリを制限し、シンボリックリンクや「..」を含むパスを排除する検証処理を実装する
3. 可能な限り、特権でのアーカイブ展開を避け、最小権限の原則を適用する
■ 参考情報
- Python公式ドキュメント(tarfileモジュールのセキュリティ警告)
対応優先度: 中
対応期限: 次回定期メンテナンスまで
お疲れさまです。特権スクリプトにおける脆弱性に関する情報共有です。
■ 概要
Pythonのtarfileモジュールを使用してアーカイブを展開する際、適切にパスを検証していない場合にディレクトリ・トラバーサルが発生し、任意の場所にファイルを書き込まれるリスクがあります。これにより、特権スクリプトを介してルート権限を奪取される可能性があります。
■ 影響範囲
- Pythonのtarfileモジュールを用いてユーザー提供のアーカイブを特権(sudo等)で展開しているシステム
■ 対応手順
1. 特権で動作するPythonスクリプト内でtarfile.extractall()等を使用していないか確認する
2. 展開先のディレクトリを制限し、シンボリックリンクや「..」を含むパスを排除する検証処理を実装する
3. 可能な限り、特権でのアーカイブ展開を避け、最小権限の原則を適用する
■ 参考情報
- Python公式ドキュメント(tarfileモジュールのセキュリティ警告)
対応優先度: 中
対応期限: 次回定期メンテナンスまで
Subject: [Security Info] Privilege Escalation Risk via Python tarfile Module
Dear Admin,
We are sharing information regarding a potential privilege escalation vector in Linux environments.
■ Overview
When using Python's tarfile module to extract archives, a lack of path validation can lead to directory traversal. If a privileged script performs this extraction, an attacker can overwrite critical system files to gain root access.
■ Scope
- Systems running privileged Python scripts that extract user-supplied archives using the tarfile module.
■ Mitigation Steps
1. Audit privileged Python scripts for the use of tarfile.extractall() or similar functions.
2. Implement strict validation of extraction paths to prevent directory traversal (e.g., checking for '..' or absolute paths).
3. Adhere to the principle of least privilege and avoid extracting archives as root whenever possible.
■ Reference
- Python official documentation regarding tarfile security warnings.
Priority: Medium
Deadline: Next scheduled maintenance
Dear Admin,
We are sharing information regarding a potential privilege escalation vector in Linux environments.
■ Overview
When using Python's tarfile module to extract archives, a lack of path validation can lead to directory traversal. If a privileged script performs this extraction, an attacker can overwrite critical system files to gain root access.
■ Scope
- Systems running privileged Python scripts that extract user-supplied archives using the tarfile module.
■ Mitigation Steps
1. Audit privileged Python scripts for the use of tarfile.extractall() or similar functions.
2. Implement strict validation of extraction paths to prevent directory traversal (e.g., checking for '..' or absolute paths).
3. Adhere to the principle of least privilege and avoid extracting archives as root whenever possible.
■ Reference
- Python official documentation regarding tarfile security warnings.
Priority: Medium
Deadline: Next scheduled maintenance