__________________________________________________________ The U.S. Department of Energy Computer Incident Advisory Capability ___ __ __ _ ___ / | /_\ / \___ __|__ / \ \___ __________________________________________________________ INFORMATION BULLETIN Security Vulnerability in PostgreSQL SECURITY DEFINER Funtions [Sun Alert ID: 102894] April 27, 2007 19:00 GMT Number R-219 [REVISED 11 May 2007] [REVISED 30 May 2007] [REVISED 22 Jun 2007] ______________________________________________________________________________ PROBLEM: SECURITY DEFINER functions are special PostgreSQL functions which perform certin designated activities with special privilegs. A security vulnerability in the PostgreSQL database server (see postgres(1)) may allow a local or remote PostgreSQL user who has authenticated with the PostgreSQL server to inject crafted objects (for example, functions, tables, or operators) and affect the execution of existing SECURITY DEFINER functions. PLATFORM: SPARC Platform Solaris 10 x86 Platform Solaris 10 RHEL Desktop Workstation (v. 5 client) Red Hat Desktop (v. 3, v. 4) Red Hat Enterprise Linux (v. 5 server) Red Hat Enterprise Linux Desktop (v. 5 client) Red Hat Enterprise Linux AS, ES, WS (v. 3, v. 4) Debian GNU/Linux 3.1 (sarge) and 4.0 (etch) DAMAGE: May allow a local or remote PostgreSQL user who has authenticated with the PostgreSQL server to inject crafted objects (for example, functions, tables, or operators) and affect the execution of existing SECURITY DEFINER functions. SOLUTION: Upgrade to the appropriate version. ______________________________________________________________________________ VULNERABILITY The risk is MEDIUM. An authenticated PostgreSQL user can take ASSESSMENT: control of the database or execute code with elevated privileges. ______________________________________________________________________________ LINKS: CIAC BULLETIN: http://www.ciac.org/ciac/bulletins/r-219.shtml ORIGINAL BULLETIN: http://www.sunsolve.sun.com/search/document.do?assetkey=1 -26-102894-1 ADDITIONAL LINKS: https://rhn.redhat.com/errate/RHSA-2007-0336.html http://www.debian.org/security/2007/dsa-1311 CVE: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name= CVE-2007-2138 ______________________________________________________________________________ REVISION HISTORY: 05/11/2007 - revised R-219 to add a link to Red Hat RHSA-2007:0336-2 for RHEL Desktop Workstation (v. 5 client), Red Hat Desktop (v. 3, v. 4), Red Hat Enterprise Linux (v. 5 server), Red Hat Enterprise Linux Desktop (v. 5 client), and Red Hat Enterprise Linux AS, ES, WS (v. 3, v. 4). 05/30/2007 - revised R-219 to reflect changes Sun has made in Sun Alert ID: 102894 where they updated Contributing Factors and Resolution sections and changed the State to Resolved. 6/22/2007 - revised R-219 to add a link to Debian Security Advisory DSA-1311-1 for Debian GNU/Linux 3.1 (sarge) and 4.0 (etch). [***** Start Sun Alert ID: 102894 *****] Sun(sm) Alert Notification Sun Alert ID: 102894 Synopsis: Security Vulnerability in PostgreSQL SECURITY DEFINER Functions May Allow Escalation of Privileges Category: Security Product: Solaris 10 Operating System BugIDs: 6546373 Avoidance: Patch State: Resolved Date Released: 26-Apr-2007, 29-May-2007 Date Closed: 29-May-2007 Date Modified: 29-May-2007 1. Impact SECURITY DEFINER functions are special PostgreSQL functions which perform certain designated activities with special privileges. A security vulnerability in the PostgreSQL database server (see postgres(1)) may allow a local or remote PostgreSQL user who has authenticated with the PostgreSQL server to inject crafted objects (for example, functions, tables, or operators) and affect the execution of existing SECURITY DEFINER functions. This would allow that user to control the database and execute code with the elevated privileges of the owner of the SECURITY DEFINER function, or to shadow any table with their own modified version and inject it for processing by a SECURITY DEFINER function. This issue is described in the following documents: CVE-2007-2138 at http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-2138 PostgreSQL Security Information at http://www.postgresql.org/about/news.791 2. Contributing Factors This issue can occur in the following releases: SPARC Platform Solaris 10 without patch 123590-05 x86 Platform Solaris 10 without patch 123591-05 Notes: Solaris 8 and 9 do not ship with PostgreSQL and are thus not impacted by this issue. This issue affects PostgreSQL versions 7.3.x prior to 7.3.19, 7.4.x prior to 7.4.17, 8.0.x prior to 8.0.13, 8.1.x prior to 8.1.9 and 8.2.x prior to 8.2.4. Any user exploiting this vulnerability must have an account on the SQLserver and must have permissions to run SECURITY DEFINER functions owned by another user. The SECURITY DEFINER property of functions is similar to the setuid(2) feature in Unix Operating Systems. This property allows users to execute functions with the privileges of the owner of the functions rather than with the privileges of the user invoking the function. To determine the list of SECURITY DEFINER functions on the database, the following SQL command can be run: SELECT pg_proc.proname, pg_namespace.nspname, pg_user.usename \ FROM pg_proc JOIN pg_namespace ON pg_proc.pronamespace=pg_namespace.oid \ JOIN pg_user ON pg_proc.proowner=pg_user.usesysid WHERE prosecdef='t'; To determine the version of PostgreSQL on the system, the following command can be run: $ /usr/bin/postgres --version postgres (PostgreSQL) 8.1.3 3. Symptoms There are no predictable symptoms that would indicate the described issue has been exploited. Solution Summary Top 4. Relief/Workaround There is no workaround for this issue. Please see the Resolution section below. 5. Resolution This issue is resolved in the following releases: SPARC Platform Solaris 10 with patch 123590-05 or later x86 Platform Solaris 10 with patch 123591-05 or later Change History 29-May-2007: Updated Contributing Factors and Resolution sections State: Resolved This Sun Alert notification is being provided to you on an "AS IS" basis. This Sun Alert notification may contain information provided by third parties. The issues described in this Sun Alert notification may or may not impact your system(s). Sun makes no representations, warranties, or guarantees as to the information contained herein. ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE HEREBY DISCLAIMED. BY ACCESSING THIS DOCUMENT YOU ACKNOWLEDGE THAT SUN SHALL IN NO EVENT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES THAT ARISE OUT OF YOUR USE OR FAILURE TO USE THE INFORMATION CONTAINED HEREIN. This Sun Alert notification contains Sun proprietary and confidential information. It is being provided to you pursuant to the provisions of your agreement to purchase services from Sun, or, if you do not have such an agreement, the Sun.com Terms of Use. This Sun Alert notification may only be used for the purposes contemplated by these agreements. Copyright 2000-2006 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, CA 95054 U.S.A. All rights reserved. [***** End Sun Alert ID: 102894 *****] _______________________________________________________________________________ CIAC wishes to acknowledge the contributions of Sun Microsystems for the information contained in this bulletin. _______________________________________________________________________________ CIAC, the Computer Incident Advisory Capability, is the computer security incident response team for the U.S. Department of Energy (DOE) and the emergency backup response team for the National Institutes of Health (NIH). CIAC is located at the Lawrence Livermore National Laboratory in Livermore, California. CIAC is also a founding member of FIRST, the Forum of Incident Response and Security Teams, a global organization established to foster cooperation and coordination among computer security teams worldwide. CIAC services are available to DOE, DOE contractors, and the NIH. CIAC can be contacted at: Voice: +1 925-422-8193 (7x24) FAX: +1 925-423-8002 STU-III: +1 925-423-2604 E-mail: ciac@ciac.org Previous CIAC notices, anti-virus software, and other information are available from the CIAC Computer Security Archive. World Wide Web: http://www.ciac.org/ Anonymous FTP: ftp.ciac.org PLEASE NOTE: Many users outside of the DOE, ESnet, and NIH computing communities receive CIAC bulletins. If you are not part of these communities, please contact your agency's response team to report incidents. Your agency's team will coordinate with CIAC. The Forum of Incident Response and Security Teams (FIRST) is a world-wide organization. A list of FIRST member organizations and their constituencies can be obtained via WWW at http://www.first.org/. This document was prepared as an account of work sponsored by an agency of the United States Government. Neither the United States Government nor the University of California nor any of their employees, makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe privately owned rights. Reference herein to any specific commercial products, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation or favoring by the United States Government or the University of California. The views and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or the University of California, and shall not be used for advertising or product endorsement purposes. LAST 10 CIAC BULLETINS ISSUED (Previous bulletins available from CIAC) R-209: HP-UX ICMP Vulnerable to DoS via ICMP Path R-210: mandb R-211: XMMS R-212: Vulnerability in RPC on Windows DNS Server R-213: Oracle Critical Patch Update - April 2007 R-214: PHP Security Update R-215: Multiple Security Vulnerabilities in Mozilla Layout Engine R-216: Apple Security Update 2007-004 R-217: CA BrightStor ARCserve Backup Media Server Vulnerabilities R-218: Default Passwords in NetFlow Collection Engine