{"record":{"id":"557ce26c64b49688","repo":"kubernetes/kops","slug":"unmarshalling-authorization-token-v","errorCode":null,"errorMessage":"unmarshalling authorization token: %v","messagePattern":"unmarshalling authorization token: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bootstrap/awsbootstrap/verifier.go","lineNumber":222,"sourceCode":"\n\tcallerIdentity, err := a.stsRequestValidator.getCallerIdentityV1(ctx, &a.client, decoded)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn verifyCallerIdentity(ctx, callerIdentity)\n}\n\nfunc (a awsVerifier) verifyTokenV2(ctx context.Context, token string, body []byte, verifyCallerIdentity verifyCallerIdentityFunc) (*bootstrap.VerifyResult, error) {\n\ttoken = strings.TrimPrefix(token, AWSAuthenticationTokenPrefixV2)\n\n\ttokenBytes, err := base64.StdEncoding.DecodeString(token)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"decoding authorization token: %v\", err)\n\t}\n\tvar decoded awsV2Token\n\tif err := json.Unmarshal(tokenBytes, &decoded); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshalling authorization token: %v\", err)\n\t}\n\n\t// Verify the token has signed the body content.\n\tsha := sha256.Sum256(body)\n\tif decoded.SignedHeader.Get(\"X-Kops-Request-SHA\") != base64.RawStdEncoding.EncodeToString(sha[:]) {\n\t\treturn nil, fmt.Errorf(\"incorrect SHA\")\n\t}\n\n\treqURL, err := url.Parse(decoded.URL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing STS request URL: %v\", err)\n\t}\n\tsignedHeaders := sets.New(strings.Split(reqURL.Query().Get(\"X-Amz-SignedHeaders\"), \";\")...)\n\tif !signedHeaders.Has(\"x-kops-request-sha\") {\n\t\treturn nil, fmt.Errorf(\"unexpected signed headers value\")\n\t}\n\n\tif !a.stsRequestValidator.isValidV2(reqURL) {","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/bootstrap/awsbootstrap/verifier.go#L204-L240","documentation":"verifyTokenV2 wraps json.Unmarshal failure after base64-decoding a V2 (AWS SDK SigV4a-style) bootstrap token. The payload must be an awsV2Token containing URL, method and signed headers; invalid JSON indicates a corrupt or forged token.","triggerScenarios":"Thrown at pkg/bootstrap/awsbootstrap/verifier.go:222 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Regenerate the token with a compatible kOps version","Check for payload corruption in transit","Verify token format matches awsV2Token"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}