Vulnerabilities in pkg:nuget/NHibernate
PACKAGECVE-2024-39677 is a HIGH (CVSS 5.9) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting NHibernate libraries in the NuGet ecosystem. The issue involves nhibernate sql injection vulnerability in discriminator mappings, static fields referenced in hql, and some utilities. Remediation is available by upgrading affected packages to version 5.4.9, 5.5.2.
pkg:nuget/NHibernate
Vulnerability advisories affecting package pkg:nuget/NHibernate. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-fg4q-ccq8-3r5q | CVE-2024-39677 | HIGH | NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities |
CVE-2024-39677 at a Glance
Security Impact
CVSS: 5.9
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N).
How to Fix CVE-2024-39677
To remediate this vulnerability, upgrade all affected NHibernate 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 NHibernate to 5.4.9
Upgrade NHibernate to 5.5.2
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for NHibernate
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-39677, inspect your project dependencies for NHibernate:
inspect dependencies for NHibernate
Analyze the terminal output to locate any version of NHibernate in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.4.9), 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-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In NHibernate, 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-39677 Affected NHibernate Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
NHibernate
|
NuGet |
< 5.4.9
|
5.4.9
|
|
NHibernate
|
NuGet |
≥ 5.5.0
< 5.5.2
|
5.5.2
|
References
Frequently Asked Questions
What is CVE-2024-39677?
Which NHibernate versions are affected?
What version fixes CVE-2024-39677?
Is NHibernate affected?
What is the CVSS score of CVE-2024-39677?
What CWE is associated with CVE-2024-39677?
How can I check NuGet dependencies for CVE-2024-39677?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fg4q-ccq8-3r5q",
"modified" : "2024-11-18T16:26:49Z",
"published" : "2024-07-08T14:20:33Z",
"aliases" : [ "CVE-2024-39677" ],
"summary" : "NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities",
"details" : "### Impact\nA SQL injection vulnerability exists in some types implementing `ILiteralType.ObjectToSQLString`. Callers of these methods are exposed to the vulnerability, which includes:\n - Mappings using inheritance with discriminator values:\n - The discriminator value could be written in the mapping in a way exploiting the vulnerability of the associated discriminator type, if that type is among the vulnerable ones.\n - The current culture settings for formatting the discriminator value type could be altered in a way resulting into SQL injections with the discriminator values.\n - HQL queries referencing a static field of the application.\n - Users of the `SqlInsertBuilder` and `SqlUpdateBuilder` utilities, calling their `AddColumn` overload taking a literal value. These overloads are unused by NHibernate but could be used by users referencing directly these utilities.\n - Any direct use of the `ObjectToSQLString` methods for building SQL queries on the user side.\n\n### Patches\nReleases 5.4.9 and 5.5.2.\n\n### Workarounds\n - Ensure the application does not use the features listed above.\n - For discriminator usages, ensure the discriminator values in the mappings do not contain quotes for string discriminators. Furthermore, for types which `ToString` conversion can be altered to include SQL injections through adequate hacking of the current culture settings, either change for another type, or ensure the used values cannot allow culture exploits, or ensure the application performs sanity checks of the current culture settings. Types sensitive to culture include integers for negative values, dates, times and datetimes, floats and decimals.\n\n### References\n - https://github.com/nhibernate/nhibernate-core/issues/3516\n - https://github.com/nhibernate/nhibernate-core/pull/3517\n - https://github.com/nhibernate/nhibernate-core/pull/3547 ",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "NuGet",
"name" : "NHibernate"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "5.4.9"
} ]
} ]
}, {
"package" : {
"ecosystem" : "NuGet",
"name" : "NHibernate"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "5.5.0"
}, {
"fixed" : "5.5.2"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nhibernate/nhibernate-core/security/advisories/GHSA-fg4q-ccq8-3r5q"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-39677"
}, {
"type" : "WEB",
"url" : "https://github.com/nhibernate/nhibernate-core/issues/3516"
}, {
"type" : "WEB",
"url" : "https://github.com/nhibernate/nhibernate-core/pull/3517"
}, {
"type" : "WEB",
"url" : "https://github.com/nhibernate/nhibernate-core/pull/3547"
}, {
"type" : "WEB",
"url" : "https://github.com/nhibernate/nhibernate-core/commit/b4a69d1a5ff5744312478d70308329af496e4ba9"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nhibernate/nhibernate-core"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-89" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-07-08T14:20:33Z",
"nvd_published_at" : "2024-07-08T15:15:22Z"
}
}