GHSA-3ccm-4qq2-5wrp: Github.com/edgelesssys/contrast Constrata's Coordinator Transit Engine `ciphertextContainer.UnmarshalJSON` Vulnerability
MODERATEGHSA-3ccm-4qq2-5wrp is a MODERATE (CVSS 4.3) constrata's coordinator transit engine `ciphertextcontainer.unmarshaljson` vulnerability (CWE-129: Improper Validation of Array Index) affecting Github.com/edgelesssys/contrast libraries in the Go ecosystem. The issue involves constrata's coordinator transit engine `ciphertextcontainer.unmarshaljson` panics on attacker-controlled short ciphertexts. Remediation is available by upgrading affected packages to version 1.21.0.
GHSA-3ccm-4qq2-5wrp at a Glance
Security Impact
CVSS: 4.3
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L).
How to Fix GHSA-3ccm-4qq2-5wrp
To remediate this vulnerability, upgrade all affected Github.com/edgelesssys/contrast dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/edgelesssys/contrast to 1.21.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/edgelesssys/contrast
How to Check if You Are Affected
To determine whether your application is affected by GHSA-3ccm-4qq2-5wrp, inspect your project dependencies for Github.com/edgelesssys/contrast:
inspect dependencies for github.com/edgelesssys/contrast
Analyze the terminal output to locate any version of Github.com/edgelesssys/contrast in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.21.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-129: Improper Validation of Array Index, where the product uses untrusted input when calculating or using an array index, but the product does not validate or incorrectly validates the index to ensure the index references a valid position within the array. In Github.com/edgelesssys/contrast, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-3ccm-4qq2-5wrp Affected Github.com/edgelesssys/contrast Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/edgelesssys/contrast
|
Go |
< 1.21.0
|
1.21.0
|
References
Frequently Asked Questions
What is GHSA-3ccm-4qq2-5wrp?
Which Github.com/edgelesssys/contrast versions are affected?
What version fixes GHSA-3ccm-4qq2-5wrp?
Is github.com/edgelesssys/contrast affected?
What is the CVSS score of GHSA-3ccm-4qq2-5wrp?
What CWE is associated with GHSA-3ccm-4qq2-5wrp?
How can I check Go dependencies for GHSA-3ccm-4qq2-5wrp?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3ccm-4qq2-5wrp",
"modified" : "2026-07-01T18:47:53Z",
"published" : "2026-07-01T18:47:53Z",
"aliases" : [ ],
"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.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/edgelesssys/contrast"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.21.0"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 1.20.0"
}
} ],
"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"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-129" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-07-01T18:47:53Z",
"nvd_published_at" : null
}
}