{"record":{"id":"8e7022f4309bd2c6","repo":"JuliusBrussee/caveman","slug":"kms-generate-probe-w","errorCode":null,"errorMessage":"kms: generate probe: %w","messagePattern":"kms: generate probe: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/kms/kms.go","lineNumber":320,"sourceCode":"}\n\n// ProbePayloadProduction performs the same live round-trip with the payload KEK.\nfunc ProbePayloadProduction(ctx context.Context) error {\n\tif !runtimeenv.IsProduction() {\n\t\treturn nil\n\t}\n\tclient, err := FromPayloadEnvironment()\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn client.Probe(ctx)\n}\n\n// Probe verifies live key access without persisting tenant data.\nfunc (c *Client) Probe(ctx context.Context) error {\n\tplaintext := make([]byte, 32)\n\tif _, err := rand.Read(plaintext); err != nil {\n\t\treturn fmt.Errorf(\"kms: generate probe: %w\", err)\n\t}\n\tenvelope, err := c.Encrypt(ctx, plaintext)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"kms: probe encrypt: %w\", err)\n\t}\n\tdecrypted, err := c.Decrypt(ctx, envelope)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"kms: probe decrypt: %w\", err)\n\t}\n\tif !bytes.Equal(decrypted, plaintext) {\n\t\treturn errors.New(\"kms: probe plaintext mismatch\")\n\t}\n\treturn nil\n}\n\nfunc validateLocation(region, keyID string) error {\n\tif !regionPattern.MatchString(region) {\n\t\treturn errors.New(\"kms: invalid Scaleway region\")","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/kms/kms.go#L302-L338","documentation":"Probe generates 32 random bytes with crypto/rand to run a live encrypt/decrypt round trip; if rand.Read fails the error is wrapped as \"kms: generate probe: %w\". crypto/rand failing means the OS entropy source is unavailable, which is an environment-level problem, not a KMS problem.","triggerScenarios":"Calling Probe on a system where the OS CSPRNG cannot serve bytes — depleted entropy pools on old/virtualized kernels, restricted /dev/urandom, or seccomp/container policies blocking getrandom(2).","commonSituations":"Hardened containers with syscall filters; stripped-down VMs or old kernels lacking getrandom; misconfigured sandboxes in CI.","solutions":["Fix the runtime environment's entropy source (ensure /dev/urandom access or getrandom syscall is permitted).","Check seccomp/AppArmor/container policies that may block getrandom(2) and allowlist it.","Upgrade the kernel/base image if running on an OS with a broken RNG.","Retry Probe once entropy is restored — no tenant data is at risk since no API call was made."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := client.Probe(ctx); err != nil {\n    if strings.Contains(err.Error(), \"generate probe\") {\n        return fmt.Errorf(\"host RNG unavailable; fix entropy source: %w\", err)\n    }\n    return err\n}","preventionTips":["Smoke-test crypto/rand availability in container startup checks.","Avoid seccomp profiles that block getrandom(2).","Run health checks that exercise RNG before production workloads.","Keep host kernels reasonably up to date."],"tags":["go","kms","crypto","entropy","probe"],"backgroundTag":"random-generation-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}