CVE-2024-37298: Github.com/gorilla/schema Potential Memory Exhaustion Attack Due Vulnerability
HIGHCVE-2024-37298 is a HIGH (CVSS 7.5) potential memory exhaustion attack due vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Github.com/gorilla/schema libraries in the Go ecosystem. The issue involves potential memory exhaustion attack due to sparse slice deserialization. Remediation is available by upgrading affected packages to version 1.4.1.
CVE-2024-37298 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2024-37298
To remediate this vulnerability, upgrade all affected Github.com/gorilla/schema 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/gorilla/schema to 1.4.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/gorilla/schema
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-37298, inspect your project dependencies for Github.com/gorilla/schema:
inspect dependencies for github.com/gorilla/schema
Analyze the terminal output to locate any version of Github.com/gorilla/schema in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.1), 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-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Github.com/gorilla/schema, 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
CVE-2024-37298 Affected Github.com/gorilla/schema Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/gorilla/schema
|
Go |
< 1.4.1
|
1.4.1
|
References
Frequently Asked Questions
What is CVE-2024-37298?
Which Github.com/gorilla/schema versions are affected?
What version fixes CVE-2024-37298?
Is github.com/gorilla/schema affected?
What is the CVSS score of CVE-2024-37298?
What CWE is associated with CVE-2024-37298?
How can I check Go dependencies for CVE-2024-37298?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-3669-72x9-r9p3",
"modified" : "2024-07-05T21:29:07Z",
"published" : "2024-07-01T20:35:12Z",
"aliases" : [ "CVE-2024-37298" ],
"summary" : "Potential memory exhaustion attack due to sparse slice deserialization",
"details" : "### 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.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/gorilla/schema"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.4.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/gorilla/schema/security/advisories/GHSA-3669-72x9-r9p3"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-37298"
}, {
"type" : "WEB",
"url" : "https://github.com/gorilla/schema/commit/cd59f2f12cbdfa9c06aa63e425d1fe4a806967ff"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/gorilla/schema"
}, {
"type" : "WEB",
"url" : "https://github.com/gorilla/schema/blob/main/decoder.go#L223"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-770" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-07-01T20:35:12Z",
"nvd_published_at" : "2024-07-01T19:15:04Z"
}
}