{"id":"CVE-2024-27289","aliases":["CVE-2024-27289","GHSA-m7wr-2xf7-cm9p","GO-2024-2605"],"related":["CGA-6fr5-f876-7rfw"],"kind":"vulnerability","state":"published","title":"pgx SQL Injection via Line Comment Creation","summary":"pgx is a PostgreSQL driver and toolkit for Go. Prior to version 4.18.2, SQL injection can occur when all of the following conditions are met: the non-default simple protocol is used; a placeholder for a numeric value must be immediately preceded by a minus; there must be a second placeholder for a string value after the first placeholder; both must be on the same line; and both parameter values must be user-controlled. The problem is resolved in v4.18.2. As a workaround, do not use the simple protocol or do not place a minus directly before a placeholder.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"pgx is a PostgreSQL driver and toolkit for Go. Prior to version 4.18.2, SQL injection can occur when all of the following conditions are met: the non-default simple protocol is used; a placeholder for a numeric value must be immediately preceded by a minus; there must be a second placeholder for a string value after the first placeholder; both must be on the same line; and both parameter values must be user-controlled. The problem is resolved in v4.18.2. As a workaround, do not use the simple protocol or do not place a minus directly before a placeholder.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nSQL injection can occur when all of the following conditions are met:\n\n1. The non-default simple protocol is used.\n2. A placeholder for a numeric value must be immediately preceded by a minus.\n3. There must be a second placeholder for a string value after the first placeholder; both\nmust be on the same line.\n4. Both parameter values must be user-controlled.\n\ne.g. \n\nSimple mode must be enabled:\n\n```go\n// connection string includes \"prefer_simple_protocol=true\"\n// or\n// directly enabled in code\nconfig.ConnConfig.PreferSimpleProtocol = true\n```\n\nParameterized query:\n\n```sql\nSELECT * FROM example WHERE result=-$1 OR name=$2;\n```\n\nParameter values:\n\n`$1` => `-42`\n`$2` => `\"foo\\n 1 AND 1=0 UNION SELECT * FROM secrets; --\"`\n\nResulting query after preparation:\n\n```sql\nSELECT * FROM example WHERE result=--42 OR name= 'foo\n1 AND 1=0 UNION SELECT * FROM secrets; --';\n```\n\n### Patches\n\nThe problem is resolved in v4.18.2.\n\n### Workarounds\n\nDo not use the simple protocol or do not place a minus directly before a placeholder.","format":"markdown","source":"ghsa"},{"lang":"en","text":"SQL injection is possible when the database uses the non-default simple protocol, a minus sign directly precedes a numeric placeholder followed by a string placeholder on the same line, and both parameter values are user-controlled.","format":"markdown","source":"go"},{"lang":"es","text":"pgx es un controlador PostgreSQL y un conjunto de herramientas para Go. Antes de la versión 4.18.2, la inyección SQL puede ocurrir cuando se cumplen todas las condiciones siguientes: se utiliza el protocolo simple no predeterminado; un marcador de posición para un valor numérico debe ir precedido inmediatamente de un signo menos; debe haber un segundo marcador de posición para un valor de cadena después del primer marcador de posición; ambos deben estar en la misma línea; y ambos valores de parámetros deben ser controlados por el usuario. El problema se resuelve en v4.18.2. Como solución alternativa, no utilice el protocolo simple ni coloque un signo menos directamente antes de un marcador de posición.","source":"nvd"}],"published":"2024-03-04T20:13:11.000Z","modified":"2026-09-10T03:50:10.592Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"}],"cwes":["CWE-89"],"affected":[{"ranges":[{"version":"< 4.18.2","status":"affected"}],"vendor":"jackc","product":"pgx","source":"cvelist"},{"ranges":[{"type":"custom","introduced":"0","fixed":"4.18.2","status":"affected"}],"vendor":"jackc","product":"pgx","cpe":"cpe:2.3:a:jackc:pgx:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"4.18.2"}],"ecosystem":"Go","package":"github.com/jackc/pgx","purl":"pkg:golang/github.com/jackc/pgx","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"4.18.2"}],"ecosystem":"Go","package":"github.com/jackc/pgx/v4","purl":"pkg:golang/github.com/jackc/pgx/v4","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/jackc/pgx","purl":"pkg:golang/github.com/jackc/pgx","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"4.18.2"}],"ecosystem":"Go","package":"github.com/jackc/pgx/v4","purl":"pkg:golang/github.com/jackc/pgx/v4","source":"go"},{"ranges":[{"status":"affected","fixed":"4.18.2"}],"vendor":"jackc","product":"pgx","cpe":"cpe:2.3:a:jackc:pgx:*:*:*:*:*:go:*:*","source":"nvd"}],"references":[{"url":"https://github.com/jackc/pgx/security/advisories/GHSA-m7wr-2xf7-cm9p","tags":["advisory","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/jackc/pgx/commit/f94eb0e2f96782042c96801b5ac448f44f0a81df","tags":["fix","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://www.sonarsource.com/blog/double-dash-double-trouble-a-subtle-sql-injection-flaw/","tags":["third-party-advisory"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-27289","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/jackc/pgx","tags":["package"],"sources":["ghsa"]},{"url":"https://www.sonarsource.com/blog/double-dash-double-trouble-a-subtle-sql-injection-flaw","tags":["web"],"sources":["ghsa"]}],"credits":["paul-gerste-sonarsource"],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2024-07-24T14:13:55.313Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-27289","url":"https://www.cve.org/CVERecord?id=CVE-2024-27289","licence":"CVE Terms of Use","modified":"2025-06-12T15:45:56.361Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-m7wr-2xf7-cm9p","url":"https://github.com/advisories/GHSA-m7wr-2xf7-cm9p","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:10.592Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2024-2605","url":"https://pkg.go.dev/vuln/GO-2024-2605","licence":"CC-BY-4.0","modified":"2026-02-04T03:50:07.714Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-27289","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-27289","licence":"Public domain","modified":"2026-06-17T07:19:34.997Z"}],"updatedAt":"2026-11-25T22:58:37.309Z","epss":{"score":0.00847,"percentile":0.5919,"date":"2026-12-01T12:00:22.000Z"}}