Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 128647 - app-text/ghostscript-esp-8.15.1 ps2epsi: insecure temp files
Summary: app-text/ghostscript-esp-8.15.1 ps2epsi: insecure temp files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B3 [noglsa] DerCorny
Keywords:
: 132342 (view as bug list)
Depends on:
Blocks: 132213
  Show dependency tree
 
Reported: 2006-04-03 08:51 UTC by Martin von Gagern
Modified: 2019-12-22 11:57 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin von Gagern 2006-04-03 08:51:49 UTC
ps2epsi from the ESP version of GhostScript deletes a temporary file created by mktemp. This file is later an argument to gs, although with -dSAFER specified.

A malicious user could watch the temporary directory, e.g. using inotify. Once a file is created and deleted, it could try to replace it with an own copy, which would then be processed with the privileges of the user calling ps2epsi. The attack would depend on the watching process getting processing time before ps2epsi can recreate the file but after it has checked the file is really gone. This is at least possible, although I don't know if it's probable.

At the very least he could introduce his own contents instead or additionally to the document provided by the user. I don't know if -dSAFER is safe enough to prevent worse attacks.

As a solution, the file should be kept and overwritten, and only deleted by the signal handler already present.
Comment 1 Stefan Cornelius (RETIRED) gentoo-dev 2006-04-03 09:02:07 UTC
printing please verify and provide fixed ebuilds if needed, thank you.
Comment 2 Stefan Schweizer (RETIRED) gentoo-dev 2006-04-03 14:51:13 UTC
ebuild done, ghostscript-esp-8.15.1-r1.ebuild
Comment 3 Stefan Schweizer (RETIRED) gentoo-dev 2006-04-03 14:58:59 UTC
actually, gs-esp-8 cannot be marked stable due to the numerous unsolved bugs in bugzilla. I would like the afpl one in the other bug be marked stable though. Do you want me to patch the stable -7 series of gs-esp? Or do you want to tell people to use -gnu or -afpl in the GLSA?

Also -gnu is now the global default with the new-style virtual/ghostscript because -esp-8 has so many bugs.
Comment 4 Thierry Carrez (RETIRED) gentoo-dev 2006-04-15 05:16:16 UTC
Stefan: probably better to patch the -7 line if you can.
Comment 5 Thierry Carrez (RETIRED) gentoo-dev 2006-04-22 03:24:26 UTC
Printing herd please patch the current stable series or advise
Comment 6 Stefan Schweizer (RETIRED) gentoo-dev 2006-04-22 11:05:11 UTC
well, advice is to not recommend either ghostscript-esp in a security GLEP because both series have serious bugs.

Just tell people to switch to -gnu, ok?
Comment 7 Thierry Carrez (RETIRED) gentoo-dev 2006-04-23 10:17:09 UTC
The vulnerability is not serious enough to warrant a MaskGLSA so we'll probably just security.mask the two as having persistent security problems and not issue anything. The message will recommand users to switch to the gnu version.

Security, please comment
Comment 8 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-04-23 12:45:05 UTC
I agree with comment #7.
Comment 9 Stefan Schweizer (RETIRED) gentoo-dev 2006-04-30 04:56:24 UTC
ghostscript-esp-8.15.1_p20060430 fixes a thus far serious bug in gs-esp. I cannot find any other bugs open for gs-esp-8 so
probably it should be marked stable instead of just masking the old version.
Comment 10 Thierry Carrez (RETIRED) gentoo-dev 2006-05-02 09:41:12 UTC
We can try...
Arches please test and mark ghostscript-esp-8.15.1_p20060430 stable if you can
Comment 11 Thomas Cort (RETIRED) gentoo-dev 2006-05-02 12:08:41 UTC
(In reply to comment #10)
> Arches please test and mark ghostscript-esp-8.15.1_p20060430 stable if you can

I've done some testing on a stable amd64 system and have encountered a problem with either ps2epsi or epstopdf (from tetex). Using paper.ps[1] I ran `ps2epsi paper.ps` and got paper.epsi[2] (which is 57M, is that normal?). I then ran `epstopdf paper.epsi` and got a pdf[3]. However, when I open the pdf in gpdf it is all on one page. I ran `ps2pdf paper.ps` and got a good looking pdf[4]. Am I doing something completely wrong here (note, I have 0 experience with encapulated ps)? There were no warnings or errors when I ran the commands I mentioned.

[1] http://dev.gentoo.org/~tcort/examples/paper.ps
[2] http://dev.gentoo.org/~tcort/examples/paper.epsi.bz2
[3] http://dev.gentoo.org/~tcort/examples/paper-from-epsi.pdf
[4] http://dev.gentoo.org/~tcort/examples/paper-from-ps.pdf

app-text/ghostscript-esp-8.15.1_p20060430  +X -cjk +cups -emacs +gtk -threads -xml
app-text/tetex-2.0.2-r9  +X -doc -tcltk
app-text/gpdf-2.10.0-r4  -debug

# emerge --info
Portage 2.0.54 (default-linux/amd64/2006.0, gcc-3.4.5, glibc-2.3.5-r2, 2.6.15-gentoo-r7 x86_64)
=================================================================
System uname: 2.6.15-gentoo-r7 x86_64 AMD Turion(tm) 64 Mobile Technology ML-32
Gentoo Base System version 1.6.14
dev-lang/python:     2.4.2
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/lib/X11/xkb /usr/lib64/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/eselect/compiler /etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=athlon64 -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs autoconfig collision-protect cvs distlocks multilib-strict sandbox sfperms strict"
GENTOO_MIRRORS="http://gentoo.mirrored.ca/ http://adelie.polymtl.ca/ http://gentoo.arcticnetwork.ca/ http://gentoo.osuosl.org/ "
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
USE="amd64 X aac acpi aim alsa audacious audiofile avi berkdb bitmap-fonts browserplugin bzip2 cdr cli crypt cups curl dbus dri eds emboss encode esd exif expat fam flac foomaticdb gif glut gnome gphoto2 gpm gstreamer gtk gtk2 gtkhtml hal icq idn imlib ipv6 isdnlog jabber java jpeg kde lcms libwww lua lzw lzw-tiff mad mikmod mng mono mozilla moznocompose moznoirc moznomail mp3 mpeg msn ncurses nls nocd nptl nptlonly nsplugin offensive ogg oggvorbis openal opengl oscar pam pcre pdflib perl png pppd python qt quicktime readline reflection sdl session shorten sndfile spell spl ssl symlink tcpd tetex tiff truetype truetype-fonts type1-fonts udev usb userlocales vorbis wxgtk1 xml2 xmms xorg xpm xv xvid yahoo zlib userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS
Comment 12 Matthias Langer 2006-05-02 18:36:08 UTC
I've done some testing with ghostscript-esp-8.15.1_p20060430 [  +X -cjk +cups -emacs +gtk -threads +xml ] on x86. For testing i've opened a view ps files and verified that they are displayed correctly using evnince-0.4.0-r3 [  +dbus -debug -doc +dvi +nautilus -t1lib +tiff ]. However, i can also confirm the behavour mentioned in comment #11 (with evenice instead of gpdf). Btw. i'm using tetex-2.0.2-r8  [ +X -doc +tcltk ].

Portage 2203-svn (default-linux/x86/2006.0, gcc-3.4.5, glibc-2.3.6-r3, 2.6.16-gentoo-r3 i686)
=================================================================
System uname: 2.6.16-gentoo-r3 i686 AMD Athlon(tm) XP 2400+
Gentoo Base System version 1.6.14
dev-lang/python:     2.3.5-r2, 2.4.2
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/eselect/compiler /etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=athlon-xp -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig collision-protect distlocks sandbox sfperms strict test"
GENTOO_MIRRORS="http://gentoo.inode.at/ "
LANG="en_US.utf8"
LC_ALL="en_US.utf8"
LINGUAS="en de"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://192.168.0.1/gentoo-portage"
USE="x86 3dnow 3dnowext X a52 aac aalib acpi alsa apm audiofile avi berkdb bitmap-fonts bonobo bzip2 cairo cdr cli crypt css cups curl dbus directfb dri dts dvd dvdr dvdread eds emboss encode exif expat fam fbcon ffmpeg firefox flac foomaticdb fortran gd gdbm gif ginac glut gmp gnome gphoto2 gpm gstreamer gtk gtk2 gtkhtml guile hal icq idn imagemagick imlib ipv6 isdnlog java javascript jpeg jpeg2k junit lcms libg++ libwww mad mikmod mime mmx mmxext mng motif mozsvg mp3 mpeg msn nautilus ncurses nls nptl nsplugin nvidia offensive ogg oggvorbis openal opengl pam pcre pdflib perl plotutils png posix pppd python quicktime readline real reflection ruby sdl session slang sockets speex spell spl sqlite sqlite3 sse ssl subtitles svg svga tcltk tcpd tetex theora tiff truetype truetype-fonts type1-fonts udev unicode usb vcd vorbis win32codecs wma xine xml xml2 xmms xorg xv xvid zlib linguas_en linguas_de userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, INSTALL_MASK, LDFLAGS
Comment 13 Matthias Langer 2006-05-02 18:59:27 UTC
When trying to reproduce the behavour in comment #11 with ghostscript-gnu-8.16-r3 [ +X -cjk +cups -emacs +gtk ] on the box descibed in comment #12 (x86) i got basically the same results, with the exception that i got a warning:

$ ps2epsi paper.ps
sed: -e expression #1, char 42: Invalid range end

If i should try the same with different ghostscript-(gnu/esp) versions, let me know.
Comment 14 Stefan Schweizer (RETIRED) gentoo-dev 2006-05-05 06:40:00 UTC
*** Bug 132342 has been marked as a duplicate of this bug. ***
Comment 15 Stefan Schweizer (RETIRED) gentoo-dev 2006-05-05 06:46:28 UTC
Adding kde metabug

 Matthias: Yes, please open a separate bug for ps2epsi if it is indeed a bug and the behavious in other ghostscripts is different.
Comment 16 Matthias Langer 2006-05-06 14:02:01 UTC
I've now also tried to reproduce comment #11 with ghostscript-gnu-8.16-r1 [ +X -cjk +cups +gtk ] and got exactly the same results as decribed in comment #13. After that i did the same again, but this time with another ps file as source (215 pages / 1.1MB) and got:

$ ps2epsi a1.ps
Error: /stackoverflow in --roll--
Operand stack:
   --nostringval--
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   --nostringval--   --nostringval--   --nostringval--   421   1   660   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   50365 6   %oparray_pop   --nostringval--
Dictionary stack:
   --dict:1118/1686(ro)(G)--   --dict:0/20(G)--   --dict:73/200(L)--   --dict:36/47(L)--   --dict:139/300(L)--   --dict:36/47(L)--
Current allocation mode is local
Last OS error: 2
GNU Ghostscript 8.16: Unrecoverable error, exit code 1
sed: -e expression #1, char 42: Invalid range end
Comment 17 Matthias Langer 2006-05-06 14:57:34 UTC
I've now tested ps2epsi with all ghostscript versions in portage (afpl, gnu, esp) and it seems to be broken for all of them. Thus i think comment #11 - comment #16 should not be a reason to leave ghostscript-esp-8.15.1_p20060430 in ~arch.
Comment 18 Thierry Carrez (RETIRED) gentoo-dev 2006-05-09 09:50:31 UTC
Yes, please mark stable if it doesn't do worse than the current stable...
Comment 19 Thomas Cort (RETIRED) gentoo-dev 2006-05-09 10:26:47 UTC
(In reply to comment #10)
> Arches please test and mark ghostscript-esp-8.15.1_p20060430 stable if you can

alpha and amd64 stable.
Comment 20 Mark Loeser (RETIRED) gentoo-dev 2006-05-11 11:36:33 UTC
x86 done, thanks for testing Matthias
Comment 21 Emanuele Giaquinta (RETIRED) gentoo-dev 2006-05-13 01:52:12 UTC
ppc done.
Comment 22 Jason Wever (RETIRED) gentoo-dev 2006-05-13 16:05:47 UTC
SPARC'd
Comment 23 Markus Rothe (RETIRED) gentoo-dev 2006-05-14 00:20:50 UTC
stable on ppc64
Comment 24 Marko Steinberger 2006-05-14 08:46:48 UTC
Just an additional note. After updating ghostscript-esp my printer stopped working. Switching to ghostscript-gnu did not solve my problem at first. I also had to reemerge gimp-print.
I am just reporting this because some people already seem to have similar problems: 

http://forums.gentoo.org/viewtopic-t-434182-highlight-ghostscript.html

If there will be a GLSA then I suggest thinking about mentioning this.
Comment 25 Thierry Carrez (RETIRED) gentoo-dev 2006-05-14 09:55:52 UTC
Ready for GLSA vote, I vote NO, because ps2epsi is rather uncommon use.
Comment 26 Raphael Marichez (Falco) (RETIRED) gentoo-dev 2006-05-14 15:04:20 UTC
another no
Comment 27 Marko Steinberger 2006-05-14 17:30:51 UTC
Bug #133123 is about broken gimp-print.
Comment 28 Sune Kloppenborg Jeppesen (RETIRED) gentoo-dev 2006-05-14 22:41:27 UTC
Closing without GLSA.
Comment 29 René Nussbaumer (RETIRED) gentoo-dev 2006-05-15 10:36:49 UTC
stable on hppa. Forgot to remove us from CC.