Blind SQL injection in Bahmni's flowSheet endpoint
One request parameter went into a native SQL query unbound, while the two beside it in the same method were bound correctly. Any authenticated Bahmni user, including one with no privileges, could read arbitrary data from the clinical database: other patients' records, identifiers, and the stored password hashes. Fixed in 3.0.1.
Bahmni is an open-source hospital system, an OpenMRS distribution that clinics and hospitals run as their main electronic medical record. One of its REST endpoints took a request parameter and placed it, unescaped and unbound, into a native SQL query. Any user with a valid login could turn that into a blind SQL injection and read whatever the application’s database account could read. In a patient record system that is other patients’ clinical data, their identifiers, and the stored password hashes. It is fixed in release 3.0.1.
I reported it privately to the Bahmni team, they fixed it, and the advisory is public as GHSA-jw4p-m348-j6gm, with the finding credited to me. A CVE has been requested and is waiting on assignment. The fix has shipped, so I can walk through how it worked. I have kept the actual payloads out of it.
Where the bug lives
The flowSheet endpoint, GET /openmrs/ws/rest/v1/bahmnicore/observations/flowSheet, returns a patient’s observations for a given set of clinical forms over time. It is the sort of read a clinician makes constantly, so it is reachable by ordinary application users rather than administrators. That is what sets how far this bug reaches.
Internally the endpoint builds its query in ObsDaoImpl.getObsForFormBuilderForms from three inputs: a patient UUID, a list of visit IDs, and a list of form names. Two of the three were bound as query parameters, the way you are supposed to. The third, formNames, was formatted into the SQL string with String.format and dropped inside a REGEXP ‘...’ literal.
the formNames path, before 3.0.1 and after
// bahmnicore-api ObsDaoImpl.getObsForFormBuilderForms()
// before (affected, 0.93 to 3.0.0): formNames formatted straight into the SQL
queryString.append(String.format(
"where obs.form_namespace_and_path REGEXP '%s' ",
commaSeparatedFormNamesPattern(formNames)));
queryToGetObs.setParameter("patientUuid", patientUuid); // already bound
queryToGetObs.setParameterList("visitIds", listOfVisitIds); // already bound
// after (fixed, 3.0.1): formNames bound like its siblings, metacharacters escaped
queryString.append("where obs.form_namespace_and_path REGEXP :formNamesPattern ");
queryToGetObs.setParameter("formNamesPattern", commaSeparatedFormNamesPattern(formNames));So the values that decided which forms to match were attacker-controlled text sitting inside the query, next to two sibling parameters that were handled correctly. It is an easy one to miss in review, since the obvious user input was already bound and this one quietly was not.
How a form name becomes SQL
Each form name is wrapped in a little regular expression and the results are joined together, then the whole thing is placed between single quotes in the SQL text. The moment a form name contains a single quote of its own, it closes that string literal early and the rest of the value is read by the database as SQL. From there you are no longer choosing which forms to match. You are writing part of the query.
The endpoint does not hand you the result of your injected query directly, so I demonstrated it as a time-based blind injection: a condition that tells the database to pause for a few seconds when it is true, and to answer immediately when it is false. You ask one yes-or-no question at a time, such as whether the next character of a value falls in a given range, and read the answer off the clock. It is slow going, but with enough requests you can pull out anything the query’s database account can reach. I confirmed the timing fired on the affected build and went silent on 3.0.1, measured in the database’s own query log rather than guessed from the response.
What a logged-in user could reach
In Bahmni the application’s database account reaches the whole clinical schema, so the read is not confined to the flowSheet data. The advisory names the obvious targets: observations belonging to other patients, such as diagnoses and results, patient identifiers, and the users.password credential hashes. That last one is the part that should give you pause. A feature for pulling up a patient’s clinical forms could read the table that holds every account’s password hash.
The privilege bar is low. This is not an unauthenticated bug, you need a session, but any session will do, including an account whose role carries no privileges at all. In a hospital system where a lot of people hold an ordinary login, that is a wide door into data they were never meant to touch. I scored it CVSS 3.1 6.5 (Medium), CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N, weakness CWE-89. It is reachable over the network, needs low privilege, and gives up confidentiality in full with no direct integrity or availability impact. A confidentiality-only score looks moderate on paper, and in a general-purpose app it would be. Here the confidentiality being given up is patient records and credential hashes, so I would not file it as a low.
Pinning it down
Two things are easy to get wrong with a finding like this, so I checked both. The first is whether the vulnerable path is actually live or just dead code that happens to look bad. I ran the endpoint with a benign form name and watched it execute the real query and return the real row, so the sink is reached in normal operation, not behind a flag.
The second is the version range, which is where people tend to be generous with themselves. I did not rely on the source alone. I decompiled the published jars across the recent releases to see exactly where the sink appears and where it disappears. The String.format into REGEXP ‘%s’ is present in the compiled 2.0.1, 2.1.0 and 3.0.0 artifacts, and the first release where it is replaced by the bound :formNamesPattern is 3.0.1. That lines up with the advisory, which marks the whole range from 0.93 onward as affected and 3.0.1 as the fix.
Not the other Bahmni SQL injection
Bahmni has had SQL injection reported before, so it is worth being clear about what this is not. It is not CVE-2026-15477, the SqlQueryHelper /bahmnicore/sql path, and it is not the configurable SQL-search property. Turning off emrapi.sqlSearch.highRiskPatients, the mitigation for that other issue, does nothing here. This is a separate sink in a separate method, and in the same method the patient and visit parameters are bound correctly, which is what tells you the fix for the earlier issues did not happen to cover this one.
The fix
The patch is small and it is the right one. formNames is now bound as a query parameter like its two siblings, and each form name has its regex metacharacters escaped before it goes anywhere near the REGEXP clause, so the regular expression cannot be steered either. There is a regression test whose name does not leave much room for interpretation, shouldTreatMaliciousFormNamesPayloadAsInertDataNotSql.
I did not take their word for it. I pulled bahmnicore-omod 3.0.1 from Maven Central, checked it against the published hash, dropped it into a running instance in place of the development build, and replayed the payloads. Every one came back inert on 3.0.1 and fired on the affected release I kept as a control, the same request giving opposite results on the two builds. I test the release people actually download, not a branch.
If you run Bahmni
Upgrade to 3.0.1 or later. The affected range is wide, every bahmnicore-omod from 0.93 onward, so most older deployments are in scope. If you are pinned to an older line for now, the sink is a single method, ObsDaoImpl.getObsForFormBuilderForms, and the fix is the commit referenced in the advisory.
While you are in there, it is worth looking at the account the application uses to reach the database. The reason a flowSheet read could return password hashes is that the same account can read every table in the schema. A SQL injection is a bad day regardless, but an application database user scoped to only the tables it needs turns a full-schema read into a much smaller one. That will not stop the injection, but it decides how bad the next one is before anyone has found it.
The input that does not look like input
Bugs like this usually come down to the same thing: the dangerous input is the one that does not look like input. Whoever wrote this bound the patient UUID and the visit IDs without thinking about it, because those obviously come from the user. The form names read like an internal detail the application puts together itself, so they went in as plain text. A query that binds almost all of its inputs is the easy kind to trust, and the value left out is the one nobody checks.
Disclosure and timeline
Reported privately in late August 2026. Fix committed on 30 September, released as 3.0.1 on 7 October, and published as advisory GHSA-jw4p-m348-j6gm on 9 October with the finding credited to me. They read the report, reproduced it, fixed it in about five weeks, and credited the finding. A CVE has been requested and is pending assignment.
If you want to recompute the severity for your own deployment, our free CVSS calculator scores 3.1 and 4.0 from the base metrics, and how we approach coordinated disclosure is on our disclosure page.