/

CVE-2021-47757

Severity:

HIGH RISK

(8.8)

Unrestricted File Upload in Chikitsa Patient Management

CVE-2021-47757

Analyzed

Vulnerability type

Category:

Unrestricted File Upload

CWE:

CWE-434

Impact:

Authenticated Remote Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Chikitsa Patient Management System 2.0.2 contains an authenticated remote code execution vulnerability in its backup restoration feature, where uploaded backup archives can include executable PHP content.

An authenticated attacker who can restore backups may upload a crafted ZIP file containing a web shell, leading to arbitrary command execution on the server when the malicious file is accessed.

Affected context

This vulnerability exists in deployments of Chikitsa Patient Management System 2.0.2 that expose the backup restore functionality to authenticated users.

The issue typically manifests when:

  • Backup ZIP files are accepted from users and unpacked on the server
  • Extracted files are written into a web-accessible directory
  • File type and content of the archive entries are not strictly validated or restricted to non-executable formats

Exploit preconditions

  • Attack surface: Web application interface, specifically the backup restoration functionality.
  • Required access: Valid authenticated account with permission to restore backups (e.g., admin or user role allowed to manage backups).
  • Trigger point: Upload and restoration of a crafted backup ZIP file that includes a PHP shell or other executable code.
  • Why exploitation is possible: The restore process allows arbitrary files from the backup archive to be written into directories accessible by the web server without robust file type validation, extension filtering, or storage outside the web root. As a result, an attacker can place executable PHP code that the server will interpret.

Why this happens

The underlying issue aligns with CWE-434: Unrestricted Upload of File with Dangerous Type.

The backup restore logic treats user-supplied backup archives as trusted, unpacking their contents without enforcing strict constraints on:

  • Allowed file types (e.g., limiting to data-only formats)
  • File paths relative to the application structure
  • Execution semantics of files once deployed on the server

By failing to restrict uploads to safe, non-executable content and by restoring them in a location interpreted by the PHP engine, the application effectively allows users to introduce new executable files, enabling code execution within the web server context.

Potential impact

  • Remote execution of arbitrary system commands under the web server's privileges
  • Full compromise of the web application and underlying server environment
  • Exfiltration or modification of patient records and other sensitive medical data
  • Installation of backdoors, web shells, or malware for persistent access
  • Pivoting to other internal systems reachable from the compromised server

General mitigation guidance

Effective mitigation typically focuses on constraining what backup restoration can write and ensuring no executable code is introduced:

  • Restrict restored files to a strict set of non-executable types (e.g., SQL dumps, JSON, CSV) and enforce extension and MIME-type checks server-side.
  • Store restored content outside of any web-accessible directory so that uploaded data cannot be executed directly by the web server.
  • Implement server-side validation of archive contents before extraction, rejecting archives that contain unexpected file types, paths, or PHP/other executable extensions.
  • Normalize and sanitize extraction paths to prevent placing files in arbitrary or sensitive directories.
  • Run the web application with least-privilege OS users and disable execution permissions where code execution is not required (e.g., noexec mounts for data directories).
  • Where possible, design backup and restore to operate on structured data (database dumps, serialized records) rather than arbitrary file archives.

How teams detect issues like this

Organizations can use several approaches to detect this class of vulnerability and its exploitation:

  • Static analysis: Flag file upload and archive extraction code paths where user-controlled files are written into web roots or executable directories without extension/content verification.
  • Code review: Look for backup/restore implementations that:
  • Accept user-supplied archives
  • Call ZIP or archive extraction APIs
  • Do not enforce whitelists of safe file types and locations
  • Runtime monitoring: Monitor web server logs for requests to unexpected PHP files or new script paths created shortly after backup restoration operations.
  • File integrity monitoring: Track changes in web root directories, alerting when new executable files (e.g., .php) appear unexpectedly.
  • Automated security testing tools can be configured to test upload/restore endpoints with benign test payloads to identify where executable files end up in web-accessible locations.

Sources

SourceLink
github.comgithub.com/sanskruti-technologies/chikitsa
sourceforge.netsourceforge.net/projects/chikitsa/
chikitsa.iochikitsa.io/
exploit-db.comexploit-db.com/exploits/50572

Frequently asked

questions

It can be exploitable over the internet if the Chikitsa instance is exposed and an attacker can authenticate to the application and access the backup restore interface. No local OS-level access is required.

The attacker must have valid application credentials with permissions to upload and restore backup ZIP files. Unauthenticated users cannot typically exploit this path directly, but credential theft or weak account controls can make exploitation easier.

The most robust fix is to ensure that backup restoration never results in executable files being deployed into web-accessible locations. This involves strict whitelisting of allowed file types, verifying archive contents before extraction, and storing restored data outside the document root or any directory interpreted by the PHP engine.

When designing any upload or import functionality, treat all user-supplied files as untrusted. Apply layered controls: limit accepted types, validate content against expectations, control final storage locations, avoid mixing data with executable code, and enforce least-privilege permissions at the file system and application levels. Incorporate these checks into secure coding standards and automated review processes.

Find out what's already
exploitable in your codebase.