{"id":"CVE-2024-37298","aliases":["CVE-2024-37298","GHSA-3669-72x9-r9p3","GO-2024-2958"],"related":["CGA-c6pm-6625-xr6w"],"kind":"vulnerability","state":"published","title":"Potential memory exhaustion attack due to sparse slice deserialization","summary":"gorilla/schema converts structs to and from form values. Prior to version 1.4.1 Running `schema.Decoder.Decode()` on a struct that has a field of type `[]struct{...}` opens it up to malicious attacks regarding memory allocations, taking advantage of the sparse slice functionality. Any use of `schema.Decoder.Decode()` on a struct with arrays of other structs could be vulnerable to this memory exhaustion vulnerability. Version 1.4.1 contains a patch for the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"gorilla/schema converts structs to and from form values. Prior to version 1.4.1 Running `schema.Decoder.Decode()` on a struct that has a field of type `[]struct{...}` opens it up to malicious attacks regarding memory allocations, taking advantage of the sparse slice functionality. Any use of `schema.Decoder.Decode()` on a struct with arrays of other structs could be vulnerable to this memory exhaustion vulnerability. Version 1.4.1 contains a patch for the issue.","source":"cvelist"},{"lang":"en","text":"### Details\n\nRunning `schema.Decoder.Decode()` on a struct that has a field of type `[]struct{...}` opens it up to malicious attacks regarding memory allocations, taking advantage of the sparse slice functionality. For instance, in the Proof of Concept written below, someone can specify to set a field of the billionth element and it will allocate all other elements before it in the slice. \n\nIn the local environment environment for my project, I was able to call an endpoint like `/innocent_endpoint?arr.10000000.X=1` and freeze my system from the memory allocation while parsing `r.Form`. I think [this line](https://github.com/gorilla/schema/blob/main/decoder.go#L223) is responsible for allocating the slice, although I haven't tested to make sure, so it's just an educated guess.\n\n### Proof of Concept\n\nThe following proof of concept works on both v1.2.0 and v1.2.1. I have not tested earlier versions.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/gorilla/schema\"\n)\n\nfunc main() {\n\tdec := schema.NewDecoder()\n\tvar result struct {\n\t\tArr []struct{ Val int }\n\t}\n\tif err := dec.Decode(&result, map[string][]string{\"arr.1000000000.Val\": {\"1\"}}); err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"%#+v\\n\", result)\n}\n\n```\n\n### Impact\n\nAny use of `schema.Decoder.Decode()` on a struct with arrays of other structs could be vulnerable to this memory exhaustion vulnerability. There seems to be no possible solution that a developer using this library can do to disable this behaviour without fixing it in this project, so all uses of Decode that fall under this umbrella are affected. A fix that doesn't require a major change may also be harder to find, since it could break compatibility with some other intended use-cases.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Potential memory exhaustion attack due to sparse slice deserialization in github.com/gorilla/schema","format":"markdown","source":"go"},{"lang":"es","text":"gorilla/schema convierte estructuras hacia y desde valores de formulario. Antes de la versión 1.4.1 La ejecución de `schema.Decoder.Decode()` en una estructura que tiene un campo de tipo `[]struct{...}` la abre a ataques maliciosos relacionados con las asignaciones de memoria, aprovechando la escasez de memoria. funcionalidad de corte. Cualquier uso de `schema.Decoder.Decode()` en una estructura con matrices de otras estructuras podría ser vulnerable a esta vulnerabilidad de agotamiento de la memoria. La versión 1.4.1 contiene un parche para el problema.","source":"nvd"}],"published":"2024-07-01T18:27:33.952Z","modified":"2026-09-10T03:50:16.191Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-770"],"affected":[{"ranges":[{"version":"< 1.4.1","status":"affected"}],"vendor":"gorilla","product":"schema","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","fixed":"1.4.1","status":"affected"}],"vendor":"gorillatoolkit","product":"schema","cpe":"cpe:2.3:a:gorillatoolkit:schema:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.4.1"}],"ecosystem":"Go","package":"github.com/gorilla/schema","purl":"pkg:golang/github.com/gorilla/schema","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"1.4.1"}],"ecosystem":"Go","package":"github.com/gorilla/schema","purl":"pkg:golang/github.com/gorilla/schema","source":"go"}],"references":[{"url":"https://github.com/gorilla/schema/security/advisories/GHSA-3669-72x9-r9p3","tags":["advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/gorilla/schema/commit/cd59f2f12cbdfa9c06aa63e425d1fe4a806967ff","tags":["fix","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/gorilla/schema/blob/main/decoder.go#L223","tags":["web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-37298","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/gorilla/schema","tags":["package"],"sources":["ghsa"]}],"credits":["@AlexVasiluta"],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2024-07-02T14:16:14.834Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-37298","url":"https://www.cve.org/CVERecord?id=CVE-2024-37298","licence":"CVE Terms of Use","modified":"2024-08-02T03:50:55.675Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-3669-72x9-r9p3","url":"https://github.com/advisories/GHSA-3669-72x9-r9p3","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:16.191Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2024-2958","url":"https://pkg.go.dev/vuln/GO-2024-2958","licence":"CC-BY-4.0","modified":"2026-02-04T02:53:15.821Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-37298","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-37298","licence":"Public domain","modified":"2026-06-17T07:38:05.733Z"}],"updatedAt":"2026-11-25T22:58:42.415Z","epss":{"score":0.01096,"percentile":0.66489,"date":"2026-12-01T12:00:22.000Z"}}