-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The patch strips, then compares\n\nThe pre-patch loop in `(*ExifTool).WriteMetadata` ran the dangerous-tag check against the raw map key:\n\n```go\ndangerousTags := []string{\n \"FileName\", // Writing this triggers a file rename in ExifTool\n \"Directory\", // Writing this triggers a file move in ExifTool\n \"HardLink\", // Writing this creates a hard link in ExifTool\n \"SymLink\", // Writing this creates a symbolic link in ExifTool\n}\n\nfor key := range metadata {\n for _, tag := range dangerousTags {\n if strings.EqualFold(key, tag) {\n delete(metadata, key)\n }\n }\n}\n```\n\nThe April 13 commit replaces the comparison side of the inner `if`:\n\n```diff\n for key := range metadata {\n+ // Strip ExifTool group prefixes (e.g., \"System:FileName\" -->\n+ // \"FileName\") before comparing. ExifTool allows leading group\n+ // names separated by colons, and treats the prefixed and bare\n+ // forms identically.\n+ bare := key\n+ if i := strings.LastIndex(key, \":\"); i >= 0 {\n+ bare = key[i+1:]\n+ }\n for _, tag := range dangerousTags {\n- if strings.EqualFold(key, tag) {\n+ if strings.EqualFold(bare, tag) {\n delete(metadata, key)\n }\n }\n }\n```\n\nThe same commit grows the `dangerousTags` slice by one entry:\n\n```diff\n dangerousTags := []string{\n- \"FileName\", // Writing this triggers a file rename in ExifTool\n- \"Directory\", // Writing this triggers a file move in ExifTool\n- \"HardLink\", // Writing this creates a hard link in ExifTool\n- \"SymLink\", // Writing this creates a symbolic link in ExifTool\n+ \"FileName\", // Writing this triggers a file rename in ExifTool\n+ \"Directory\", // Writing this triggers a file move in ExifTool\n+ \"HardLink\", // Writing this creates a hard link in ExifTool\n+ \"SymLink\", // Writing this creates a symbolic link in ExifTool\n+ \"FilePermissions\", // Writing this changes the file's permissions\n }\n```\n\nThe CVE description names \"move, rename, and change permissions for arbitrary files.\" Before April 13, the rename, move, and link variants were reachable through any group-prefixed alias (`System:FileName`, `Composite:Directory`, `EXIF:System:SymLink`), and the permissions variant was reachable directly by name. `FilePermissions` was not in the blocklist at all. `strings.EqualFold(\"FilePermissions\", \"FileName\")` is false, `EqualFold(\"FilePermissions\", \"Directory\")` is false, and so on for the other three entries. An HTTP client that sent `{\"FilePermissions\":\"777\"}` got a `chmod(2)` for free.\n\nExifTool's documentation, in the table the source comment links to, lists `FileName`, `Directory`, `HardLink`, `SymLink`, and `FilePermissions` together in its \"Extra\" tags group, each annotated with the syscall it performs. The April 13 commit's title says `remove System: prefixes`. The diff also added the fifth name to the slice. The commit message did not mention it.\n\n## The exploit primitive\n\nThe vulnerable endpoint is `POST /forms/pdfengines/metadata/write`, registered in `pkg/modules/pdfengines/routes.go`. Gotenberg's API has no authentication by default; the flag that enables it, `api-enable-basic-auth`, defaults to false. Any HTTP client that can reach the container can call this route.\n\nThe request is multipart/form-data with a `files` field carrying one or more PDFs and a `metadata` field carrying a JSON object. The handler unmarshals the JSON into a Go `map[string]any` and hands it to `buildExifToolWriteArgs`, which composes `exiftool -overwrite_original -= ... ` from the map, skipping any key the blocklist matches.\n\nAgainst an unpatched Gotenberg (v8.29.0 through v8.30.x), the chain is one request:\n\n```bash\ncurl -X POST http://gotenberg.internal:3000/forms/pdfengines/metadata/write \\\n -F 'files=@cover.pdf' \\\n -F 'metadata={\"System:FileName\":\"/var/lib/gotenberg/spool/inbox.pdf\"}'\n```\n\n`cover.pdf` is the file Gotenberg copies into a per-request temp directory. ExifTool resolves `System:FileName` to the FileName pseudo-tag, which it documents as performing a `rename(2)` of the file it is operating on. The temp PDF is now at `/var/lib/gotenberg/spool/inbox.pdf`. The attacker controls the source (their upload, whose bytes are entirely theirs) and the destination (their JSON), within the bounds of the gotenberg process's filesystem access.\n\n`System:HardLink` does the same with `link(2)`. `System:SymLink` does the same with `symlink(2)`. `System:Directory` moves the file across directories. `FilePermissions` calls `chmod(2)`. The advisory phrases this as \"move, rename, and change permissions for arbitrary files.\" It is closer to \"the attacker selects which `*at(2)` syscall the gotenberg process makes, with both arguments under their control, in one HTTP request, without authentication.\"\n\n## A blocklist's grammar versus ExifTool's grammar\n\nThe blocklist is a Go string slice. The check is `strings.EqualFold`, written by someone who has read ExifTool's documentation enough to add four (and now five) entries to the slice. The check fires when the request key, as a string, equals one of those entries under case folding.\n\nExifTool resolves tag names through a parser. The parser accepts the bare form, a group prefix, multiple group prefixes separated by colons, and the same forms in any case. The April 13 patch closes one of those resolution paths by stripping everything before the last colon. The blocklist still does not consult ExifTool; the post-patch loop strips the prefix and case-folds the result, then checks the resulting string against five hard-coded names. ExifTool's parser is unaware that this check has run, and the patch's `strings.LastIndex` is unaware of any future extension to ExifTool's tag-name grammar.\n\nThis is [gate-before-canonicalize](/patterns/gate-before-canonicalize) in our catalog. The check inspects the input for a forbidden form; the downstream subsystem canonicalizes the same input into that forbidden form. The patch does the right thing structurally: it canonicalizes (strips the group prefix, folds the case) before checking. The shape of the bug, before the patch, is that ExifTool's `Image::ExifTool::DoSetTag` did the canonicalization and Gotenberg's `for key := range metadata` did the checking, and they did not share a grammar.\n\nGotenberg has been here before. [CVE-2026-40280](/posts/gotenberg-cve-2026-40280-named-fix-adds-the-bug) was the URL-scheme variant of the same pattern: the default outbound deny-list compiled `^https?://(10\\.|...)` as a case-sensitive byte-pattern match, and `net/url.Parse` lowercased the scheme inside the dial path, so `HTTPS://169.254.169.254/` cleared the gate as written and reached the IMDS endpoint as parsed. [CVE-2026-42596](/posts/gotenberg-cve-2026-42596-patch-removed-the-default-protection) was the host-form variant: `[::ffff:127.0.0.1]` did not appear in any of the deny-list's character classes, but `net/netip.ParseAddr` unmapped it to the loopback IPv4 the regex was written to block. CVE-2026-40893 is the same pattern, on a different parser, in the same product. Three gates, three canonicalizers downstream, three CVEs.\n\n## Five patches in sixteen days\n\nThe dangerous-tag blocklist arrived on March 28, 2026 in commit `043b158`, titled `fix(exiftool): arbitrary file write`. It had two entries (`FileName`, `Directory`) and was implemented as `delete(metadata, \"FileName\")` and `delete(metadata, \"Directory\")`. `delete` on a Go map is case-sensitive. `delete(metadata, \"filename\")` does nothing when the key is `filename`. ExifTool processes the lowercase form just fine.\n\nThe bypass arrived three days later. Commit `15050a3` on March 31, `fix(exiftool): case-insensitive comparison and expanded blocklist`, switched the loop to `strings.EqualFold` and added `HardLink` and `SymLink`. The advisory for this fix is [GHSA-qmwh-9m9c-h36m](https://github.com/advisories/GHSA-qmwh-9m9c-h36m), published alongside Gotenberg v8.30.0. The same advisory notes that the original v8.29.0 blocklist had also omitted the link-creation tags entirely; the writer had read the `FileName` and `Directory` pages of the ExifTool documentation and not the adjacent ones.\n\nThe next bypass arrived on April 6, in commit `405f106` (`fix(exitool): prevent control characters`). At the time, Gotenberg's `WriteMetadata` was implemented through the `go-exiftool` library, which speaks ExifTool's line-based stdin protocol: one tag assignment per line. A newline embedded in a metadata key splits into two stdin lines. The first carried whatever the attacker named the key; the second carried whatever the attacker put after the newline. The commit's own source comment, on the regex it adds, says it out loud:\n\n> An attacker who controls a metadata value but not the key could otherwise inject pseudo-tags like `-FileName=`, `-Directory=`, `-SymLink=`, or `-HardLink=` and trigger arbitrary filesystem side effects.\n\nThe same bypass arrived again on April 11, in commit `55d1952` (`fix(exiftool): prevent line breaks`), this time on the value side. The April 6 patch had rejected control characters in keys; values still flowed through unfiltered. A newline in a value did the same line-splitting trick.\n\nAnd then April 13 brought commit `46e1909`, sixteen days after the blocklist's first commit. Five distinct patches. One blocklist. Each patch closed the bypass the previous bypass-finder reported. The bypass-finder kept finding new ones because the blocklist's grammar was a finite list and ExifTool's grammar was a parser.\n\n## The blocklist was the wrong shape\n\nThe recurring fix shape, across all five patches, is \"add another exception to the blocklist.\" Case-insensitivity is one exception, applied through `strings.EqualFold`. Newline-injection in keys is another, applied through `safeKeyPattern`. Newline-injection in values is another, applied through `validateMetadataValue`. Group prefixes are another, applied through `strings.LastIndex(key, \":\")`. A missing entry for `FilePermissions` is another, applied by appending one more string. Each patch is a faithful response to a specific bypass. None of them changes the shape: enumerate a set of dangerous tag forms, reject inputs that match, pass the rest to ExifTool.\n\nThe alternative is an allowlist of metadata namespaces. PDF metadata lives in a finite, documented surface: the XMP packets `XMP-dc`, `XMP-pdf`, `XMP-pdfx`, `XMP-xmp`, and a handful of EXIF and IPTC tags that real PDF tooling sets. A list of accepted tag-name prefixes is on the order of thirty entries, all of them documented by Adobe and the PDF/A consortium, none of them connected to a filesystem syscall. An allowlist closes the class on the day it ships. A blocklist closes one bypass at a time.\n\nThe catalog name for \"patches address symptoms; the design holds the primitive\" is [design-debt-driver](/patterns/design-debt-driver). The component is the dangerous-tag blocklist itself. The primitive is \"user JSON keys reach ExifTool's tag parser, and ExifTool's tag parser has more grammar than any enumeration will cover.\"\n\n## What v8.31.0 actually changed\n\nThe April 13 patch is correct for the bypasses it names. `System:FileName` no longer reaches ExifTool. `Composite:HardLink` no longer reaches ExifTool. `Main:System:Directory` no longer reaches ExifTool (the patch uses `LastIndex`, so any number of group prefixes collapse to the bare name). Bare `FilePermissions` no longer reaches ExifTool. On the specific surfaces Anurag Bathani reported, the patch holds.\n\nIt does not change the relationship. The current `pkg/modules/exiftool/exiftool.go` still has a `dangerousTags` slice, now five entries, checked against the post-canonicalized key. The next bypass, if one exists, will arrive on whatever ExifTool grammar feature this loop does not yet know about. The bypass will be reported, the loop will grow another line, the next minor release will close it, and the loop will still be a loop.\n\nPoC: [GHSA-62p3-hvxx-fxg4](https://github.com/advisories/GHSA-62p3-hvxx-fxg4)","closing_line":"The blocklist learned one new dangerous shape per bypass. ExifTool's grammar did not run out of shapes.","hook_md":"Gotenberg's patch for CVE-2026-40893 ships on April 13, 2026 as commit `46e1909`, titled `fix(exiftool): remove System: prefixes`. The functional change is six lines added to one loop in `pkg/modules/exiftool/exiftool.go`: strip everything before the last colon in each metadata key, then case-fold the result, then compare against the dangerous-tag blocklist. Before April 13, the comparison ran on the raw key, and `strings.EqualFold(\"System:FileName\", \"FileName\")` is false. ExifTool's documentation, on the page Gotenberg's source comment links to, has said for years that \"a tag name may include leading group names separated by colons.\" The blocklist asked ExifTool nothing. ExifTool's parser did not need to ask the blocklist anything.","post_id":429,"slug":"gotenberg-cve-2026-40893-blocklist-asked-exiftool-nothing","title":"CVE-2026-40893: Gotenberg's Dangerous-Tag Blocklist Asked ExifTool Nothing","type":"initial","unreadable_sentence":"The blocklist asked ExifTool nothing. ExifTool's parser did not need to ask the blocklist anything."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCamD8OgAKCRDeZjl4jgkQ JlkLAPwI3Q5lfBYK9u52nQWdqdxyKS/7yOT4iyFyLD+mTGA2ygEA79PkSM+kS193 zQecIsjowe2Sj72jEcQmf7+0wrSZVQY= =URzv -----END PGP SIGNATURE-----