首页 -> 安全研究
安全研究
安全漏洞
Wine以不安全方式创建tmp文件漏洞
发布日期:2005-03-15
更新日期:2005-03-15
受影响系统:
Wine Windows API Emulator 20050310描述:
Wine Windows API Emulator 20050305
Wine Windows API Emulator 20050211
BUGTRAQ ID: 12791
CVE(CAN) ID: CVE-2005-0787
Wine是一款允许在UNIX操作系统(如Linux上)运行DOS和MS Windows程序(Windows 3.x 和Win32可执行程序)的免费软件
wine在启动win32应用程序时,会在/tmp中以regxxxxyyyy.tmp文件名临时存储windows注册表。这里xxxxxx是当前wine进程的十六进制pid值,yyyy是通常等于0的整数值。
regxxxxyyyy.tmp是以0644(-rw-r--r--)权限创建的,这在多用户环境中就导致了安全漏洞。实际上本地用户可以访问windows注册表的DUMP,获取敏感信息,如口令和其他保密数据。
受影响的函数是$winerelease/misc/registry.c中的_get_tmp_fn(FILE **)和$winerelease/server/registry.c中的save_branch( struct key *key, const char *path )。
_get_tmp_fn(FILE **) @ $winerelease/misc/registry.c :
-----------------------------------------------------
static LPSTR _get_tmp_fn(FILE **f)
{
LPSTR ret;
int tmp_fd,count;
ret = _xmalloc(50);
for (count = 0;;) {
sprintf(ret,"/tmp/reg%lx%04x.tmp",(long)getpid(),count++);
//here file regxxxyyyy.tmp is not created with secure permssions
if ((tmp_fd = open(ret,O_CREAT | O_EXCL | O_WRONLY,0666)) != -1) break;
if (errno != EEXIST) {
ERR("Unexpected error while open() call: %s\n",strerror(errno));
free(ret);
*f = NULL;
return NULL;
}
}
------------------------------------------------------
save_branch( struct key *,const char * ) @ $winerelease/server/registry.c:
------------------------------------------------------
static int save_branch( struct key *key, const char *path )
{
struct stat st;
char *p, *real, *tmp = NULL;
int fd, count = 0, ret = 0, by_symlink;
FILE *f;
.
.
.
for (;;)
{
sprintf( p, "reg%lx%04x.tmp", (long) getpid(), count++ );
//here file regxxxyyyy.tmp is not created with secure permssions
if ((fd = open( tmp, O_CREAT | O_EXCL | O_WRONLY, 0666 )) != -1) break;
if (errno != EEXIST) goto done;
close( fd );
}
.
.
.
}
------------------------------------------------------
open()在创建regxxxyyyy.tmp时,会使用0666模式做为参数。由于默认的umask是022 ==> (0666) &~ (022) = 0644 = -rw-r--r-- ,因此会以0644权限创建文件。
<*来源:Giovanni Delvecchio (badpenguin79@hotmail.com)
链接:http://marc.theaimsgroup.com/?l=bugtraq&m=111082537009842&w=2
http://bugs.winehq.org/show_bug.cgi?id=2715
http://www.zone-h.org/advisories/read/id=7300
*>
建议:
临时解决方法:
如果您不能立刻安装补丁或者升级,NSFOCUS建议您采取以下措施以降低威胁:
* 使用0600模式调用open()函数:
... open(ret,O_CREAT | O_EXCL | O_WRONLY,0600)) ....
厂商补丁:
Wine
----
目前厂商已经发布了升级补丁以修复这个安全问题,请到厂商的主页下载:
http://bugs.winehq.org/show_bug.cgi?id=2715
浏览次数:3263
严重程度:0(网友投票)
绿盟科技给您安全的保障