VYPR
Critical severity10.0GHSA Advisory· Published May 6, 2026· Updated May 11, 2026

CVE-2026-40281

CVE-2026-40281

Description

Gotenberg is a Docker-powered stateless API for PDF files. In versions 8.30.1 and earlier, the metadata write endpoint validates metadata keys for control characters but leaves metadata values unsanitized. A newline character in a metadata value splits the ExifTool stdin line into two separate arguments, allowing injection of arbitrary ExifTool pseudo-tags such as -FileName, -Directory, -SymLink, and -HardLink. This is a bypass of the incomplete key-sanitization fix introduced in v8.30.1. An unauthenticated attacker can rename or move any PDF being processed to an arbitrary path in the container filesystem, overwrite arbitrary files, or create symlinks and hard links at arbitrary paths.

Affected products

2

Patches

1
405f1069c026

fix(exitool): prevent control characters

https://github.com/gotenberg/gotenbergJulien NeuhartApr 6, 2026via nvd-ref
1 file changed · +21 0
  • pkg/modules/exiftool/exiftool.go+21 0 modified
    @@ -8,6 +8,7 @@ import (
     	"os"
     	"os/exec"
     	"reflect"
    +	"regexp"
     	"strings"
     	"syscall"
     
    @@ -23,6 +24,12 @@ func init() {
     	gotenberg.MustRegisterModule(new(ExifTool))
     }
     
    +// safeKeyPattern matches legitimate ExifTool tag names: alphanumeric,
    +// hyphens, underscores, colons, and periods. Rejects control characters
    +// (especially \n) that would inject stdin arguments via go-exiftool's
    +// line-based protocol.
    +var safeKeyPattern = regexp.MustCompile(`^[a-zA-Z0-9\-_.:]+$`)
    +
     // systemTags lists ExifTool tags that reflect internal filesystem state
     // rather than actual PDF metadata. These are stripped from both read and
     // write operations.
    @@ -253,6 +260,20 @@ func (engine *ExifTool) WriteMetadata(ctx context.Context, logger *slog.Logger,
     		"HardLink",  // Writing this creates a hard link in ExifTool
     		"SymLink",   // Writing this creates a symbolic link in ExifTool
     	}
    +	// Reject metadata keys containing characters that could inject ExifTool
    +	// stdin arguments. ExifTool uses a line-based stdin protocol; a newline
    +	// in a key splits into a separate argument, enabling flag injection
    +	// (e.g., -if with Perl eval). Only allow alphanumeric, hyphen, colon,
    +	// period, and underscore — sufficient for all legitimate tag names.
    +	for key := range metadata {
    +		if !safeKeyPattern.MatchString(key) {
    +			err = fmt.Errorf("write PDF metadata with ExifTool: invalid metadata key %q", key)
    +			span.RecordError(err)
    +			span.SetStatus(codes.Error, err.Error())
    +			return err
    +		}
    +	}
    +
     	for key := range metadata {
     		for _, tag := range dangerousTags {
     			if strings.EqualFold(key, tag) {
    

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

5

News mentions

0

No linked articles in our index yet.