{"id":"CVE-2024-39677","aliases":["CVE-2024-39677","GHSA-fg4q-ccq8-3r5q"],"related":[],"kind":"vulnerability","state":"published","title":"NHibernate SQL injection vulnerability in discriminator mappings, static fields referenced in HQL, and some utilities","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"NHibernate es un mapeador relacional de objetos para el framework .NET. Existe una vulnerabilidad de inyección SQL en algunos tipos que implementan ILiteralType.ObjectToSQLString. Quienes llaman a estos métodos están expuestos a la vulnerabilidad, que incluye asignaciones que utilizan herencia con valores discriminadores; Consultas HQL que hacen referencia a un campo estático de la aplicación; usuarios de las utilidades SqlInsertBuilder y SqlUpdateBuilder, llamando a su sobrecarga AddColumn tomando un valor literal; y cualquier uso directo de los métodos ObjectToSQLString para crear consultas SQL en el lado del usuario. Esta vulnerabilidad se solucionó en 5.4.9 y 5.5.2.","source":"nvd"}],"published":"2024-07-08T14:20:33.000Z","modified":"2026-09-10T03:50:16.921Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N","score":5.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N","score":5.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N","score":5.9,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-89"],"affected":[{"ranges":[{"version":"< 5.4.9","status":"affected"},{"version":">= 5.5.0, < 5.5.2","status":"affected"}],"vendor":"nhibernate","product":"nhibernate-core","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"5.4.9"}],"ecosystem":"NuGet","package":"NHibernate","purl":"pkg:nuget/NHibernate","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"5.5.0","status":"affected","fixed":"5.5.2"}],"ecosystem":"NuGet","package":"NHibernate","purl":"pkg:nuget/NHibernate","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"5.4.9"},{"status":"affected","introduced":"5.5.0","fixed":"5.5.2"}],"vendor":"nhibernate","product":"nhibernate-core","cpe":"cpe:2.3:a:nhibernate:nhibernate-core:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/nhibernate/nhibernate-core/security/advisories/GHSA-fg4q-ccq8-3r5q","tags":["vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/nhibernate/nhibernate-core/issues/3516","tags":["issue-tracking","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/nhibernate/nhibernate-core/pull/3517","tags":["issue-tracking","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/nhibernate/nhibernate-core/pull/3547","tags":["issue-tracking","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/nhibernate/nhibernate-core/commit/b4a69d1a5ff5744312478d70308329af496e4ba9","tags":["patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-39677","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/nhibernate/nhibernate-core","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-07-08T17:40:31.738Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-39677","url":"https://www.cve.org/CVERecord?id=CVE-2024-39677","licence":"CVE Terms of Use","modified":"2024-08-02T04:26:15.958Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-fg4q-ccq8-3r5q","url":"https://github.com/advisories/GHSA-fg4q-ccq8-3r5q","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:16.921Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-39677","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-39677","licence":"Public domain","modified":"2026-06-17T07:42:26.680Z"}],"updatedAt":"2026-11-25T22:58:42.556Z","epss":{"score":0.00583,"percentile":0.4923,"date":"2026-12-01T12:00:22.000Z"}}