DEV Community

johnettwawers
johnettwawers

Posted on

Bahmni's CSV importer must not let admin input choose the destination path

Bahmni's CSV importer must not let admin input choose the destination path

Bahmni patched a path-traversal issue in the admin CSV import flow tracked as CVE-2026-63194. The affected module is bahmnicore-omod 0.93 and later, with fixed releases in 0.93.1, 1.0.1, 1.1.1, 1.2.1, 1.3.1, and 2.0.1. The advisory describes insufficient validation of input paths that may allow an arbitrary file write.

The import worker has too much authority

CSV import is a normal administrative operation. A hospital may load patient, reference, or integration data from a supplier. If the importer builds a filesystem path from input and writes with the application server's account, a crafted path can move the write outside the intended staging directory.

The attacker's benefit depends on what the server process can reach. A write to an executable web directory, a scheduled-task location, or an application configuration path can become a stronger compromise. Even a write outside the upload folder can overwrite a business file and cause data loss. The advisory does not claim that every deployment has a direct remote-code-execution path, and an analyst should not invent one.

Restrict the route and the filesystem

Apply the fixed module version. Until the update is in place, restrict /openmrs/ws/rest/v1/bahmnicore/admin/upload/* at the ingress or reverse proxy to trusted addresses. Remove Admin Page access for nonessential users and review who can reach the backend API directly.

The application server should write imports to a dedicated directory with no execute permission and no path to configuration files. Canonicalize the final path and verify that it stays below the import root. Run the importer with a low-privilege OS identity. Use an allow-list of expected CSV names and reject absolute paths, parent-directory sequences, and alternate encodings that resolve outside the root.

Monitor the upload path

Log the authenticated user, uploaded filename, resolved destination, file hash, and import result. Alert on files written outside the normal import directory, failed path validation, unexpected file types, and writes followed by a process restart. Review administrative sessions around any suspicious write.

The investigation should preserve the original upload, server-side path, file ownership, access time, and any web requests for the newly written file. If the import account has access to shared storage, inspect the shares for new or modified content.

Verify with a non-production import

Test with a CSV that contains safe path variations and confirm that every write remains under the expected root. Confirm that the application returns a clear validation error without exposing filesystem details. Repeat the test after upgrades and whenever the import library changes.

The fix is partly a code change and partly a boundary change. Parameter validation stops the crafted path from being accepted. Directory permissions limit the damage if a future validation gap appears.

References

Top comments (0)