ghostscript before 6.53 allows attackers to execute arbitrary commands by using .locksafe or .setsafe to reset the current pagedevice.
The ghostscript command with the -dSAFER option allows remote attackers to execute commands.