exiftool: strip all non-essential tags

Documentation was already clear on this only stripping GPS tags.
But there are more potentially sensitive metadata tags (e.g. author
and possibly description) and the name alone suggests a broader effect.

Thus change the filter to strip all metadata except for colourspace info
and orientation (technically it strips everything and then readds
selected tags).

Explicitly stripping CommonIFD0 is needed since -all does not modify
IFD0 due to TIFF storing some actual image data there. CommonIFD0 then
strips a bunch of commonly used actual metadata tags from IFD0, to my
understanding leaving TIFF image data and custom metadata tags intact.
This commit is contained in:
Oneric 2024-04-15 23:49:01 +02:00
parent 7a7ebecf00
commit 1f9b31e7ef
4 changed files with 16 additions and 6 deletions

View File

@ -37,7 +37,7 @@ If any of the options are left unspecified, you will be prompted interactively.
- `--static-dir <path>` - the directory custom public files should be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)
- `--listen-ip <ip>` - the ip the app should listen to, defaults to 127.0.0.1
- `--listen-port <port>` - the port the app should listen to, defaults to 4000
- `--strip-uploads <Y|N>` - use ExifTool to strip uploads of sensitive location data
- `--strip-uploads <Y|N>` - use ExifTool to strip uploads of metadata when possible
- `--anonymize-uploads <Y|N>` - randomize uploaded filenames
- `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames
- `--skip-release-env` - skip generation the release environment file

View File

@ -656,7 +656,7 @@ This filter replaces the declared filename (not the path) of an upload.
#### Pleroma.Upload.Filter.Exiftool
This filter only strips the GPS and location metadata with Exiftool leaving color profiles and attributes intact.
This filter strips metadata with Exiftool leaving color profiles and orientation intact.
No specific configuration.

View File

@ -171,10 +171,10 @@ defmodule Mix.Tasks.Pleroma.Instance do
{strip_uploads_message, strip_uploads_default} =
if Pleroma.Utils.command_available?("exiftool") do
{"Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as installed. (y/n)",
{"Do you want to strip metadata from uploaded images? This requires exiftool, it was detected as installed. (y/n)",
"y"}
else
{"Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n)",
{"Do you want to strip metadata from uploaded images? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n)",
"n"}
end

View File

@ -4,7 +4,7 @@
defmodule Pleroma.Upload.Filter.Exiftool do
@moduledoc """
Strips GPS related EXIF tags and overwrites the file in place.
Tries to strip all image metadata but colorspace and orientation overwriting the file in place.
Also strips or replaces filesystem metadata e.g., timestamps.
"""
@behaviour Pleroma.Upload.Filter
@ -19,7 +19,17 @@ defmodule Pleroma.Upload.Filter.Exiftool do
try do
case System.cmd(
"exiftool",
["-ignoreMinorErrors", "-overwrite_original", "-gps:all=", file],
[
"-ignoreMinorErrors",
"-overwrite_original",
"-all=",
"-CommonIFD0=",
"-TagsFromFile",
"@",
"-ColorSpaceTags",
"-Orientation",
file
],
parallelism: true
) do
{_response, 0} -> {:ok, :filtered}