Skip to content

fix: refuse an empty signing key for the size signatures (#53) - #59

Merged
ogorzalka merged 1 commit into
mainfrom
fix/refuse-empty-signing-key
Nov 23, 2026
Merged

ogorzalka merged 1 commit into
mainfrom
fix/refuse-empty-signing-key

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Closes #53.

The signing key reaches SizedFileName as a closure (wp_salt('pollora/media') standalone, app.key with the framework) and was never checked: an empty key gave an HMAC anyone can compute (an attacker could only trigger the generation of the declared sizes, bounded by the lock and the pixel/byte ceilings). signature() and for() now throw InvalidMediaConfigurationException::emptySigningKey() for an empty or blank key; the message says to set APP_KEY or the WordPress salts. The key is still resolved when signing, so a late key works. Names and signatures with a valid key are unchanged.

The 12-hex truncation (48 bits) is kept: an online search of 2^48 is unrealistic and a longer signature would break the file names already issued.

A fallback route hit with an empty key now answers 500 instead of accepting a weak signature.

Checked: full suite (612) on five seeds, the new test fails without the fix, Pint, PHPStan, Rector dry-run on src. WordPress integration suite and coverage not run locally.

@ogorzalka
ogorzalka merged commit 5ef9418 into main Nov 23, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Size signatures can be computed by anyone when app.key is empty

1 participant