Summary
OpenEMR fails to correctly enforce sensitivity-based access controls for group encounters because it checks the wrong data source for sensitivity flags.
In affected versions, users who should be restricted from viewing sensitive encounter records (such as mental health sessions) can still access those group encounter details under certain conditions.
Affected context
This vulnerability affects OpenEMR deployments using group encounters with sensitivity classifications, such as mental health or other restricted medical records.
The weakness occurs in the access-control logic that evaluates whether a user is allowed to view an encounter: the system consults form_encounter for sensitivity flags, while group encounters actually store this information in form_groups_encounter.
As a result, group encounters with sensitivity set are handled as if they were not sensitive, whenever authorization checks rely on the incorrect table.
Exploit preconditions
- Attack surface: Application user interface and APIs that display or return encounter data.
- Required access: Valid OpenEMR account with permissions to view at least some patient encounters or group sessions.
- Trigger point: Requesting access (via UI or API) to a group encounter that has been marked as sensitive in
form_groups_encounter. - Why exploitation is possible: The authorization layer evaluates sensitivity only in
form_encounter, so the sensitivity flags for group encounters are never consulted, causing the checks to silently pass.
Why this happens
The root cause is an incomplete authorization implementation where the system performs sensitivity checks against an incorrect or partial data source.
Specifically, the access-control logic assumes sensitivity metadata is stored in the form_encounter table, but group encounters use form_groups_encounter to persist sensitivity information.
This mismatch creates an authorization gap consistent with CWE-863: Incorrect Authorization, where the system attempts to enforce access control but fails to consult all relevant attributes and resources needed to make a correct decision.
Conceptually, the bug reflects a design pattern where authorization logic is hardcoded to one data model and not updated when new encounter types or storage patterns are introduced.
Potential impact
- Exposure of sensitive group encounter details (e.g., mental health or other restricted-session notes) to users who should be denied access.
- Violation of patient privacy and potential non-compliance with healthcare regulations and data protection laws.
- Unintended disclosure of diagnoses, treatments, or participation in sensitive group programs.
- Erosion of trust between patients and providers due to improper handling of confidential information.
General mitigation guidance
Effective mitigation focuses on aligning authorization logic with the complete data model and treating sensitivity as a first-class access-control attribute:
- Centralize sensitivity and authorization checks in a single, reusable access-control layer that understands all encounter types, including individual and group encounters.
- Ensure sensitivity flags and other access-control attributes are consistently stored and retrieved from the correct tables or domain models for each encounter type.
- Implement policy-based access control, where rules derive from patient privacy policies and roles, rather than relying on scattered checks across UI components.
- Apply the principle of least privilege so that user roles only grant access to sensitive encounters when explicitly required.
- Include regression tests for all encounter types (individual, group, telehealth, etc.) to verify that sensitivity and privacy rules are enforced uniformly.
How teams detect issues like this
Organizations can identify similar authorization gaps through:
- Code review: Look for access-control logic that references only one table or encounter type when multiple variants exist; verify that sensitivity and privacy flags are consulted for each path that returns encounter data.
- Static analysis: Configure rules to detect duplicated or inconsistent authorization checks across controllers, APIs, and views, especially for high-value resources like medical records.
- Access-control testing: Perform role-based and privacy-focused test cases that attempt to view sensitive and non-sensitive encounters, including group encounters, confirming that restricted data is not returned.
- Audit logging review: Examine logs for patterns where users with restricted roles frequently access sensitive group encounters, which may indicate an authorization oversight.

