{"id":"GHSA-3ccm-4qq2-5wrp","aliases":["GO-2026-5864"],"url":"https://o3.security/vulnerability/GHSA-3ccm-4qq2-5wrp","summary":"Constrata's coordinator transit engine `ciphertextContainer.UnmarshalJSON` panics on attacker-controlled short ciphertexts","details":"## Summary\n\n`ciphertextContainer.UnmarshalJSON` decodes the third `:`-separated component of a `vault:vX:base64...` ciphertext and then unconditionally takes a 12-byte prefix slice for the AES-GCM nonce: `c.nonce = fullCiphertext[:aesGCMNonceSize]`. If the decoded blob is shorter than 12 bytes, the slice expression panics. The panic happens before any cryptographic operation, while the JSON body of the request is still being parsed inside the request handler. Because the handler is invoked from `net/http`'s standard handler goroutine, the panic is recovered to a 500 response, but the request handler aborts mid-execution and the recovered panic appears in the Coordinator's logs. An authenticated workload that holds a valid mesh certificate for any `WorkloadSecretID` can trigger the panic at will, producing log spam, request-failure metrics, and a slow but cheap denial of service against the transit-engine endpoint.\n\n## Details\n\n### the panicking slice\n\n`coordinator/internal/transitengineapi/crypto.go:64-88`:\n\n```go\n// UnmarshalJSON umarshalls a json string to a ciphertextContainer holding the version prefix,\n// decoded base64 nonce and ciphertext.\nfunc (c *ciphertextContainer) UnmarshalJSON(data []byte) error {\n\tvar encoded string\n\tif err := json.Unmarshal(data, &encoded); err != nil {\n\t\treturn err\n\t}\n\t// Split \"vault:vX:base64\" format\n\tparts := strings.SplitN(encoded, \":\", 3)\n\tif len(parts) < 3 {\n\t\treturn fmt.Errorf(\"invalid ciphertext format\")\n\t}\n\tversion, err := extractVersion(parts[1])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"ciphertext version: %w\", err)\n\t}\n\tc.keyVersion = version\n\tfullCiphertext, err := base64.StdEncoding.DecodeString(parts[2])\n\tif err != nil {\n\t\treturn fmt.Errorf(\"decoding ciphertext: %w\", err)\n\t}\n\tc.nonce = fullCiphertext[:aesGCMNonceSize]      // PANIC when len(fullCiphertext) < 12\n\tc.ciphertext = fullCiphertext[aesGCMNonceSize:]\n\treturn nil\n}\n```\n\n`aesGCMNonceSize = 12` (defined at line 33). There is no length check on `fullCiphertext`. If `parts[2]` decodes to fewer than 12 bytes (which happens for any base64 string shorter than ~16 characters), the slice expression `fullCiphertext[:aesGCMNonceSize]` triggers Go's runtime panic `runtime error: slice bounds out of range [:12] with length N`.\n\n`UnmarshalJSON` is reached from `parseRequest`:\n\n```go\n// coordinator/internal/transitengineapi/transitengineapi.go:292-302\nfunc parseRequest(r *http.Request, into any) error {\n\tdefer r.Body.Close()\n\tif err := validateContentType(r); err != nil {\n\t\treturn err\n\t}\n\tif err := json.NewDecoder(r.Body).Decode(into); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n```\n\nwhich is called inside `getDecryptHandler` (line 178-237) before any other processing.\n\n### auth requirement is real but trivial to satisfy for any registered workload\n\nThe transit-engine HTTP server (`transitengineapi.go:74-100`) configures `tls.RequireAndVerifyClientCert` with the Coordinator's mesh CA pool. The handler is wrapped by `authorizationMiddleware` (line 348-357) which calls `authorizeWorkloadSecret` (line 241-254). That function reads the `WorkloadSecretOID` extension from the peer cert and requires it to match the URL path's `{name}` segment.\n\nAny workload that has gone through the normal initializer / meshapi flow (`coordinator/internal/meshapi/meshapi.go:71-119`) and has a non-empty `WorkloadSecretID` in its `PolicyEntry` is issued a mesh cert with the matching extension, so the path-name authorisation is automatically satisfied for whichever `workloadSecretID` the manifest assigned to that workload. There is no rate limiting, no proof-of-work, and no audit log on triggering the panic.\n\n### what happens after the panic\n\n`net/http` wraps each handler in a recovered goroutine, so the panic does not crash the Coordinator process. Instead:\n\n1. The Go runtime captures the panic, logs `http: panic serving <peer>: runtime error: slice bounds out of range` to stderr together with a goroutine stack trace.\n2. The connection is hung up without a response body (`http.Server.serve` calls `c.close()` in the recovery path).\n3. The grpc-prometheus / handler metrics (registered via `promRegistry`) record the request as failed.\n4. The recovered panic appears in the Coordinator's logs / journald, creating noise that an operator monitoring a real attack would have to filter out.\n\nA workload that wants to amplify the impact can:\n\n* Loop the request to fill the journal with stack traces (cheap operation per request, expensive log volume).\n* Combine with a second valid workload identity to bypass any per-cert rate limiting added later.\n* Use the panic stack trace (which contains internal source paths) as a fingerprint to determine the exact Coordinator version in lieu of a `/version` endpoint.\n\nThe panic also avoids returning a JSON error body to the caller, so callers that depend on a structured error are forced into a less informative failure mode (HTTP-level connection close).\n\n## PoC\n\nThe bug is deterministic. Drop the following test into `coordinator/internal/transitengineapi/crypto_test.go`:\n\n```go\nfunc TestCiphertextContainer_UnmarshalJSON_ShortBlobPanics(t *testing.T) {\n\t// \"AAAA\" base64-decodes to 3 bytes, well under aesGCMNonceSize=12.\n\tbody := []byte(`\"vault:v1:AAAA\"`)\n\tdefer func() {\n\t\tif r := recover(); r == nil {\n\t\t\tt.Fatalf(\"expected panic, got nil\")\n\t\t}\n\t}()\n\tvar c ciphertextContainer\n\t_ = c.UnmarshalJSON(body) // panics: slice bounds out of range [:12] with length 3\n}\n```\n\nEnd-to-end against a running Coordinator (omitted for static review; would require a Contrast cluster and a mesh-certificate-holding workload):\n\n```bash\n$ curl -k --cert workload.crt --key workload.key \\\n    -H 'Content-Type: application/json' \\\n    -d '{\"ciphertext\":\"vault:v1:AAAA\",\"associated_data\":\"\"}' \\\n    https://coordinator:8200/v1/transit/decrypt/<my-workload-secret-id>\n\n# Connection: closed without HTTP response body.\n# Coordinator log:\n# http: panic serving 10.0.0.5:54321: runtime error: slice bounds out of range [:12] with length 3\n# goroutine 4711 [running]:\n# net/http.(*conn).serve.func1(...)\n#         net/http/server.go:1883 +0xb0\n# panic({0x...?, 0x...?})\n#         runtime/panic.go:770 +0x132\n# github.com/edgelesssys/contrast/coordinator/internal/transitengineapi.(*ciphertextContainer).UnmarshalJSON(...)\n#         coordinator/internal/transitengineapi/crypto.go:85 +0x...\n```\n\n## Impact\n\n* **Soft denial of service** against the transit-engine endpoint per workload identity. The Coordinator process survives because of `net/http`'s panic recovery, but each panicked request consumes CPU for the recovery / stack dump and floods the operator's logs.\n* **Information disclosure via stack trace** in the Coordinator log. The trace pins the Coordinator binary version, the build path of the `transitengineapi` package, and exact line numbers of internal source. This is a low-grade fingerprint, but it is leaked even to operators who would normally only see the binary version through controlled means.\n* **Loss of structured error reporting**: legitimate decrypt requests sharing the panicked log lines may be harder to attribute, and the API consumer sees a connection-close instead of a 4xx response, masking the cause.\n\nCVSS rationale: `AV:N`, `AC:L`, `PR:L` (any workload with a transit-engine permission can do this), `UI:N`, `S:U`, `C:N` / `I:N` / `A:L` (low availability impact: log noise + per-request CPU cost; no full DoS because Go's HTTP panic recovery keeps the process up). Score `3.1`.\n\n## Recommended Fix\n\nValidate the decoded length before slicing. The minimal change at `coordinator/internal/transitengineapi/crypto.go:81-87`:\n\n```go\nfullCiphertext, err := base64.StdEncoding.DecodeString(parts[2])\nif err != nil {\n\treturn fmt.Errorf(\"decoding ciphertext: %w\", err)\n}\nif len(fullCiphertext) < aesGCMNonceSize {\n\treturn fmt.Errorf(\"ciphertext is too short: got %d bytes, expected at least %d for the nonce\", len(fullCiphertext), aesGCMNonceSize)\n}\nc.nonce = fullCiphertext[:aesGCMNonceSize]\nc.ciphertext = fullCiphertext[aesGCMNonceSize:]\nreturn nil\n```\n\nA defence-in-depth tightening would also reject ciphertexts with `len(fullCiphertext) <= aesGCMNonceSize` (which would yield an empty actual ciphertext that AES-GCM open would later reject anyway, but a sharper boundary fails earlier with a clearer error). Add a unit test along the lines of the PoC that asserts a clean error rather than a panic.","published":"2026-07-01T18:47:53Z","modified":"2026-07-07T16:11:37.677219442Z","cvss":{"score":4.3,"severity":"MEDIUM","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L"},"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Go","name":"github.com/edgelesssys/contrast","fixedVersion":"1.21.0"}],"fix":{"url":"https://github.com/edgelesssys/contrast/commit/d6584fbff816037472034f7ad6e08cdbab1d870d","label":"edgelesssys/contrast@d6584fb"},"references":[{"type":"WEB","url":"https://github.com/edgelesssys/contrast/security/advisories/GHSA-3ccm-4qq2-5wrp"},{"type":"WEB","url":"https://github.com/edgelesssys/contrast/commit/d6584fbff816037472034f7ad6e08cdbab1d870d"},{"type":"PACKAGE","url":"https://github.com/edgelesssys/contrast"},{"type":"WEB","url":"https://github.com/edgelesssys/contrast/releases/tag/v1.21.0"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-07-07T16:11:37.677219442Z"}}