{"record":{"id":"1e06d1eeb5bc6239","repo":"kubernetes/kops","slug":"attested-document-nonce-mismatch-got-q-expected","errorCode":null,"errorMessage":"attested document nonce mismatch: got=%q expected=%q","messagePattern":"attested document nonce mismatch: got=%q expected=%q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/azure/attest.go","lineNumber":294,"sourceCode":"// its nonce and freshness timestamps.\nfunc parseAndValidateAttestedDocumentContent(content []byte, body []byte) (*attestedData, error) {\n\tvar data attestedData\n\tif err := json.Unmarshal(content, &data); err != nil {\n\t\treturn nil, fmt.Errorf(\"unmarshalling attested data: %w\", err)\n\t}\n\tklog.V(4).Infof(\"Attested document content: vmId=%q subscriptionId=%q createdOn=%q expiresOn=%q\", data.VMId, data.SubscriptionId, data.TimeStamp.CreatedOn, data.TimeStamp.ExpiresOn)\n\n\tif data.VMId == \"\" {\n\t\treturn nil, fmt.Errorf(\"attested document vmId is required\")\n\t}\n\tif data.SubscriptionId == \"\" {\n\t\treturn nil, fmt.Errorf(\"attested document subscriptionId is required\")\n\t}\n\n\t// Verify the nonce matches the request body hash (replay protection).\n\texpectedNonce := nonceForBody(body)\n\tif data.Nonce != expectedNonce {\n\t\treturn nil, fmt.Errorf(\"attested document nonce mismatch: got=%q expected=%q\", data.Nonce, expectedNonce)\n\t}\n\n\tnow := time.Now().UTC()\n\tif data.TimeStamp.CreatedOn == \"\" {\n\t\treturn nil, fmt.Errorf(\"attested document createdOn is required\")\n\t}\n\tcreatedOn, err := time.Parse(attestedDocumentTimeFormat, data.TimeStamp.CreatedOn)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"parsing attested document creation: %w\", err)\n\t}\n\tif createdOn.After(now.Add(attestedDocumentMaxClockSkew)) {\n\t\treturn nil, fmt.Errorf(\"attested document createdOn %s is too far in the future\", data.TimeStamp.CreatedOn)\n\t}\n\toldestAllowedCreatedOn := now.Add(-(attestedDocumentMaxAge + attestedDocumentMaxClockSkew))\n\tif createdOn.Before(oldestAllowedCreatedOn) {\n\t\treturn nil, fmt.Errorf(\"attested document createdOn %s is older than allowed freshness window of %s plus %s clock skew\", data.TimeStamp.CreatedOn, attestedDocumentMaxAge, attestedDocumentMaxClockSkew)\n\t}\n\tklog.V(4).Infof(\"Attested document createdOn is fresh (createdOn=%s now=%s)\", createdOn.Format(time.RFC3339), now.Format(time.RFC3339))","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/azure/attest.go#L276-L312","documentation":"Replay protection check: the nonce in the signed attested document does not match the hash derived from the HTTP request body. The document was signed for a different request (replay) or the body was altered after signing.","triggerScenarios":"Thrown at upup/pkg/fi/cloudup/azure/attest.go:294 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reject the bootstrap request; the token is a replay or the request was tampered with","Have the node re-request attestation so a fresh nonce-bound document is produced"],"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"}