UCLH-Foundry / PIXL

PIXL Image eXtraction Laboratory
Apache License 2.0
8 stars 0 forks source link

orthanc-anon ReceivedInstanceCallback must not allow exceptions to go uncaught or anonymisation will be compromised #368

Closed jeremyestein closed 3 months ago

jeremyestein commented 4 months ago

Definition of Done / Acceptance Criteria

Details and Comments

Repro steps



* Run the system test without performing teardown afterwards (the system test should fail)
* Inspect the orthanc anon server in your browser at http://localhost:7003/
* Navigate to "All studies"

#### Expected
Due to the raised exception, I would expect no data to have reached orthanc anon. And if any data has, it absolutely shouldn't contain any PII.

#### Actual
orthanc-anon contains the same data as orthanc-raw. Ie. two studies with full, original patient name, patient ID, accession number.
Luckily, it seems that FTP upload hasn't happened, but I haven't investigated why.

#### Discussion
It seems that orthanc requires an explicit return value (eg. `return orthanc.ReceivedInstanceAction.DISCARD, None`) to discard or modify a received instance. The default is to accept unmodified.
When anonymising, this "fail dangerous" paradigm is very much not ideal.

I can't be sure that in real life we wouldn't perform the FTP upload. It could be the way the system test is set up to test for success before proceeding that stops it from doing so. A human operator may not have realised this has happened and may manually run the upload command, thus putting patient data at risk.
stefpiatek commented 4 months ago

Is this not just a top level try block catching all exceptions and discarding?

I can't be sure that in real life we wouldn't perform the FTP upload.

We query the hashed_image_idenfifier in pipeline.image table, so if the data hasn't been pseudonymised, then it will fail on that query and not export

jeremyestein commented 4 months ago

Possible duplicate of #122