flawopen.com/Teardowns/cve-2024-7646-ingress-nginx-annotation-code-injection
CVE-2024-7646: Ingress-NGINX सत्यापन बायपास
Carriage-return bypass से commands inject कर controller credentials मिल सकते थे। 1.11.2/1.10.4 में सुधार हुआ; ingress-nginx अब बंद है।
ऐसे द्वारपाल की कल्पना करें जो केवल यह देखता है कि फ़ॉर्म में अनुमत शब्द है, पूरी value नहीं जाँचता। Carriage return अगली प्रणाली को शेष पाठ अलग तरह से पढ़वा सकता है। यहाँ annotation आंशिक जाँच से गुजरकर बनी हुई NGINX configuration में लिखी गई। सुधार पूरी value जाँचता है और carriage return को सुरक्षित ढंग से संभालता है।
इस पेज के मुख्य शब्द
Ingress object- Kubernetes API resource जो host या path से Service तक routing बताता है। गैर-admin users को इसे बनाने की अनुमति दी जा सकती है।
Annotation validation bypass- Annotation value ऐसे validator से पास हुआ जिसने पूरे value के exact allowed option होने की जगह केवल अनुमत substring ढूँढी।
Carriage return (`\r`)- कुछ formats में line break के लिए उपयोग किया जाने वाला control character। Validation और configuration generation की अलग व्याख्या line boundaries बदल सकती है।
Controller service account- ingress-nginx controller की Kubernetes identity। Upstream notice कहता है कि default permissions में cluster के सभी Secrets तक पहुँच शामिल हो सकती है।
फ्रेमवर्क मैपिंग
- इस गाइड में बताई गई कमजोरी के लिए CWE संदर्भ: CWE-20
मूल कारण विश्लेषण (Root Cause)
CVE-2024-7646 ingress-nginx annotation-validation bypass है, unrestricted custom Lua snippet का मामला नहीं। auth-tls-verify-client validator ने शुरुआत और अंत के anchors के बिना Go regular expression उपयोग किया; इसलिए MatchString किसी लंबे value को स्वीकार कर सकता था यदि उसमें अनुमत विकल्प substring के रूप में मौजूद हो। Annotation में carriage return को बनी हुई NGINX configuration साफ़ करते समय अलग तरह से समझा जा सकता था। Upstream सुधार पूरे value का मिलान आवश्यक करता है और cleanConf में अलग carriage return सुरक्षित रूप से संभालता है। Kubernetes security notice के अनुसार Ingress object बनाने की अनुमति वाला actor validation bypass कर command inject कर controller credentials प्राप्त कर सकता था; default configuration में इनसे cluster के सभी Secrets पढ़े जा सकते हैं। यह उच्च गंभीरता (CVSS 8.8) वाला authenticated Kubernetes API path है, अनाम network request नहीं। परियोजना मार्च 2026 में retired हुई; पुराने fix पर upgrade केवल तत्काल containment है। Deployments को maintained controller या Gateway API implementation पर migrate करना चाहिए।
हमले का चरण-दर-चरण प्रवाह
उपयोगकर्ता Ingress बना सकता है
हमलावर को Kubernetes API से Ingress object बनाने की अनुमति चाहिए। Multi-tenant clusters में जोखिम अधिक है जहाँ यह अधिकार application teams को दिया जाता है।
Annotation partial match से पास होता है
कमजोर auth-tls-verify-client regex में anchors नहीं थे। इसलिए Go MatchString exact permitted value के बजाय ऐसा लंबा value स्वीकार कर सकता था जिसमें अनुमत विकल्प मौजूद हो।
Carriage return config boundary बदलता है
Annotation generated NGINX configuration में शामिल होती है। Fix series whole-value validation और config cleanup के दौरान bare carriage return handling दोनों ठीक करती है।
Controller identity उजागर होती है
Kubernetes notice कहता है कि command injection controller credentials प्राप्त कर सकता है। Default में service account सभी Secrets पढ़ सकता है; वास्तविक प्रभाव deployed RBAC पर निर्भर है।
सोर्स कोड: कमज़ोर बनाम सुरक्षित कार्यान्वयन
ये CVE-2024-7646 के upstream fixes के अंश हैं: PR #11719 auth-tls-verify-client के अनुमत values को anchor करता है और PR #11721 cleanConf में bare carriage return संभालता है। 1.10 branch में PR #11718 और #11722 के अनुरूप बदलाव आए। असंबंधित function context छोड़ा गया है।
// internal/ingress/annotations/authtls/main.go (पहले)
authVerifyClientRegex = regexp.MustCompile(`on|off|optional|optional_no_ca`)
// internal/ingress/controller/template/template.go (पहले)
switch c {
case ' ', '\t':
needOutput = lineStarted
case '\n':
needOutput = !(!lineStarted && emptyLineWritten)
nextLineStarted = false
}
// internal/ingress/annotations/authtls/main.go (ठीक किया गया)
authVerifyClientRegex = regexp.MustCompile(`^(on|off|optional|optional_no_ca)$`)
// internal/ingress/controller/template/template.go (ठीक किया गया)
switch c {
case '\r':
rest := in.Bytes()
if len(rest) > 0 && rest[0] != '\n' {
c = ' '
needOutput = lineStarted
}
case '\n':
needOutput = !(!lineStarted && emptyLineWritten)
nextLineStarted = false
}
इंजीनियरिंग और सिस्टम सुरक्षा चेकलिस्ट
- ✓Kubernetes RBAC से Ingress बनाने या संपादित करने की अनुमति सीमित करें, विशेषकर multi-tenant clusters में; इस अधिकार से vulnerable path तक पहुँचा जा सकता था।
- ✓ऐतिहासिक containment के लिए 1.11 line में ingress-nginx 1.11.2 या बाद में, अथवा 1.10 line में 1.10.4 या बाद में upgrade करें। Vendor image और chart के exact versions जाँचें।
- ✓Upstream notice के अनुसार Kubernetes audit logs में carriage return (
\r) वाली Ingress annotations खोजें, जिसमेंnginx.ingress.kubernetes.io/auth-tls-verify-clientभी शामिल है। - ✓
allow-snippet-annotations: "false"को इस CVE का fix न मानें: प्रभावित path annotation validation और configuration line handling था, केवल optional snippet feature नहीं। - ✓Ingress NGINX मार्च 2026 में retired हुआ। Maintained controller या Gateway API implementation पर migration plan करें; पुराने fix के बाद नए security updates नहीं मिलेंगे।
स्रोत
- Kubernetes security response — CVE-2024-7646 का दायरा, versions, detection और mitigation
- Upstream fix — auth-tls-verify-client values को anchor करना (PR #11719)
- Upstream fix — generated config में carriage return साफ़ करना (PR #11721)
- NVD — CVE-2024-7646
- Kubernetes — Ingress NGINX retirement और migration guidance
- MITRE CWE-20 — improper input validation