CVE-2024-39677
NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities
NHibernate is an object-relational mapper for the .NET framework. A SQL injection vulnerability exists in some types implementing ILiteralType.ObjectToSQLString. Callers of these methods are exposed to the vulnerability, which includes mappings using inheritance with discriminator values; HQL queries referencing a static field of the application; users of the SqlInsertBuilder and SqlUpdateBuilder utilities, calling their AddColumn overload taking a literal value; and any direct use of the ObjectToSQLString methods for building SQL queries on the user side. This vulnerability is fixed in 5.4.9 and 5.5.2.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- High
- Privileges needed
- None
- User interaction
- None
What an attacker can affect
- Confidentiality
- None
- Integrity
- High
- Availability
- None
Exploit likelihood
What each source reports
CVE List Score used
5.9
NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities
NHibernate is an object-relational mapper for the .NET framework. A SQL injection vulnerability exists in some types implementing ILiteralType.ObjectToSQLString. Callers of these methods are exposed to the vulnerability, which includes mappings using inheritance with discriminator values; HQL queries referencing a static field of the application; users of the SqlInsertBuilder and SqlUpdateBuilder utilities, calling their AddColumn overload taking a literal value; and any direct use of the ObjectToSQLString methods for building SQL queries on the user side. This vulnerability is fixed in 5.4.9 and 5.5.2.
- Record
CVE-2024-39677- CVSS 3.1
- 5.9 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N - Weakness
- CWE-89
- Updated
- 2026-11-02
EUVDEUVD-2024-2335
5.9
NHibernate is an object-relational mapper for the .NET framework. A SQL injection vulnerability exists in some types implementing ILiteralType.ObjectToSQLString. Callers of these methods are exposed to the vulnerability, which includes mappings using inheritance with discriminator values; HQL queries referencing a static field of the application; users of the SqlInsertBuilder and SqlUpdateBuilder utilities, calling their AddColumn overload taking a literal value; and any direct use of the ObjectToSQLString methods for building SQL queries on the user side. This vulnerability is fixed in 5.4.9 and 5.5.2.
- Record
EUVD-2024-2335- CVSS 3.1
- 5.9 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N - Updated
- 2026-11-03
GitHub AdvisoriesGHSA-fg4q-ccq8-3r5q
8.2
NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities
Impact
A SQL injection vulnerability exists in some types implementing ILiteralType.ObjectToSQLString. Callers of these methods are exposed to the vulnerability, which includes:
- Mappings using inheritance with discriminator values:
- 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.
- The current culture settings for formatting the discriminator value type could be altered in a way resulting into SQL injections with the discriminator values.
- HQL queries referencing a static field of the application.
- Users of the
SqlInsertBuilderandSqlUpdateBuilderutilities, calling theirAddColumnoverload taking a literal value. These overloads are unused by NHibernate but could be used by users referencing directly these utilities. - Any direct use of the
ObjectToSQLStringmethods for building SQL queries on the user side.
Patches
Releases 5.4.9 and 5.5.2.
Workarounds
- Ensure the application does not use the features listed above.
- For discriminator usages, ensure the discriminator values in the mappings do not contain quotes for string discriminators. Furthermore, for types which
ToStringconversion 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.
References
- Record
GHSA-fg4q-ccq8-3r5q- CVSS 4.0
- 8.2 High
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 - CVSS 3.1
- 5.9 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N - Weakness
- CWE-89
- Updated
- 2026-11-02
NVD
5.9
NHibernate is an object-relational mapper for the .NET framework. A SQL injection vulnerability exists in some types implementing ILiteralType.ObjectToSQLString. Callers of these methods are exposed to the vulnerability, which includes mappings using inheritance with discriminator values; HQL queries referencing a static field of the application; users of the SqlInsertBuilder and SqlUpdateBuilder utilities, calling their AddColumn overload taking a literal value; and any direct use of the ObjectToSQLString methods for building SQL queries on the user side. This vulnerability is fixed in 5.4.9 and 5.5.2.
- Record
CVE-2024-39677- CVSS 3.1
- 5.9 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N - CVSS 3.1
- 9.8 Critical
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H - Weakness
- CWE-89
- Updated
- 2026-11-02
OSV
5.9
NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities
NHibernate is an object-relational mapper for the .NET framework. A SQL injection vulnerability exists in some types implementing ILiteralType.ObjectToSQLString. Callers of these methods are exposed to the vulnerability, which includes mappings using inheritance with discriminator values; HQL queries referencing a static field of the application; users of the SqlInsertBuilder and SqlUpdateBuilder utilities, calling their AddColumn overload taking a literal value; and any direct use of the ObjectToSQLString methods for building SQL queries on the user side. This vulnerability is fixed in 5.4.9 and 5.5.2.
- Record
CVE-2024-39677- CVSS 3.1
- 5.9 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N - Weakness
- CWE-89
- Updated
- 2026-11-02
OSVGHSA-fg4q-ccq8-3r5q
8.2
NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities
Impact
A SQL injection vulnerability exists in some types implementing ILiteralType.ObjectToSQLString. Callers of these methods are exposed to the vulnerability, which includes:
- Mappings using inheritance with discriminator values:
- 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.
- The current culture settings for formatting the discriminator value type could be altered in a way resulting into SQL injections with the discriminator values.
- HQL queries referencing a static field of the application.
- Users of the
SqlInsertBuilderandSqlUpdateBuilderutilities, calling theirAddColumnoverload taking a literal value. These overloads are unused by NHibernate but could be used by users referencing directly these utilities. - Any direct use of the
ObjectToSQLStringmethods for building SQL queries on the user side.
Patches
Releases 5.4.9 and 5.5.2.
Workarounds
- Ensure the application does not use the features listed above.
- For discriminator usages, ensure the discriminator values in the mappings do not contain quotes for string discriminators. Furthermore, for types which
ToStringconversion 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.
References
- Record
GHSA-fg4q-ccq8-3r5q- CVSS 4.0
- 8.2 High
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 - CVSS 3.1
- 5.9 Medium
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N - Weakness
- CWE-89
- Updated
- 2026-11-02
Affected products
Affected packages
| Package | Affected | Fixed |
|---|---|---|
NHibernateNuGet |
before 5.4.9 | 5.4.9 |
NHibernateNuGet |
5.5.0 up to 5.5.2 | 5.5.2 |
NHibernateNuGet |
before 5.4.9, plus listed versions 2.1.2.40003.0.0.20013.0.0.30013.0.0.40003.1.0.4000 Show 45 moreShow less3.2.0.10013.2.0.10023.2.0.10033.2.0.20013.2.0.20023.2.0.30013.2.0.40003.3.0-CR13.3.0.40003.3.1.40003.3.2.40003.3.3-CR13.3.3.40003.3.3.40013.3.4.40003.3.5.40003.4.0-CR13.4.0.40003.4.1.40004.0.0-Alpha14.0.0-Alpha24.0.0-CR14.0.0.40004.0.1.40004.0.2.40004.0.3.40004.0.4.40004.1.0-CR14.1.0.40004.1.1.40004.1.2.40005.0.05.0.15.0.25.0.35.0.45.0.55.0.65.0.75.0.85.1.05.1.15.1.25.1.35.1.4 |
5.4.9 |
NHibernateNuGet |
5.5.0 up to 5.5.2, plus listed versions 5.5.1 |
5.5.2 |
History
| Recorded | Changed | Sources |
|---|---|---|
| aliases | EUVD | |
| first indexed | CVE List, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2024-39677 is a medium vulnerability (CVSS 5.9) in Nhibernate Nhibernate-core, published July 8, 2024. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.58%, the 47th percentile. Fixed in NHibernate 5.4.9.
References
github.com/nhibernate/nhibernate-core/security/advisories/GHSA-fg4q-ccq8-3r5q
github.com/nhibernate/nhibernate-core/issues/3516
github.com/nhibernate/nhibernate-core/pull/3517
github.com/nhibernate/nhibernate-core/pull/3547
github.com/nhibernate/nhibernate-core/commit/b4a69d1a5ff5744312478d70308329af496e4ba9
nvd.nist.gov/vuln/detail/CVE-2024-39677
github.com/advisories/GHSA-fg4q-ccq8-3r5q
github.com/CVEProject/cvelistV5/tree/main/cves/2024/39xxx/CVE-2024-39677.json
github.com/nhibernate/nhibernate-core
Left out here: 41 versions. The JSON record has them.