{"record":{"id":"7c016ff0edb10029","repo":"kubernetes/kops","slug":"incorrect-sha","errorCode":null,"errorMessage":"incorrect SHA","messagePattern":"incorrect SHA","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bootstrap/awsbootstrap/verifier.go","lineNumber":166,"sourceCode":"\nfunc (a awsVerifier) verifyTokenV1(ctx context.Context, token string, body []byte, verifyCallerIdentity verifyCallerIdentityFunc) (*bootstrap.VerifyResult, error) {\n\ttoken = strings.TrimPrefix(token, AWSAuthenticationTokenPrefixV1)\n\n\ttokenBytes, err := base64.StdEncoding.DecodeString(token)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"decoding authorization token: %w\", err)\n\t}\n\tvar decoded awsV1Token\n\tif err := json.Unmarshal(tokenBytes, &decoded); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshalling authorization token: %w\", err)\n\t}\n\n\t// Verify the token has signed the body content.\n\tsha := sha256.Sum256(body)\n\tdecodedHeaders := http.Header(decoded)\n\n\tif decodedHeaders.Get(\"X-Kops-Request-SHA\") != base64.RawStdEncoding.EncodeToString(sha[:]) {\n\t\treturn nil, fmt.Errorf(\"incorrect SHA\")\n\t}\n\n\tauthorization := decodedHeaders.Get(\"Authorization\")\n\tif !strings.HasPrefix(authorization, \"AWS4-HMAC-SHA256 \") {\n\t\treturn nil, fmt.Errorf(\"incorrect authorization algorithm\")\n\t}\n\n\tamzSignature := \"\"\n\tamzCredential := \"\"\n\tamzSignedHeaders := \"\"\n\n\tfor _, token := range strings.Split(strings.TrimPrefix(authorization, \"AWS4-HMAC-SHA256 \"), \", \") {\n\t\tkv := strings.SplitN(token, \"=\", 2)\n\t\tif len(kv) == 1 {\n\t\t\treturn nil, fmt.Errorf(\"incorrect authorization format\")\n\t\t}\n\t\tgot := kv[1]\n\t\tswitch kv[0] {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/bootstrap/awsbootstrap/verifier.go#L148-L184","documentation":"Verification guard in verifyTokenV1: the X-Kops-Request-SHA header inside the token does not match the SHA-256 of the presented request body, so the request body was not signed by this token and the request is rejected as unauthenticated.","triggerScenarios":"Thrown at pkg/bootstrap/awsbootstrap/verifier.go:166 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the client signs the exact request body bytes","Check for middleware that rewrites the body","Use a matching kOps client version"],"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"}