feat: add security features#30
Merged
Merged
Conversation
bcc091f to
8d65861
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking Changes
PHP API changes
Storage::setDecoder()removedThe
setDecoder(UriDecoder $decoder): selfmethod has been removed.The domain was previously injected via this mutable setter; it is now passed explicitly as a parameter to
fetchImage().Before:
After:
Storage::fetchImage()signature changedThe
$domainparameter has been added as the second positional argument.The
$forceparameter is now third (was second).Before:
After:
UrlFilesystemAdapterconstructor changedThe constructor no longer accepts
Symfony\Component\Filesystem\Filesystem.It now requires
BaBeuloula\CdnPhp\Http\HttpFetcher.Before:
After:
Behavioral changes
HTTP redirects disabled by default
file_get_contentspreviously followed HTTP redirects unconditionally, which was an SSRFvector (a redirect from an allowed domain could reach internal services).
Redirects are now disabled by default.
Migration: if your image origins serve content via HTTP redirects, set:
Watermark URLs validated against
ALLOWED_DOMAINSA request with
wu=https://external-domain.com/wm.jpgwhereexternal-domain.comis notin
ALLOWED_DOMAINSnow returns HTTP 403 instead of processing the watermark.Migration: add any watermark domain you intend to use to
ALLOWED_DOMAINS.Image dimensions clamped at 5 000 px
wandhvalues above5000are silently clamped to5000.Previously, arbitrarily large dimensions were honored, which could cause excessive
memory and CPU usage.
Migration: no action required unless your clients intentionally request dimensions
above 5 000 px.
Malformed
DOMAINS_ALIASESentries now throw at bootAn entry that does not follow the
alias=domainformat (missing=) previously causedsilent undefined behavior. It now throws
\InvalidArgumentExceptionat container boot,preventing the application from starting with a misconfigured alias list.
Migration: review your
DOMAINS_ALIASESvalue and ensure every entry uses thealias=domainformat.New environment variables
The following variables are new. They all have safe defaults and will not cause a hard
failure if absent, but they change runtime behavior:
FETCH_TIMEOUT10FETCH_MAX_SIZE52428800FETCH_ALLOW_REDIRECTS01to follow HTTP redirectsFORCE_TOKEN?force=true; empty = no protectionAdd them to your
.envor SSM Parameter Store as needed.