Summary
OpenEMR before 8.4.0 has an authorization bypass in its FHIR QuestionnaireResponse endpoint. A low-privileged authenticated user who supplies the session-exposed CSRF token in the APICSRFTOKEN header may bypass FHIR scope checks and read questionnaire responses belonging to other patients.
Affected context
The issue affects OpenEMR deployments before 8.4.0 where authenticated users can access the FHIR API. The reported weakness involves GET /fhir/QuestionnaireResponse: the APICSRFTOKEN header can be used to skip FHIR scope checks, potentially exposing questionnaire answers across patients.
Exploit preconditions
- Attack surface: The OpenEMR FHIR API, specifically the QuestionnaireResponse endpoint
- Required access: A low-privileged authenticated account and access to the session-exposed
api_csrf_token_jsvalue - Trigger point: A request to
GET /fhir/QuestionnaireResponsecarrying the token in theAPICSRFTOKENheader - Why exploitation is possible: The token handling path can bypass FHIR scope authorization checks, allowing a request to access data beyond the user's authorized patient scope
Why this happens
The underlying issue is an authorization enforcement failure mapped to CWE-862: Missing Authorization. The endpoint's handling of the APICSRFTOKEN header allows a session-exposed token to bypass FHIR scope checks rather than consistently enforcing whether the authenticated user is permitted to read the requested patient data.
Potential impact
- An attacker could read QuestionnaireResponse records for patients outside their permitted scope.
- Questionnaire answers may expose sensitive personal or health information.
- Site-wide data exposure could increase privacy, regulatory, and incident-response risks.
General mitigation guidance
Defensive design should ensure that every FHIR request is authorized against the authenticated user's permissions and the specific patient resource being accessed. CSRF tokens should not function as authorization credentials or bypass scope enforcement.
Common protective patterns include:
- Applying server-side authorization checks consistently on every endpoint and resource.
- Enforcing patient-level and FHIR-scope restrictions independently of CSRF validation.
- Treating session-exposed values and client-supplied headers as untrusted input.
- Using secure-by-default access policies and least-privilege roles.
- Testing authorization boundaries for cross-patient access as part of security reviews.
How teams detect issues like this
Review FHIR endpoint code and policies for paths where CSRF token handling can skip or weaken authorization checks. Static analysis and code review should look for missing resource-level authorization, inconsistent checks across request paths, and reliance on client-supplied headers for access decisions.
Runtime monitoring can flag authenticated users requesting QuestionnaireResponse data across many patient records or outside their assigned scope. Automated tests and policy enforcement can verify that authorization is checked for every resource request, including requests with valid CSRF tokens.

