jr-paperclip 8.0.8 → 8.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +21 -3
- data/VIPS_MIGRATION_GUIDE.md +1 -1
- data/lib/paperclip/helpers.rb +5 -0
- data/lib/paperclip/image_magick/policy.xml +55 -0
- data/lib/paperclip/image_magick_policy.rb +36 -0
- data/lib/paperclip/thumbnail.rb +1 -0
- data/lib/paperclip/version.rb +1 -1
- data/lib/paperclip.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7c02cf8668a123a0b336ba8ee2ace2c402b2c72d1563277a169f08ea42194349
|
|
4
|
+
data.tar.gz: 1043bc957022e6fd960dd932dfff6cb17f71c3ac0e4052a927d36c455794a96b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3afc5378ffe7541d7db9031a80fabf8c8399a059cf7614190a9a48310cb22d85f23bfcbcac632046494bb6593fcaca4b201a2a2d895c7ebbe96d78a3d9402d79
|
|
7
|
+
data.tar.gz: 8709dbb20a50dbfd238e8e8aacb3cdfd6a727bdcc9c49ee8a515629e385dadd819e04451416915f36fff4945b33e03a69351674300a599b12c1c8aaf966422c5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
8.0.9 (2026-11-04)
|
|
2
|
+
|
|
3
|
+
* Security: Apply a bundled ImageMagick policy to direct `identify` calls and MiniMagick thumbnailing,
|
|
4
|
+
blocking MSL, indirect file and network coders, and Ghostscript by default. Adapted from
|
|
5
|
+
rails/rails@468aa9a93fc98f5476b6821770f4ccfcb7f7d328 (GHSA-f3w6-w445-fwh9).
|
|
6
|
+
* Behavior: PDF and PostScript thumbnailing is blocked by default. MiniMagick 5.1 or newer is required;
|
|
7
|
+
GraphicsMagick and MiniMagick CLI prefixes are rejected because they bypass the policy. The
|
|
8
|
+
policy also applies to direct MiniMagick commands in the same Ruby process once thumbnailing starts.
|
|
9
|
+
|
|
1
10
|
8.0.8 (2026-10-21)
|
|
2
11
|
|
|
3
12
|
* Performance: Let eligible vips resizes use native file thumbnailing instead of loading and
|
data/README.md
CHANGED
|
@@ -125,11 +125,17 @@ If you're on Mac OS X, you'll want to run the following with [Homebrew](http://w
|
|
|
125
125
|
|
|
126
126
|
brew install imagemagick
|
|
127
127
|
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
PDF uploads do not require Ghostscript, but rendering PDF thumbnails with
|
|
129
|
+
ImageMagick does. Paperclip's bundled security policy blocks PDF and Ghostscript
|
|
130
|
+
processing by default. If your application must render PDFs from trusted sources,
|
|
131
|
+
review the policy and explicitly allow the required coders and delegate in your
|
|
132
|
+
host's ImageMagick policy. On Mac OS X, Ghostscript can be installed with:
|
|
130
133
|
|
|
131
134
|
brew install gs
|
|
132
135
|
|
|
136
|
+
Paperclip requires MiniMagick to use ImageMagick without a CLI prefix for this
|
|
137
|
+
policy to protect thumbnails. GraphicsMagick and CLI prefixes are rejected.
|
|
138
|
+
|
|
133
139
|
If you are on Ubuntu (or any Debian base Linux distribution), you'll want to run
|
|
134
140
|
the following with apt-get:
|
|
135
141
|
|
|
@@ -164,7 +170,7 @@ You can also specify the backend per-attachment (see [Image Processing Backends]
|
|
|
164
170
|
|
|
165
171
|
**Note on Geometry Detection:** When `vips` is the active backend, Paperclip uses the ruby-vips gem to determine image dimensions instead of ImageMagick's `identify` command.
|
|
166
172
|
|
|
167
|
-
**Note on Untrusted Loaders:** `image_processing` 2.x asks libvips to block operations and loaders marked as untrusted by default. The affected formats depend on the libvips version and enabled loader libraries in your build. If formats such as PDF, SVG, JPEG-XL, RAW, OpenSlide, NIFTI, FITS, MATLAB, or Analyze6 are rejected, use the ImageMagick backend
|
|
173
|
+
**Note on Untrusted Loaders:** `image_processing` 2.x asks libvips to block operations and loaders marked as untrusted by default. The affected formats depend on the libvips version and enabled loader libraries in your build. If formats such as PDF, SVG, JPEG-XL, RAW, OpenSlide, NIFTI, FITS, MATLAB, or Analyze6 are rejected, use the ImageMagick backend only if its security policy permits the format, or set `VIPS_BLOCK_UNTRUSTED=0` before loading `image_processing/vips` only for trusted inputs.
|
|
168
174
|
|
|
169
175
|
### `file`
|
|
170
176
|
|
|
@@ -788,6 +794,18 @@ jr-paperclip supports two image processing backends:
|
|
|
788
794
|
|
|
789
795
|
The traditional backend. Paperclip uses the `image_processing` gem (via `mini_magick`) to generate shell commands for ImageMagick.
|
|
790
796
|
|
|
797
|
+
Paperclip bundles an ImageMagick security policy based on [Rails commit
|
|
798
|
+
468aa9a](https://github.com/rails/rails/commit/468aa9a93fc98f5476b6821770f4ccfcb7f7d328)
|
|
799
|
+
for [GHSA-f3w6-w445-fwh9](https://github.com/rails/rails/security/advisories/GHSA-f3w6-w445-fwh9).
|
|
800
|
+
It applies to both direct `identify` calls and MiniMagick thumbnail conversion.
|
|
801
|
+
The policy blocks scripting and indirect file/network coders, including MSL,
|
|
802
|
+
and blocks PDF, PostScript, and Ghostscript processing by default. Paperclip
|
|
803
|
+
sets `MiniMagick.cli_env` process-wide when it starts an ImageMagick thumbnail,
|
|
804
|
+
so direct MiniMagick commands in the same Ruby process also inherit the policy. Run
|
|
805
|
+
trusted PDF or PostScript rendering in a separate process with its own policy,
|
|
806
|
+
or explicitly allow the needed coders and delegate in a host policy. A host
|
|
807
|
+
allow also applies to untrusted Paperclip uploads in that process.
|
|
808
|
+
|
|
791
809
|
```ruby
|
|
792
810
|
has_attached_file :avatar,
|
|
793
811
|
styles: { thumb: "100x100#" }
|
data/VIPS_MIGRATION_GUIDE.md
CHANGED
|
@@ -135,5 +135,5 @@ has_attached_file :document,
|
|
|
135
135
|
## Important Considerations
|
|
136
136
|
|
|
137
137
|
1. **Output Parity**: While libvips aims for high quality, its resizing algorithms (Lanczos) may produce slightly different visual results than ImageMagick. `image_processing` 2.x also no longer applies post-resize sharpening by default.
|
|
138
|
-
2. **PDF/SVG Support**: libvips requires additional libraries (like `poppler` or `librsvg`) to process these formats. With `image_processing` 2.x, operations and loaders marked as untrusted may be blocked by default, and the exact affected formats vary by libvips build and version. Use ImageMagick for blocked formats or set `VIPS_BLOCK_UNTRUSTED=0` only for trusted inputs.
|
|
138
|
+
2. **PDF/SVG Support**: libvips requires additional libraries (like `poppler` or `librsvg`) to process these formats. With `image_processing` 2.x, operations and loaders marked as untrusted may be blocked by default, and the exact affected formats vary by libvips build and version. Paperclip's ImageMagick policy also blocks PDF and Ghostscript by default. Use ImageMagick for blocked formats only when its policy permits them, or set `VIPS_BLOCK_UNTRUSTED=0` only for trusted inputs.
|
|
139
139
|
3. **Exotic Formats**: If you rely on very specific ImageMagick features (like specialized filters or complex layer manipulation), test those attachments thoroughly before switching.
|
data/lib/paperclip/helpers.rb
CHANGED
|
@@ -31,6 +31,11 @@ module Paperclip
|
|
|
31
31
|
command_path = options[:command_path]
|
|
32
32
|
terrapin_path_array = Terrapin::CommandLine.path.try(:split, Terrapin::OS.path_separator)
|
|
33
33
|
Terrapin::CommandLine.path = [terrapin_path_array, command_path].flatten.compact.uniq
|
|
34
|
+
local_options = local_options.merge(
|
|
35
|
+
environment: Paperclip::ImageMagickPolicy.command_environment(
|
|
36
|
+
local_options[:environment] || {}, Terrapin::CommandLine.environment["MAGICK_CONFIGURE_PATH"],
|
|
37
|
+
),
|
|
38
|
+
)
|
|
34
39
|
if logging? && (options[:log_command] || local_options[:log_command])
|
|
35
40
|
local_options = local_options.merge(logger: logger)
|
|
36
41
|
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Paperclip's ImageMagick security policy, adapted from the Active Storage policy in
|
|
3
|
+
Rails commit 468aa9a93fc98f5476b6821770f4ccfcb7f7d328 (MIT license):
|
|
4
|
+
https://github.com/rails/rails/commit/468aa9a93fc98f5476b6821770f4ccfcb7f7d328
|
|
5
|
+
|
|
6
|
+
ImageMagick 6 and 7 both honor the coder, delegate, and path domains. Each
|
|
7
|
+
Ghostscript coder alias must be denied separately. Avoid backticks in this file:
|
|
8
|
+
ImageMagick's tokenizer can silently discard rules after one.
|
|
9
|
+
-->
|
|
10
|
+
<policymap>
|
|
11
|
+
<!-- Scripting coder that reads and writes files named inside the image. -->
|
|
12
|
+
<policy domain="coder" rights="none" pattern="MSL"/>
|
|
13
|
+
|
|
14
|
+
<!-- Coders that read or delete files other than the image being processed. -->
|
|
15
|
+
<policy domain="coder" rights="none" pattern="EPHEMERAL"/>
|
|
16
|
+
<policy domain="coder" rights="none" pattern="TEXT"/>
|
|
17
|
+
<policy domain="coder" rights="none" pattern="MPC"/>
|
|
18
|
+
|
|
19
|
+
<!-- Coders that display to a screen. -->
|
|
20
|
+
<policy domain="coder" rights="none" pattern="SHOW"/>
|
|
21
|
+
<policy domain="coder" rights="none" pattern="WIN"/>
|
|
22
|
+
<policy domain="coder" rights="none" pattern="PLT"/>
|
|
23
|
+
|
|
24
|
+
<!-- Coders that read remote or local references. -->
|
|
25
|
+
<policy domain="coder" rights="none" pattern="URL"/>
|
|
26
|
+
<policy domain="coder" rights="none" pattern="HTTP"/>
|
|
27
|
+
<policy domain="coder" rights="none" pattern="HTTPS"/>
|
|
28
|
+
<policy domain="coder" rights="none" pattern="FTP"/>
|
|
29
|
+
<policy domain="coder" rights="none" pattern="FILE"/>
|
|
30
|
+
|
|
31
|
+
<!-- Ghostscript and all of its coder aliases. -->
|
|
32
|
+
<policy domain="delegate" rights="none" pattern="gs"/>
|
|
33
|
+
<policy domain="coder" rights="none" pattern="PS"/>
|
|
34
|
+
<policy domain="coder" rights="none" pattern="PS2"/>
|
|
35
|
+
<policy domain="coder" rights="none" pattern="PS3"/>
|
|
36
|
+
<policy domain="coder" rights="none" pattern="EPS"/>
|
|
37
|
+
<policy domain="coder" rights="none" pattern="EPS2"/>
|
|
38
|
+
<policy domain="coder" rights="none" pattern="EPS3"/>
|
|
39
|
+
<policy domain="coder" rights="none" pattern="EPI"/>
|
|
40
|
+
<policy domain="coder" rights="none" pattern="EPSF"/>
|
|
41
|
+
<policy domain="coder" rights="none" pattern="EPSI"/>
|
|
42
|
+
<policy domain="coder" rights="none" pattern="EPT"/>
|
|
43
|
+
<policy domain="coder" rights="none" pattern="EPT2"/>
|
|
44
|
+
<policy domain="coder" rights="none" pattern="EPT3"/>
|
|
45
|
+
<policy domain="coder" rights="none" pattern="PDF"/>
|
|
46
|
+
<policy domain="coder" rights="none" pattern="AI"/>
|
|
47
|
+
<policy domain="coder" rights="none" pattern="EPDF"/>
|
|
48
|
+
<policy domain="coder" rights="none" pattern="PDFA"/>
|
|
49
|
+
<policy domain="coder" rights="none" pattern="POCKETMOD"/>
|
|
50
|
+
<policy domain="coder" rights="none" pattern="XPS"/>
|
|
51
|
+
<policy domain="coder" rights="none" pattern="PCL"/>
|
|
52
|
+
|
|
53
|
+
<!-- Indirect reads such as text:@/etc/passwd. -->
|
|
54
|
+
<policy domain="path" rights="none" pattern="@*"/>
|
|
55
|
+
</policymap>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Paperclip
|
|
4
|
+
module ImageMagickPolicy
|
|
5
|
+
POLICY_DIRECTORY = File.expand_path("image_magick", __dir__).freeze
|
|
6
|
+
POLICY_PATH = File.join(POLICY_DIRECTORY, "policy.xml").freeze
|
|
7
|
+
|
|
8
|
+
def self.command_environment(environment = {}, *other_paths)
|
|
9
|
+
raise "Paperclip ImageMagick security policy is missing: #{POLICY_PATH}" unless File.file?(POLICY_PATH)
|
|
10
|
+
|
|
11
|
+
environment ||= {}
|
|
12
|
+
configured_path = configuration_path(environment["MAGICK_CONFIGURE_PATH"], *other_paths)
|
|
13
|
+
paths = configured_path.to_s.split(File::PATH_SEPARATOR)
|
|
14
|
+
paths.reject! { |path| path.empty? || path == POLICY_DIRECTORY }
|
|
15
|
+
|
|
16
|
+
environment.merge("MAGICK_CONFIGURE_PATH" => [POLICY_DIRECTORY, *paths.uniq].join(File::PATH_SEPARATOR))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.configuration_path(*paths)
|
|
20
|
+
[*paths, ENV["MAGICK_CONFIGURE_PATH"]].detect { |path| !path.to_s.empty? }
|
|
21
|
+
end
|
|
22
|
+
private_class_method :configuration_path
|
|
23
|
+
|
|
24
|
+
def self.apply_to_mini_magick!
|
|
25
|
+
require "mini_magick"
|
|
26
|
+
unless MiniMagick.respond_to?(:cli_env) && MiniMagick.respond_to?(:cli_env=)
|
|
27
|
+
raise "Paperclip's ImageMagick security policy requires mini_magick 5.1 or later"
|
|
28
|
+
end
|
|
29
|
+
if MiniMagick.graphicsmagick || MiniMagick.cli_prefix
|
|
30
|
+
raise "Paperclip's ImageMagick security policy requires MiniMagick to use ImageMagick without a CLI prefix"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
MiniMagick.cli_env = command_environment(MiniMagick.cli_env || {})
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/paperclip/thumbnail.rb
CHANGED
data/lib/paperclip/version.rb
CHANGED
data/lib/paperclip.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jr-paperclip
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.0.
|
|
4
|
+
version: 8.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jukka Rautanen
|
|
@@ -85,7 +85,7 @@ dependencies:
|
|
|
85
85
|
requirements:
|
|
86
86
|
- - ">="
|
|
87
87
|
- !ruby/object:Gem::Version
|
|
88
|
-
version:
|
|
88
|
+
version: '5.1'
|
|
89
89
|
- - "<"
|
|
90
90
|
- !ruby/object:Gem::Version
|
|
91
91
|
version: '6'
|
|
@@ -95,7 +95,7 @@ dependencies:
|
|
|
95
95
|
requirements:
|
|
96
96
|
- - ">="
|
|
97
97
|
- !ruby/object:Gem::Version
|
|
98
|
-
version:
|
|
98
|
+
version: '5.1'
|
|
99
99
|
- - "<"
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '6'
|
|
@@ -453,6 +453,8 @@ files:
|
|
|
453
453
|
- lib/paperclip/glue.rb
|
|
454
454
|
- lib/paperclip/has_attached_file.rb
|
|
455
455
|
- lib/paperclip/helpers.rb
|
|
456
|
+
- lib/paperclip/image_magick/policy.xml
|
|
457
|
+
- lib/paperclip/image_magick_policy.rb
|
|
456
458
|
- lib/paperclip/interpolations.rb
|
|
457
459
|
- lib/paperclip/interpolations/plural_cache.rb
|
|
458
460
|
- lib/paperclip/io_adapters/abstract_adapter.rb
|