| 1 |
=head1 NAME |
| 2 |
|
| 3 |
Imager::Security - brief notes on security and image processing |
| 4 |
|
| 5 |
=head1 SYNOPSIS |
| 6 |
|
| 7 |
# keep abreast of security updates |
| 8 |
apt-get update && apt-get upgrade |
| 9 |
yum upgrade |
| 10 |
pkgin update && pkgin upgrade |
| 11 |
# or local equivalent |
| 12 |
|
| 13 |
# limit memory use |
| 14 |
use Imager; |
| 15 |
# only images that use up to 10MB |
| 16 |
Imager->set_file_limits(bytes => 10_000_000); |
| 17 |
|
| 18 |
=head1 DESCRIPTION |
| 19 |
|
| 20 |
There's two basic security considerations when dealing with images |
| 21 |
from an unknown source: |
| 22 |
|
| 23 |
=over |
| 24 |
|
| 25 |
=item * |
| 26 |
|
| 27 |
keeping your libraries up to date |
| 28 |
|
| 29 |
=item * |
| 30 |
|
| 31 |
limiting the amount of memory used to store images |
| 32 |
|
| 33 |
=back |
| 34 |
|
| 35 |
=head2 Keeping libraries up to date |
| 36 |
|
| 37 |
Image file format libraries such as C<libpng> or C<libtiff> have |
| 38 |
relatively frequent security updates, keeping your libraries up to |
| 39 |
date is basic security. |
| 40 |
|
| 41 |
If you're using user supplied fonts, you will need to keep your font |
| 42 |
libraries up to date too. |
| 43 |
|
| 44 |
=head2 Limiting memory used |
| 45 |
|
| 46 |
With compression, and especially with pointer formats like TIFF, it's |
| 47 |
possible to store very large images in a relatively small file. |
| 48 |
|
| 49 |
If you're receiving image data from an untrusted source you should |
| 50 |
limit the amount of memory that Imager can allocate for a read in |
| 51 |
image file using the C<set_file_limits()> method. |
| 52 |
|
| 53 |
Imager->set_file_limits(bytes => 10_000_000); |
| 54 |
|
| 55 |
You may also want to limit the maximum width and height of images read |
| 56 |
from files: |
| 57 |
|
| 58 |
Imager->set_file_limits(width => 10_000, height => 10_000, |
| 59 |
bytes => 10_000_000); |
| 60 |
|
| 61 |
This has no effect on images created without a file: |
| 62 |
|
| 63 |
# succeeds |
| 64 |
my $image = Imager->new(xsize => 10_001, ysize => 10_001); |
| 65 |
|
| 66 |
You can reset to the defaults with: |
| 67 |
|
| 68 |
Imager->set_file_limits(reset => 1); |
| 69 |
|
| 70 |
=head1 AUTHOR |
| 71 |
|
| 72 |
Tony Cook <[email protected]> |
| 73 |
|
| 74 |
=cut |