Shrine 3.12.0
Security
-
The
download_endpointplugin now requires the:secret_keyoption and always signs download URLs (GHSA-w8v6-8q68-85pf). Previously, download URLs were unsigned by default, so attackers could build URLs for arbitrary files in any registered storage, and choose the responseContent-Typeand filename through the serialized metadata.Shrine.plugin :download_endpoint, prefix: "attachments", secret_key: "<YOUR SECRET KEY>"The endpoint returns
403 Forbiddenfor URLs with a missing or invalid signature. File responses now also include theX-Content-Type-Options: nosniffheader. -
The
remote_urlplugin now refuses URLs and redirects that resolve to private IP addresses (localhost, private networks, link-local addresses such as cloud metadata endpoints etc), which prevents server-side request forgery. This is done by passingallow_private: falseto the downloader. If you need to download from internal addresses, and the URLs don't come from untrusted sources, you can allow it:plugin :remote_url, max_size: 20*1024*1024, allow_private: true # or attacher.assign_remote_url(url, downloader: { allow_private: true }) -
Submitting a cached file can no longer be used to move or delete files uploaded by others (GHSA-v6vc-5f2v-5rj8):
-
FileSystemnow rejects ids that resolve to the storage directory itself (e.g.""or"."), which previously allowed moving the whole cache directory on promotion withmove: true. -
FileSystem#uploadwithmove: trueandFileSystem#deletenow refuse to move or delete directories. -
FileSystemnow stops cleaning empty directories at the storage directory, instead of continuing into its parent directories. -
The
remove_invalidplugin now only deletes invalid files that were uploaded by the attacher. Cached files assigned from data (e.g. form params), which could belong to other users, are just deassigned.
-
-
The
:ruby_vipsanalyzer of thestore_dimensionsplugin now callsVips.block_untrusted(true)(libvips 8.13+), so that unvalidated uploads cannot reach libvips loaders that haven't been fuzzed (e.g.magickload,svgload) (GHSA-gx57-4cm3-73qj). This can be overridden with theVIPS_BLOCK_UNTRUSTEDenvironment variable.
New features
-
The
remote_urlplugin now accepts:net_http,:httpor:httpxfor the:downloaderoption, which selects the corresponding Down backend.plugin :remote_url, max_size: 20*1024*1024, downloader: :http # uses Down::Http plugin :remote_url, max_size: 20*1024*1024, downloader: :httpx # uses Down::Httpx -
The
download_endpointplugin now supports:secret_keywithout:expires_in, which generates non-expiring signed URLs.
Backwards compatibility
-
The
download_endpointplugin now raisesShrine::Errorwhen the:secret_keyoption is not given. Previously generated unsigned download URLs will return403 Forbidden. -
The
remote_urlplugin now defaults to the:net_httpdownloader, soDown.backendis no longer used. If you've changedDown.backend, pass the corresponding backend to the:downloaderoption instead. -
Custom
remote_urldownloaders now receive the:allow_privatekeyword argument, so they need to accept it. Make sure to forward it to Down, or otherwise refuse URLs resolving to private IP addresses. -
Shrine now requires Down 6.1.2 or later.
-
FileSystem#deleteandFileSystem#uploadwithmove: truenow raiseShrine::Errorwhen given an id that resolves to a directory. -
The
remove_invalidplugin no longer deletes cached files assigned from data when validation fails.