Headline
CVE-2022-23551: fix: add handler for invalid token requests (#1325) · Azure/aad-pod-identity@7e01970
aad-pod-identity assigns Azure Active Directory identities to Kubernetes applications and has now been deprecated as of 24 October 2022. The NMI component in AAD Pod Identity intercepts and validates token requests based on regex. In this case, a token request made with backslash in the request (example: /metadata/identity\oauth2\token/
) would bypass the NMI validation and be sent to IMDS allowing a pod in the cluster to access identities that it shouldn’t have access to. This issue has been fixed and has been included in AAD Pod Identity release version 1.8.13. If using the AKS pod-managed identities add-on, no action is required. The clusters should now be running the version 1.8.13 release.
@@ -217,6 +217,36 @@ func TestRouterPathPrefix(t *testing.T) { expectedStatusCode: http.StatusOK, expectedBody: "default_handler", }, { name: "invalid token request with \\oauth2", url: `/metadata/identity\oauth2/token/`, expectedStatusCode: http.StatusOK, expectedBody: "invalid_request_handler", }, { name: "invalid token request with \\token", url: `/metadata/identity/oauth2\token/`, expectedStatusCode: http.StatusOK, expectedBody: "invalid_request_handler", }, { name: "invalid token request with \\oauth2\\token", url: `/metadata/identity\oauth2\token/`, expectedStatusCode: http.StatusOK, expectedBody: "invalid_request_handler", }, { name: "invalid token request with mix of / and \\", url: `/metadata/identity/\oauth2\token/`, expectedStatusCode: http.StatusOK, expectedBody: "invalid_request_handler", }, { name: "invalid token request with multiple \\", url: `/metadata/identity\\\oauth2\\token/`, expectedStatusCode: http.StatusOK, expectedBody: "invalid_request_handler", }, }
for _, test := range tests { @@ -225,6 +255,7 @@ func TestRouterPathPrefix(t *testing.T) { defer teardown()
rtr.PathPrefix(tokenPathPrefix).HandlerFunc(testTokenHandler) rtr.MatcherFunc(invalidTokenPathMatcher).HandlerFunc(testInvalidRequestHandler) rtr.PathPrefix(hostTokenPathPrefix).HandlerFunc(testHostTokenHandler) rtr.PathPrefix(instancePathPrefix).HandlerFunc(testInstanceHandler) rtr.PathPrefix(“/”).HandlerFunc(testDefaultHandler) @@ -263,3 +294,7 @@ func testInstanceHandler(w http.ResponseWriter, r *http.Request) { func testDefaultHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, “default_handler\n”) }
func testInvalidRequestHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, “invalid_request_handler\n”) }