All posts

A Practical Guide to EHR Security for Legacy Systems

Banner titled A Practical Guide to EHR Security for Legacy Systems, with the Forge hammer logo inside a hexagon of six icons: a shield, key, lock, document, server and heart.

TL;DR

Suppose a regional health system runs a self-hosted EHR that its team has extended for fifteen years. It holds patient charts, prescriptions, and a patient portal, and it still deploys from a compose file nobody has opened in a while. The new CISO asks one question at the first review: what would an auditor flag first, and what do we fix this quarter?

Most teams answer with a pen test report or a scanner export. Both are useful, yet neither shows where the code itself is weak or what to build next. This guide shows how to assess the security of a legacy EHR, rank the gaps, and turn them into a spec, using a real open-source EHR as the example.

What Is EHR Security?

EHR security is the set of technical and operational controls that keep electronic health records confidential, accurate, and available. It covers who can log in, what data a request can change, how documents are stored, how data moves over the network, and what gets logged. For a legacy EHR, the first decision is which gaps to close first; how to close each one comes after.

What Makes a Legacy EHR a Security Risk?

Age alone does not make an EHR risky. It becomes risky when it still handles patient data but its defaults and boundaries were set for an earlier era. The common signs are:

  • Sample credentials in production: Deployment files ship with default database and admin passwords that nobody is forced to change.
  • Unchecked input: API routes accept request bodies without strict checks on format, size, or shape.
  • Loose file handling: Clinical document uploads go to storage without a clear policy on paths, file types, or scanning.
  • Implicit trust at sign-in: The app fetches identity provider keys without limits on where it fetches them from.
  • Unmanaged dependencies: Frontend libraries arrive from remote archives outside any lockfile, often years out of date.
  • Weak transport settings: Plain HTTP stays open, and security headers are left to whoever deploys the app.

A ten-year-old EHR with strict input checks, managed secrets, and current libraries is in good shape. A three-year-old portal that ships with admin/pass is not.

Why Is Healthcare Cybersecurity Urgent for Legacy EHRs in 2026?

Three pressures have landed at the same time:

  • Outages change patient care the same day. UNM Health diverted ambulances for about two hours on October 26 from New Mexico’s only Level 1 trauma center while it contained a cyber incident.
  • Breaches reach a huge share of patients. One clearinghouse breach exposed data for nearly 193 million people, as the TL;DR figure shows.
  • The rules are tightening. The proposed HIPAA Security Rule update would turn controls such as MFA and segmentation into requirements. The current rule stays in force until a final rule is published.

None of these incidents were traced to one old application, so read them as a picture of the stakes. They also do not say which part of your EHR to fix first. That takes a consistent look at the code.

Which HIPAA Security Rule Safeguards Apply to EHR Security?

The HIPAA Security Rule’s technical safeguards name five standards: access control, audit controls, integrity, person or entity authentication, and transmission security. Security and compliance leads usually ask which of them each fix supports.

Risk areaWhat it protectsTechnical safeguard
Sample credentialsWho can log in to the app and the databaseAccess control, person or entity authentication
Identity provider keysWhich keys are trusted at sign-inPerson or entity authentication
Request parsingWhat a write request can change in a recordIntegrity
Document uploadWhat lands in clinical document storageIntegrity
Frontend dependenciesThe code that runs in a clinician’s browserIntegrity
Transport settingsPatient data moving between browser, API, and serverTransmission security

Audit controls are the one standard this list does not cover. Treat audit logging as its own workstream, and our healthcare IT modernization guide covers immutable audit records in detail.

How Do You Assess the Security of a Legacy EHR?

Assess the code and the deployment together, with the same measures every time, so results can be compared across applications and across quarters.

AreaWhat to checkWhere the evidence lives
SecretsDefault or hard-coded passwords, keys in configCompose files, env files, config classes
InputHow request bodies are parsed and validatedAPI route files, controllers
FilesUpload paths, allowed types, size limits, scanningUpload routes, document services
IdentityHow tokens and keys are fetched and checkedOAuth2 and OpenID Connect code
DependenciesEnd-of-life libraries, unpinned downloadsPackage manifests, lockfiles
TransportHTTPS redirects, HSTS, CSP, CORSWeb server and container config
AuditWhat is logged, and whether logs can be changedLogging modules, database schema

Two rules keep this honest. Scan the code instead of relying on interviews, since teams under- and over-rate their own systems. And open every flagged file before you act on a finding, because a control can live one layer up from where a scanner looks.

Assessing OpenEMR With ForgeScore

OpenEMR is a widely used open-source EHR. Clinics use it for charts, scheduling, prescriptions, billing, and a patient portal, and it exposes REST and FHIR APIs. It is a large PHP codebase that has grown over many years, which makes it a good stand-in for the legacy EHRs most health systems run, and its code is public, so every finding below can be checked.

Forge by Opsera reads a repository and writes the plan and specs a coding agent then builds from. It does not write the code itself. Its assessment produces a ForgeScore, a 0 to 100 score across eight dimensions: Trust Boundaries, Logic Narrative, Code Excellence, Data Weight, Cognitive Load, System Gravity, Semantic Clarity, and Future-Proofing. Each report also carries a NIST CSF 2.0 rating, which grades how well the code covers govern, identify, protect, detect, respond, and recover.

What the Score Shows

Forge read all 5,540 files and gave OpenEMR a ForgeScore of 56, labeled Developing, with a NIST CSF rating of C+. The security scorecard shows 0 exposed secrets, 2 CVEs, 3 end-of-life packages, and 1 circular dependency.

The ForgeScore Dashboard Overview tab for openemr/openemr with a composite score of 56, a NIST CSF rating of C+, and a security scorecard of 0 secrets, 2 CVEs, 3 end-of-life packages and 1 circular dependency.

The ForgeScore dashboard Overview tab for openemr/openemr

The strongest dimensions were Code Excellence at 66, Logic Narrative at 63, and Trust Boundaries at 58. Forge’s NIST note credits real protect controls, such as OAuth flows and route authorization hooks, and finds detect, respond, and recover less clearly built into the code.

The ForgeScore score radar for openemr/openemr beside its ranked Improvement Opportunities, led by high-severity items such as RestControllerHelper and circular dependencies.

The score radar next to the ranked Improvement Opportunities

The radar shows where points are lost, and the Improvement Opportunities list ranks each finding by severity and links to the file it points to.

Where the Six Security Areas Sit

Forge grouped its security findings into six areas. The graphic places each one where a request meets it, from the browser to the deployment.

Diagram of six security areas along one request path: remote archives in the browser, HTTPS and headers at the edge, JSON parsing and file upload on REST API write routes with the ACL check in place, JWKS fetch at sign-in, and default credentials in the Docker Compose deployment.

We checked each one against the OpenEMR repository before writing it up:

  • Default credentials: The production docker-compose.yml sets MYSQL_ROOT_PASSWORD: root, OE_USER: admin, and OE_PASS: pass, and a comment in the file says to log in with admin/pass.
  • JSON parsing: About 32 write routes in _rest_routes_standard.inc.php read the body with (array) (json_decode(file_get_contents("php://input"))), so a malformed body quietly becomes an empty array.
  • File upload: The document route passes $_FILES['document'], a path query value and an eid to DocumentRestController::postWithPath(). Forge asks for a storage policy at that boundary: canonical paths, allowed types, size limits, server-side filenames and scanning.
  • JWKS fetch: JsonWebKeySet.php loads signing keys from a jwks_uri, with caching marked as future work and no scheme or host check in that file.
  • Remote archives: The napa section of package.json downloads seven archives straight from URLs, including jQuery UI 1.12.1 and React 15.1.0, with its cache switched off.
  • HTTPS + headers: The same compose file publishes ports 80 and 443, and its health check runs curl --insecure against https://localhost.

These are hardening areas for a production deployment. They are not evidence that anything in OpenEMR has been exploited.

What OpenEMR Already Does Well

An assessment should show what to keep and what to fix. The document upload route runs RestConfig::request_authorization_check() before it touches the file, so access control is in place, and the gap is storage policy. Forge’s roadmap also calls the codebase a strong baseline, with real security architecture signals and disciplined data access in newer paths.

From Score to a Scoped Intent

A score does not tell a team what to build. So Forge asks for a goal, here Security Remediation, and writes an intent: a short document that fixes the scope before anyone plans work.

Four-step flow for Forge on OpenEMR: an assessment scoring 56 across 5,540 files, an intent with 6 security areas, a PRD-Spec at 89% confidence, and a coding agent building from work orders with review.

The intent sets a vision, lists what is in scope and out of scope, and defines fix criteria for each area.

The Intent document in Forge for the OpenEMR Security Hardening Assessment with the goal Security Remediation, showing the intent profile and vision plus the start of the six remediation areas.

The Intent document for the Security Remediation goal

The Core Issue section names each of the six areas with exact files and values, so a reviewer can confirm it in minutes.

The Core Issue section of the Forge intent document, listing six remediation areas with exact file paths and values, including docker-compose.yml default credentials, _rest_routes_standard.inc.php JSON parsing, document upload, JWKS retrieval, napa remote archives and transport hardening.

The Core Issue section, with file paths and values for each area

Out of scope does as much work as in scope. Here, it rules out unrelated features, UI redesign, and full framework migrations, keeping the effort focused on the six areas.

From Intent to a PRD Your Coding Agent Can Use

Once the intent is approved, Forge asks a few pre-flight questions, such as which deployment surfaces to cover and which compliance frameworks to optimize for. It then writes a PRD-Spec, the product requirements document with acceptance criteria for each change. Ours came back at 89% confidence.

The Product Requirements Specification for the OpenEMR Security Hardening Assessment in Forge, showing 89% confidence and an executive summary of six bounded vulnerability clusters.

The PRD-Spec executive summary at 89% confidence

The next stage cuts the PRD into work orders, small testable tasks a coding agent can pick up one at a time, with your security and compliance leads reviewing each change.

What the Roadmap Projects

Forge’s Roadmap tab sums up OpenEMR as better built than it is structurally governed. It estimates that three focused changes would lift the composite from 56 to 69.

The ForgeScore Roadmap tab for openemr/openemr, with Forge's bottom line that the codebase is better built than it is structurally governed and three focused changes lift the composite score from 56 to 69.

The Roadmap tab with Forge’s bottom line for OpenEMR

Treat that number as a planning target until you re-score the repository after the work lands.

How Do You Sequence EHR Security Fixes?

Sequence by exposure and effort, so risk comes down fast while the larger changes are planned. The order we would take for the six areas:

  1. Default credentials: A configuration change with the widest exposure, so it goes first.
  2. HTTPS + headers: Mostly web server and container settings, and easy to test from outside.
  3. JSON parsing: One shared parser, then a route-by-route swap behind tests.
  4. File upload: Needs a storage decision and a scanning tool, so it takes longer to land.
  5. JWKS fetch: Touches sign-in, so test it against every identity provider you support.
  6. Remote archives: The largest change, since replacing React 15 and jQuery UI 1.12.1 touches legacy screens.

For the health system in our example, the first two items fit in one sprint and close the findings an auditor would see first.

What the First Two Fixes Look Like in Code

Forge stops at the spec, so the code below sketches what a coding agent might write against the first acceptance criteria. Review it like any other pull request.

Default credentials. The production compose file ships sample values today:

MYSQL_ROOT_PASSWORD: rootOE_USER: adminOE_PASS: pass

With the ${VAR:?message} form, Docker Compose refuses to start when a variable is missing, so a deployment cannot fall back to a sample password:

MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?set MYSQL_ROOT_PASSWORD}OE_USER: ${OE_USER:?set OE_USER}OE_PASS: ${OE_PASS:?set OE_PASS}

Forge’s fix goes one step further and asks startup to reject known defaults such as admin or pass, even when someone sets them on purpose.

JSON parsing. Each write route reads its body like this today:

$data = (array) (json_decode(file_get_contents("php://input")));

When the body is not valid JSON, json_decode returns null, and the (array) cast turns that into an empty array, so the controller runs with no data and no error. One shared reader closes that gap for every route:

function readJsonBody(int $maxBytes = 1048576): array{$body = file_get_contents('php://input', false, null, 0, $maxBytes + 1);if ($body === false || strlen($body) > $maxBytes) {throw new BadRequestException('Request body is too large');}try {$data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);} catch (JsonException $e) {throw new BadRequestException('Malformed JSON');}if (!is_array($data)) {throw new BadRequestException('Expected a JSON object');}return $data;}

BadRequestException stands in for whatever your app uses to return an HTTP 400. Per-endpoint schema checks then run on the returned array before the controller sees it.

How Do You Prove the EHR Hardening Worked?

A security program keeps its budget when it can show results that compliance and leadership understand. Track a small set of measures per wave:

MeasureHow to track itWhat good looks like
ForgeScoreRe-score after each waveComposite and Trust Boundaries rise
NIST CSF ratingRead it from the same reportMoves up from C+
Default credentialsStartup test with sample valuesDeployment refuses to start
Request parsingTests with malformed, empty, and oversized bodiesEach returns HTTP 400
TransportHeader check against the live URLHTTPS redirect, HSTS, CSP present
DependenciesLockfile with integrity hashes, SBOMNo remote archive downloads

For the health system in our example, the first re-score plus two passing startup tests gave the CISO evidence to show an auditor, instead of a promise.

What Mistakes Derail EHR Security Work?

  • Patching from a scan list alone: A list of findings has no order. Score the application, then sequence.
  • Assuming a control is missing: OpenEMR’s upload route already checks authorization. Open the file before you write the ticket.
  • Reading version ranges as installed versions: A range in a manifest is not what runs in production.
  • Treating a projection as a result: The 56 to 69 forecast is a target until a re-score confirms it.
  • Leaving audit logging for later: It is the one HIPAA technical safeguard these six fixes do not cover.

What Should You Ask an AI Tool Before It Touches Your EHR?

AI coding tools now pitch security fixes for legacy apps, and most demos show how fast the fix lands. For a system that holds patient records, speed is the easy part to judge. These five questions show whether a tool leaves you evidence an auditor can check:

  • Map first: Does it score the whole system before it changes anything? A baseline such as the ForgeScore and NIST CSF rating above shows where you started.
  • File-level findings: Is every finding tied to an exact file and value? That lets a reviewer confirm each one in minutes instead of trusting a summary.
  • Written scope: Is there an intent with fix criteria and an out-of-scope list? In a clinical system, that list keeps an agent from drifting into changes nobody approved.
  • Reviewable changes: Can a person review each change on its own? Work orders tie every change back to one finding and one acceptance criterion.
  • Re-score: Can you run the same assessment again after the work lands? A second score on the same scale is what turns a fix list into proof.

A tool that only answers the first question with a fast demo leaves the audit trail to your team.

Conclusion: Prove Every EHR Fix With a Re-Score

The health system in our example still has a fifteen-year-old EHR. What changed is the conversation. Instead of a long scanner export, the CISO has a score, six scoped areas, a PRD with acceptance criteria, and an order of work.

That is the practical core of EHR security for legacy systems. The patches are the visible part. The proof is the second score: when the same assessment runs again after each wave and Trust Boundaries and the NIST CSF rating move up, the CISO has evidence an auditor can check.

Start with the one application your teams worry about most. Score it this month, fix the first two areas, and re-score to see what moved. Try it on your own repository with Forge by Opsera, or book a demo to see the assessment on your stack.

Questions.

What is EHR security?

EHR security is the set of controls that keep electronic health records confidential, accurate, and available, covering credentials, input validation, document storage, sign-in, dependencies, transport, and audit logging.

What does the HIPAA Security Rule require for EHR security?

Its technical safeguards cover access control, audit controls, integrity, person or entity authentication, and transmission security. A proposed update would make controls such as MFA and network segmentation explicit requirements, with final action targeted for July 2027.

How do you secure a legacy EHR without rewriting it?

Score the codebase first, then fix the highest-exposure gaps such as default credentials and transport settings. Re-score after each wave so progress is measured, not assumed.

Does Forge write the security fixes?

No. Forge writes the intent, the PRD, and the work orders. Your coding agent builds from them, and people review each change.

Is OpenEMR insecure?

This guide makes no such claim. Forge calls the codebase a strong baseline, and the six areas are hardening work for a production deployment.

Does hardening make an EHR HIPAA compliant?

No. Compliance also covers policies, risk analysis, and training. These fixes support only the technical safeguards.

Two people at work on code, seen from behind their monitors.

See it running on your own pipelines.

Forty-five minutes with our engineers. Bring a pipeline you are unhappy with.

Book a demoNo install required