[UNIX] Bad Temporary File Handling in GNAT

From: support@securiteam.com
Date: 02/15/02


From: support@securiteam.com
To: list@securiteam.com
Date: Fri, 15 Feb 2002 03:52:30 +0100 (CET)

The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
- - promotion

When was the last time you checked your server's security?
How about a monthly report?
http://www.AutomatedScanning.com - Know that you're safe.
- - - - - - - - -

  Bad Temporary File Handling in GNAT
------------------------------------------------------------------------

SUMMARY

The run-time library of the GNU Ada compiler ( <http://www.gnat.com/>
GNAT) handles temporary files in an unsafe manner, which enables tmp
symlink attacks and may enable local users to gain root access.

DETAILS

Systems affected:
All POSIX multi-user systems running GNAT-compiled binaries that use Ada
language facilities for creating temporary files are affected. The
following GNAT versions are known to have this defect:

 * GNAT 3.12p
 * GNAT 3.13p
 * GNAT 3.14p

(The unreleased version of GNAT from the GCC CVS fixes this security
defect on GNU/Linux, but introduces another one. Its use is strongly
discouraged until this problem has been addressed.)

Attack vector:
Interactive access is usually required to exploit this vulnerability.

Impact:
The impact depends on the application creating the temporary file. It
ranges from temporary to permanent denial of service, from data
eavesdropping to system compromise.

Description:
The Ada language offers a facility to create named temporary files (see
ISO/IEC 8652:1995, section A.8.5.2). The GNAT run-time library creates
these temporary files in an unsafe way, which can result in exploitable
/tmp race conditions.

In addition, the procedure GNAT.OS_Lib.Create_Temp_File creates the
temporary file in the current directory and does not retry with a
different file name if the generated random file name has come into
existence before the file is opened using O_EXCL.

Proposed solution:
The patch below replaces the calls to tmpnam() or mktemp() with ones to
mkstemp(). Of course, this only works on systems where mkstemp() is
available.

 * Patch for GNAT 3.14p:
  <http://cert.uni-stuttgart.de/files/fw/gnat-3.14p-mkstemp.diff>
http://cert.uni-stuttgart.de/files/fw/gnat-3.14p-mkstemp.diff

Unfortunately, changes that are more substantial are required for previous
versions of GNAT.

ADDITIONAL INFORMATION

The information has been provided by
<mailto:Weimer@CERT.Uni-Stuttgart.DE> Florian Weimer.

========================================

This bulletin is sent to members of the SecuriTeam mailing list.
To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

====================
====================

DISCLAIMER:
The information in this bulletin is provided "AS IS" without warranty of any kind.
In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.



Relevant Pages

  • Re: Why Users dont have write rights to the %windir%TEMP folder
    ... The number of "power users" of any type can be counted on the ... folder and I will like to see if it is acceptable in terms of security. ... That's not the correct location for temporary files, ... rather than on every workstation. ...
    (microsoft.public.windows.server.security)
  • Re: Temporary Internet Files
    ... Ron, thanks for the suggestion. ... but there is no "delete temporary files" option. ... Scroll down the list to the Security ...
    (microsoft.public.windowsxp.basics)
  • Re: The end of first class mail as we know it.
    ... media, freshly loaded for each session online, with no other files on ... the machine except temporary files, and with a second monitor which ... security are in an inverse relationship. ...
    (rec.arts.sf.fandom)
  • [Full-Disclosure] [ GLSA 200410-02 ] Netpbm: Multiple temporary file issues
    ... Utilities included in old Netpbm versions are vulnerable to multiple ... temporary files issues, potentially allowing a local attacker to ... in file overwriting with the rights of the user running the utility. ... Security is a primary focus of Gentoo Linux and ensuring the ...
    (Full-Disclosure)
  • [ GLSA 200410-02 ] Netpbm: Multiple temporary file issues
    ... Utilities included in old Netpbm versions are vulnerable to multiple ... temporary files issues, potentially allowing a local attacker to ... in file overwriting with the rights of the user running the utility. ... Security is a primary focus of Gentoo Linux and ensuring the ...
    (Full-Disclosure)