Add admission webhook TLS mismatch problem - #777
Conversation
|
Hi, I opened this PR for the evaluation task. It adds a new SREGym problem that simulates an admission webhook TLS trust mismatch caused by a stale/wrong caBundle. I tested it locally: the fault produces a I’d appreciate any feedback. |
|
@mohamedharake Thanks for the PR! Could you please write a more detailed/structured PR description? It would help me greatly in reviewing it. Some points you can include:
You can use these PRs as reference: |
|
Thank you so much for the feedback. I updated the PR description with the real world failure story, simulation details, runtime behavior, mitigation/testing notes, and expected agent behavior. I’ll also try running Stratus now and add the results if I can get it working locally. |
|
@mohamedharake Thank you! There are quite a few PRs I have to review. I'll try to get to this one as soon as I can. |
Saadmrp1038
left a comment
There was a problem hiding this comment.
@mohamedharake This is a great PR! Very clean implementation. I tested the fault and everything works nicely.
There's just this one small nit. Ping me when it's done. I will merge the PR!
| self._run(["openssl", "genrsa", "-out", str(ca_key), "2048"], stdout=subprocess.DEVNULL) | ||
| self._run([ | ||
| "openssl", "req", "-x509", "-new", "-nodes", | ||
| "-key", str(ca_key), | ||
| "-sha256", "-days", "365", | ||
| "-subj", "/CN=sregym-real-webhook-ca", | ||
| "-out", str(ca_crt), | ||
| ], stdout=subprocess.DEVNULL) | ||
|
|
||
| self._run(["openssl", "genrsa", "-out", str(wrong_ca_key), "2048"], stdout=subprocess.DEVNULL) | ||
| self._run([ | ||
| "openssl", "req", "-x509", "-new", "-nodes", | ||
| "-key", str(wrong_ca_key), | ||
| "-sha256", "-days", "365", | ||
| "-subj", "/CN=sregym-stale-wrong-ca", | ||
| "-out", str(wrong_ca_crt), | ||
| ], stdout=subprocess.DEVNULL) |
There was a problem hiding this comment.
nit: Let's use generic/realistic names here for /CN. I don't like to use names that can reveal internal information to the agent.
For example, when running with claudecode it read this data:
The root cause is clear now:\n\n1. The CA bundle in the `ValidatingWebhookConfiguration` (`pod-policy.validation.k8s.io`) contains a CA with CN = `sregym-stale-wrong-ca`\n2. The server certificate in the `pod-policy-webhook-tls` secret was signed by a CA with CN = `sregym-real-webhook-ca`
|
On a side note, I ran this problem with multiple agents. The mitigation by Claude Code was very interesting. Instead of taking a shortcut (deleting the webhook), it successfully repaired the trust chain by generating a new CA, signing a new server cert, and patching both the TLS secret and the webhook's caBundle to match. |
|
Done, thanks a lot! I renamed the certificate common names to more generic/realistic values. |
|
@mohamedharake Awesome! Congrats on your first PR merged here 🎉 |
|
This is great work!! |
|
Thank you!! |
Adds a new SREGym problem simulating an admission-webhook TLS trust mismatch in the Hotel Reservation app. The failure is a production-style Kubernetes admission-control issue: the webhook backend is reachable, but the
ValidatingWebhookConfigurationcontains a stale/wrongcaBundle, so the kube-apiserver rejects pod CREATE requests with anx509verification error.The PR is limited to the new problem plus registry wiring.
1. The real-world failure story
Admission webhooks sit directly in the Kubernetes API request path. If a
ValidatingWebhookConfigurationhasfailurePolicy: Fail, then matching requests are rejected whenever the webhook call fails. This is risky because the affected application can be healthy, but Kubernetes may still be unable to create replacement pods.This problem models a certificate-rotation / CA-drift failure: the webhook backend is reachable and serving HTTPS, but the
caBundlestored in theValidatingWebhookConfigurationis stale or wrong. The kube-apiserver therefore cannot verify the webhook server certificate and rejects pod CREATE admission requests with anx509error.Several real-world reports anchor this simulation:
OPA cert-controller, October 2020 — “CA and Server certificate potentially get updated before ValidatingWebhookConfiguration”. The issue describes the risk this problem models: the CA is renewed, but the
ValidatingWebhookConfigurationmay still contain the old CA, so webhook calls can fail.ingress-nginx, August 2020 — “apply ingress rule error after install ingress-nginx: x509 certificate is not valid”. A validating admission webhook rejects resource creation because the serving certificate does not validate for the webhook service DNS name.
ingress-nginx, January 2022 — “Kubernetes: ingress-nginx-controller-admission error, x509 certificate signed by unknown authority”. The writeup shows an admission-controller
x509failure after reinstalling ingress-nginx, with a workaround that patches the validating webhookcaBundle.cert-manager, September 2023 — “Webhook inject-ca-from annotation causes downtime”. The report describes a rotation race where the API server accepts one certificate chain while the webhook server still serves another, causing webhook downtime.
The SREGym scenario keeps the same failure class but makes it reproducible: the backend exists and is reachable, while the trust relationship between the kube-apiserver and webhook is intentionally broken.
2. How the failure is simulated in SREGym
The new problem class lives at:
sregym/conductor/problems/admission_webhook_tls_mismatch.pyand is registered as:
admission_webhook_tls_mismatch_hotel_reservationThe fault injection does the following:
policy-systemnamespace.caBundle.policy-system/pod-policy-webhook.ValidatingWebhookConfigurationnamedpod-policy.validation.k8s.io.namespaceSelector.failurePolicy: FailCREATEadmission rulescaBundlerecommendationdeployment so the ReplicaSet has to recreate it.The recreate attempt then hits the webhook and fails during TLS verification.
3. Problem runtime behaviour
Verified locally through the SREGym CLI and Kubernetes events.
policy-system/pod-policy-webhookis created as a reachable HTTPS servicerecommendationpod is deletedrecommendationReplicaSet hasdesired=1,current=0,ready=0failed calling webhookwith anx509certificate errorhotel-reservationthroughnamespaceSelectorThe key event observed locally:
This is the main diagnostic signal an agent should follow. The pod is not failing because of its own image, command, memory, or service config; pod creation is being rejected by admission control.
4. Mitigation and validation
Valid mitigations:
ValidatingWebhookConfiguration,failurePolicyfromFailtoIgnore,caBundle.Local mitigation test used the first path:
After that, the ReplicaSet recreated the missing
recommendationpod and the SREGym mitigation oracle passed.Local final result:
recommendationunder-replicatedx509: certificate signed by unknown authorityobservedJUDGE_MODEL_IDwas not configured5. Expected agent behaviour
I have not run Stratus end-to-end on this problem yet.
Expected successful agent path:
recommendationis under-replicated.ValidatingWebhookConfiguration.failurePolicy, or repairingcaBundle.The intended challenge is that the visible symptom is application-level availability loss, but the root cause is a cluster-scoped admission-control dependency.
Notes for reviewers
namespaceSelector.policy-systemnamespace.social_networkorastronomy_shopcan be added if useful.