Commit 434c094
Reject non-finite DICOM affine metadata in PydicomReader (#9087)
### Description
`PydicomReader._get_affine` builds the affine matrix from DICOM
`PixelSpacing`, `ImagePositionPatient`, and `ImageOrientationPatient`
values with no finite check. A crafted DICOM carrying `NaN`/`inf` in
those DS tags produces a corrupted affine that propagates through
spatial transforms and crashes MONAILabel inference or silently corrupts
results.
Validate all affine inputs with `math.isfinite()` and raise `ValueError`
naming the offending tag before building the matrix
(GHSA-6hp3-vr39-rqw8).
### Types of changes
- [ ] Non-breaking change
- [x] Breaking change (non-finite DICOM geometry now raises instead of
silently proceeding)
- [x] New tests added to cover the changes.
---------
Signed-off-by: R. Garcia-Dias <rafaelagd@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>1 parent 97843f8 commit 434c094
2 files changed
Lines changed: 85 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| 350 | + | |
350 | 351 | | |
351 | 352 | | |
352 | 353 | | |
| |||
752 | 753 | | |
753 | 754 | | |
754 | 755 | | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
755 | 764 | | |
756 | 765 | | |
| 766 | + | |
757 | 767 | | |
758 | 768 | | |
| 769 | + | |
759 | 770 | | |
760 | 771 | | |
| 772 | + | |
761 | 773 | | |
| 774 | + | |
762 | 775 | | |
763 | 776 | | |
764 | 777 | | |
| |||
773 | 786 | | |
774 | 787 | | |
775 | 788 | | |
| 789 | + | |
776 | 790 | | |
777 | 791 | | |
778 | 792 | | |
779 | 793 | | |
780 | 794 | | |
781 | 795 | | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
782 | 799 | | |
783 | 800 | | |
784 | 801 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
42 | 110 | | |
43 | 111 | | |
44 | 112 | | |
0 commit comments