Skip to content

fhir-smart not enforced for JSONPatch and FHIRPathPatch #4101

Closed
@jornvanwier

Description

Describe the bug

fhir-smart does appear to enforce JSONPatch and FHIRPathPatch requests. When using a JWT with ff94628809f34970a7a8199bccf2f23c as one of the patient_ids and a "patient/*.read" scope the following happens:

This PUT request gives a 403 as expected:

curl 'http://localhost:9080/fhir-server/api/v4/Patient/ff94628809f34970a7a8199bccf2f23c' -H "Authorization: Bearer $bearer" -H 'Content-Type: application/json' -d '{"resourceType": "Patient", "id": "ff94628809f34970a7a8199bccf2f23c", "gender":"female"}' -X PUT

However, if I do what is essentially the same request using JSONPatch, the change is allowed:

curl 'http://localhost:9080/fhir-server/api/v4/Patient/ff94628809f34970a7a8199bccf2f23c' -H "Authorization: Bearer $bearer" -H 'Content-Type: application/json-patch+json' -d '[{ "op": "add", "path": "/gender", "value": "female" }]' -X PATCH

With FHIRPathPatch the same can be observed.

I initially suspected that it was because org.linuxforhealth.fhir.smart.AuthzPolicyEnforcementPersistenceInterceptor does not have a beforePatch method, but after adding this method (with the same implementation as beforeUpdate) the problem persisted.

Am I missing something, or is this a bug in fhir-smart?

Environment

I'm currently still using 4.11.1. Looking through the changelogs and relevant code I don't believe this has already been fixed in the newer versions.

To Reproduce

Steps to reproduce the behavior:

  1. Have a JWT with read-only access to a patient (I'm using "patient/*.read")
  2. Perform a JSONPatch or FHIRPathPatch request for data belonging to the current patient.
  3. The request will succeed.

Expected behavior

The request should not succeed unless the JWT has a write scope for the resource.

Metadata

Assignees

Labels

P1Priority 1 - Must HavebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions