question

PankajSY-6972 avatar image
0 Votes"
PankajSY-6972 asked PankajSY-6972 commented

Security policy PDF error in Imagick in Laravel app hosted on Azure

Below is the Imagick code reading a PDF file.

$img = new Imagick();
    $img->setResolution(300,300);
    $img->readImage($pdffile);


Below error appears in the log->

production.ERROR: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408 {"userI
d":1,"exception":"[object] (ImagickException(code: 499): attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAutho
rized/408 at /home/site/wwwroot/app/Http/Controllers/Sample.php:2812)
[stacktrace]
#0 /home/site/wwwroot/app/Http/Controllers/Sample.php(2812): Imagick->readimage('/tmp/phpPPIrAu')


I added policy code in /etc/ImageMagick-6/policy.xml but no effect.






azure-webapps
· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Is your app hosted in Windows or Linux @PankajSY-6972?

1 Vote 1 ·

Hi @PankajSY-6972, wanted to follow up to see if you were still experiencing this issue. If your app is being hosted in Windows, you may be running into certain restrictions; see https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#win32ksys-user32gdi32-restrictions

1 Vote 1 ·

Due to some issues was not able to respond.

App is hosted on Linux.

0 Votes 0 ·

Is it a container image on a Linux host? Not sure what security policy it's looking for at @ error/constitute.c/IsCoderAuthorized/408 but I came across https://github.com/snobu/php-imagick-webapps#warning which may help.

1 Vote 1 ·
Show more comments

1 Answer

ryanchill avatar image
0 Votes"
ryanchill answered PankajSY-6972 commented

@PankajSY-6972, there's this answer that have been successful for others.

If that doesn't help, how did you setup the extension. Do you see any errors when running composer? Does phpinfo return the extension loaded correctly?

802a8956-2440-11e7-9b68-60e7e678a49b.png


· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@PankajSY-6972, was https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion any help? Since you don't see any composer errors, how did you setup the extension?

0 Votes 0 ·

Does apache server need to be restarted after making changes in the "policy.xml" file ?

0 Votes 0 ·

I'm not 100% certain @PankajSY-6972, if that's the case or not but I would error on the side of caution and restart the app service to cover basis.

0 Votes 0 ·
Show more comments