Skip to content

Commit 5af49b3

Browse files
aclark4lifeCopilot
andcommitted
docs: address Andrew's review comments on security.rst
- Add image.getexif() alongside image._getexif() in T-1 mitigations - Remove 'appended bytes' from T-2 (Pillow does not preserve them on resave) - Reframe R-1 threat as user-facing (not Pillow dev advice); add DecompressionBombError to the log/alert list - Add blank line before E-3 heading - Qualify dependency list in recommendation #4 as non-exhaustive Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1f02641 commit 5af49b3

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

docs/handbook/security.rst

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ round-tripping images. Applications that store or render metadata without
7171
sanitisation are vulnerable to second-order injection (SQLi, XSS, command
7272
injection).
7373

74-
*Mitigations:* treat all values from ``image.info``, ``image._getexif()``, and
75-
``image.text`` as untrusted; sanitise before storing or rendering; strip
76-
metadata when it is not required.
74+
*Mitigations:* treat all values from ``image.info``, ``image._getexif()``,
75+
``image.getexif()``, and ``image.text`` as untrusted; sanitise before storing
76+
or rendering; strip metadata when it is not required.
7777

7878
**T-2 — Covert data channel (steganography)**
7979

80-
Pillow does not remove hidden data (JPEG comments, PNG text chunks, appended
81-
bytes) when re-saving. An attacker can embed data that survives the
80+
Pillow does not remove hidden data (JPEG comments, PNG text chunks) when
81+
re-saving. An attacker can embed data that survives the
8282
encode-decode cycle invisibly.
8383

8484
*Mitigations:* to guarantee a clean output when saving, create a new image instance via
@@ -100,13 +100,13 @@ Repudiation
100100

101101
**R-1 — No structured audit trail**
102102

103-
Pillow does not emit structured audit logs of files opened, formats detected,
104-
or operations performed, making forensic investigation harder after an
105-
incident.
103+
Without application-level logging there is no record of which images were
104+
opened, what formats were detected, or what operations were performed, making
105+
forensic investigation harder after an incident.
106106

107-
*Mitigations:* applications should log the filename/hash, detected format, and
108-
dimensions of every image processed; log and alert on
109-
``Image.DecompressionBombWarning`` and ``PIL.UnidentifiedImageError``.
107+
*Mitigations:* log the filename/hash, detected format, and dimensions of every
108+
image processed; log and alert on ``Image.DecompressionBombWarning``,
109+
``Image.DecompressionBombError``, and ``PIL.UnidentifiedImageError``.
110110

111111
Information disclosure
112112
^^^^^^^^^^^^^^^^^^^^^^
@@ -189,6 +189,7 @@ isolated sandbox with no network and no sensitive mounts. Pillow does not
189189
provide a stable public API for unregistering individual format plugins, so do
190190
not rely on mutating internal registries such as ``Image.OPEN`` as a security
191191
control.
192+
192193
**E-3 — ``ImageMath.unsafe_eval()`` code injection**
193194

194195
:py:meth:`~PIL.ImageMath.unsafe_eval` calls Python's built-in ``eval()`` with
@@ -224,8 +225,9 @@ The following mitigations are listed in priority order.
224225
Ghostscript in an isolated container.
225226
3. **Never use** ``ImageMath.unsafe_eval()`` **with user input** — migrate all
226227
callers to :py:meth:`~PIL.ImageMath.lambda_eval`.
227-
4. **Keep all dependencies current** — Pillow, libjpeg, libpng, libtiff,
228-
libwebp, openjpeg, freetype, Ghostscript. Subscribe to `Pillow security
228+
4. **Keep all dependencies current** — Pillow and its C library dependencies
229+
(including libjpeg, libpng, libtiff, libwebp, openjpeg, freetype,
230+
littlecms2, Ghostscript, and others). Subscribe to `Pillow security
229231
advisories <https://github.com/python-pillow/Pillow/security/advisories>`_.
230232
5. **Enforce** ``MAX_IMAGE_PIXELS`` — never set it to ``None``; treat
231233
``Image.DecompressionBombWarning`` as an error.

0 commit comments

Comments
 (0)