SA30228 / CVE

Similar documents
SA31675 / CVE

SA28083 / CVE

Exploiting USB/IP in Linux

CSE 509: Computer Security

Analysis of MS Multiple Excel Vulnerabilities

Leveraging CVE for ASLR Bypass & RCE. Gal De Leon & Nadav Markus

12 th January MWR InfoSecurity Security Advisory. WebSphere MQ xcsgetmem Heap Overflow Vulnerability. Contents

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Brave New 64-Bit World. An MWR InfoSecurity Whitepaper. 2 nd June Page 1 of 12 MWR InfoSecurity Brave New 64-Bit World

MWR InfoSecurity Security Advisory. Linux USB Device Driver - Buffer Overflow. 29 th October Contents

Buffer overflow prevention, and other attacks

Heap Off by 1 Overflow Illustrated. Eric Conrad October 2007

Lecture 4 September Required reading materials for this class

Program Security and Vulnerabilities Class 2

Homework 3 CS161 Computer Security, Fall 2008 Assigned 10/07/08 Due 10/13/08

Qiang Li && Zhibin Hu/Qihoo 360 Gear Team Ruxcon 2016

Outline. Classic races: files in /tmp. Race conditions. TOCTTOU example. TOCTTOU gaps. Vulnerabilities in OS interaction

CSC 591 Systems Attacks and Defenses Stack Canaries & ASLR

Secure Software Programming and Vulnerability Analysis

Other array problems. Integer overflow. Outline. Integer overflow example. Signed and unsigned

Stack Overflow COMP620

Beyond Stack Smashing: Recent Advances in Exploiting. Jonathan Pincus(MSR) and Brandon Baker (MS)

typedef void (*type_fp)(void); int a(char *s) { type_fp hf = (type_fp)(&happy_function); char buf[16]; strncpy(buf, s, 18); (*hf)(); return 0; }

Memory Safety (cont d) Software Security

Huawei Frame Buffer Driver Arbitrary Memory Write

Offensive Security My First Buffer Overflow: Tutorial

CS 161 Computer Security

Ping of death Land attack Teardrop Syn flood Smurf attack. DOS Attack Methods

Documentation for exploit entitled nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY Fall Quiz I

Software Security: Buffer Overflow Attacks

malloc() is often used to allocate chunk of memory dynamically from the heap region. Each chunk contains a header and free space (the buffer in which

We would like to find the value of the right-hand side of this equation. We know that

BUFFER OVERFLOW. Jo, Heeseung

SA30285 / CVE

Buffer Overflow. Jo, Heeseung

DHCP is hard. Felix Wilhelm HITB Dubai 2018

Buffer Overflow. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Hackveda Training - Ethical Hacking, Networking & Security

20: Exploits and Containment

ISA564 SECURITY LAB. Code Injection Attacks

CSE 127 Computer Security

System Security Class Notes 09/23/2013

CSC 405 Computer Security Stack Canaries & ASLR

Basic Buffer Overflows

Fundamentals of Computer Security

Play with FILE Structure Yet Another Binary Exploitation Technique. Abstract

MWR InfoSecurity Security Advisory. Mozilla Firefox 64-Bit SetTextInternal () Heap Buffer Overflow. 23 rd June 2010

ENEE 457: Computer Systems Security. Lecture 16 Buffer Overflow Attacks

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Buffer Overflows Defending against arbitrary code insertion and execution

CS 161 Computer Security

EURECOM 6/2/2012 SYSTEM SECURITY Σ

Changelog. Corrections made in this version not in first posting: 1 April 2017: slide 13: a few more %c s would be needed to skip format string part

CSCE 548 Building Secure Software Integers & Integer-related Attacks & Format String Attacks. Professor Lisa Luo Spring 2018

HeapHopper. Bringing Bounded Model Checking to Heap Implementation Security

Secure Coding in C and C++

Applications. Cloud. See voting example (DC Internet voting pilot) Select * from userinfo WHERE id = %%% (variable)

CS16 Exam #1 7/17/ Minutes 100 Points total

CS 642 Homework #4. Due Date: 11:59 p.m. on Tuesday, May 1, Warning!

Sandboxing. CS-576 Systems Security Instructor: Georgios Portokalidis Spring 2018

Heaps of Heap-based Memory Attacks

Lecture 07 Heap control data. Stephen Checkoway University of Illinois at Chicago

Defeat Exploit Mitigation Heap Attacks. compass-security.com 1

PRESENTED BY: SANTOSH SANGUMANI & SHARAN NARANG

Software Security: Buffer Overflow Defenses

SA33901 / CVE

Baggy bounds with LLVM

String Oriented Programming Exploring Format String Attacks. Mathias Payer

CMPSC 497 Buffer Overflow Vulnerabilities

Identifying Memory Corruption Bugs with Compiler Instrumentations. 이병영 ( 조지아공과대학교

Secure Coding in C and C++ Dynamic Memory Management Lecture 5 Jan 29, 2013

New York University CSCI-UA : Advanced Computer Systems: Spring 2016 Midterm Exam

Bypassing Browser Memory Protections

From local user to root Ac1dB1tch3z s exploit analysis. Nicolò October 28

Module: Program Vulnerabilities. Professor Trent Jaeger. CSE543 - Introduction to Computer and Network Security

Intrusion Detection and Malware Analysis

CSE 127 Computer Security

Software Security: Buffer Overflow Attacks (continued)

CS140 Operating Systems Final December 12, 2007 OPEN BOOK, OPEN NOTES

CMPSC 497 Other Memory Vulnerabilities

Memory Corruption Vulnerabilities, Part II

Lecture 1: Buffer Overflows

Week 5, continued. This is CS50. Harvard University. Fall Cheng Gong

MaRTE OS Misc utilities

MediaTek Log Filtering Driver Information Disclosure

MWR InfoSecurity Security Advisory. IBM WebSphere MQ - rridecompress Remote Denial of Service Vulnerability. 4th March 2010

Black Box Debugging of Embedded Systems

General Pr0ken File System

CSE 127 Computer Security

Advanced System Security: Vulnerabilities

Buffer overflow is still one of the most common vulnerabilities being discovered and exploited in commodity software.

CSE 127 Computer Security

Reminder: compiling & linking

Malware and Vulnerability Check Point. 1. Find Problems 2. Tell Vendors 3. Share with Community

Linux Memory Layout. Lecture 6B Machine-Level Programming V: Miscellaneous Topics. Linux Memory Allocation. Text & Stack Example. Topics.

Triggering Deep Vulnerabilities Using Symbolic Execution

Computer Science 50: Introduction to Computer Science I Harvard College Fall Quiz 0 Solutions. Answers other than the below may be possible.

This time. Defenses and other memory safety vulnerabilities. Everything you ve always wanted to know about gdb but were too afraid to ask

Dissecting a 17-year-old kernel bug

Transcription:

Generated by Secunia 29 May, 2008 5 pages

Table of Contents Introduction 2 Technical Details 2 Exploitation 4 Characteristics 4 Tested Versions 5 Fixed Versions 5 References 5 Generated by Secunia 29 May, 2008 Page 1 of 5

Introduction: ============= A boundary error in Samba can be exploited to cause a heap-based buffer overflow and compromise a vulnerable system. Technical Details: ================== Samba is a popular open source implementation of the SMB (Service Message Block) protocol. An SMB packet starts with one byte containing the SMB command followed by three bytes containing the length of the SMB data. When Samba receives an SMB packet with an overly long length in a client context, a heap-based buffer overflow takes place. This can be exploited to execute arbitrary code on an affected system. The client-side implementation of Samba is included in the "libsmbclient" library. When communication with a server is started, an input buffer is allocated with a size of "CLI_BUFFER_SIZE + 4 + SAFETY_MARGIN" (66563) bytes by the "cli_initialise()" function. [libsmb/clientgen.c:282] struct cli_state *cli_initialise(void) { cli->bufsize = CLI_BUFFER_SIZE+4; <-- 65535 + 4 cli->inbuf = (char *)SMB_MALLOC(cli->bufsize+SAFETY_MARGIN); [include/client.h:29] #define CLI_BUFFER_SIZE (0xFFFF) [include/smb.h:40] #define SAFETY_MARGIN 1024 <-- + 1024 The client then opens a TCP connection to the SMB server (usually on TCP port 139 or 445). A protocol negotiation follows via a call to "cli_negprot()". The purpose of "cli_negprot()" is to decide which version of the SMB protocol is to be used with the selected server. The function sends a "negprot" command and calls "cli_receive_smb()" in order to receive the response. NOTE: "cli_receive_smb()" is called throughout the SMB session whenever an SMB packet is expected. The protocol negotiation phase is only given as an example. [libsmb/cliconnect.c:1222] BOOL cli_negprot(struct cli_state *cli) SCVAL(cli->outbuf,smb_com,SMBnegprot); cli_setup_packet(cli); cli_send_smb(cli); <-- send the negprot command if (!cli_receive_smb(cli)) <-- receive SMB packet "cli_receive_smb()" calls "client_receive_smb()" with the client input buffer ("cli->inbuf") passed via the second parameter. Generated by Secunia 29 May, 2008 Page 2 of 5

[libsmb/clientgen.c:82] BOOL cli_receive_smb(struct cli_state *cli) ret = client_receive_smb(cli->fd,cli->inbuf,cli->timeout); "client_receive_smb()" is a wrapper for "receive_smb_raw()", calling the function with the received parameters unmodified (source code not included). "receive_smb_raw()" calls "read_smb_length_return_keepalive()" in order to extract the length of the SMB packet. [lib/util_sock.c:664] BOOL receive_smb_raw(int fd, char *buffer, unsigned int timeout) { ssize_t len,ret; len = read_smb_length_return_keepalive(fd,buffer,timeout); "read_smb_length_return_keepalive()" reads 4 bytes from the socket and calls the "smb_len" macro with the buffer as a parameter. [lib/util_sock.c:601] static ssize_t read_smb_length_return_keepalive(int fd, char *inbuf, unsigned int timeout) ok = (read_data(fd,inbuf,4) == 4); <-- read four bytes len = smb_len(inbuf); <-- extract the length "smb_len" extracts the length from the two last bytes and from the last bit of the third byte. This allows a maximum length equal to 0x1FFFF (131071 decimal). [include/smb_macros.h:191] #define smb_len(buf) (PVAL(buf,3) (PVAL(buf,2)<<8) ((PVAL(buf,1)&1)<<16)) After extracting the length, "receive_smb_raw()" continues its execution by testing if the length goes above "BUFFER_SIZE + (SAFETY_MARGIN/2)". If the test yields a positive result, the function returns. Otherwise, the whole SMB packet is read into the input buffer at offset 4 (whole SMB packet == length bytes). [lib/util_sock.c:692] if (len > BUFFER_SIZE + (SAFETY_MARGIN/2)) { <-- error } ret = read_data(fd,buffer+4,len); "SAFETY_MARGIN" has a constant value of 1024 (as previously noted), resulting in a maximum SMB packet length value of "BUFFER_SIZE" + 512. "BUFFER_SIZE" is equal to 128*1024 if the system on which Samba was compiled supports 64-bit file offsets (i.e. files over 2 GB are supported), and equal to 0xFFFF on other systems. Support for 64-bit offsets is included in all modern operating systems (e.g. current Linux distributions) and it is given by the "LARGE_SMB_OFF_T" define (which internally is set to 1 due to sizeof(off_t) being 8). Generated by Secunia 29 May, 2008 Page 3 of 5

[include/smb.h:34] #if defined(large_smb_off_t) #define BUFFER_SIZE (128*1024) #else /* no large readwrite possible */ #define BUFFER_SIZE (0xFFFF) #endif [include/includes.h:495] # if (defined(have_explicit_largefile_support) && defined(have_off64_t)) (defined(sizeof_off_t) && (SIZEOF_OFF_T == 8)) # define LARGE_SMB_OFF_T 1 # endif The imposed limit of "BUFFER_SIZE" + 512 (equal to 0x20200) is greater than the maximum length of an SMB packet (0x1FFFF), allowing a maximum number of 0x1FFFF (131071 decimal) bytes. This will result in a buffer overflow when the network data is read into the client buffer (having 66559 bytes left after the first four bytes). The overflow will result in a maximum of 64512 bytes on the heap being overwritten with user-controlled data. Exploitation: ============= Exploiting the vulnerability for code execution is possible in GLIBC versions 2.6 and 2.7 by overwriting vital fields of the next heap chunk. Code execution on other GLIBC versions has not been proven, but cannot be ruled out. The buffer overflow can be triggered by tricking a user into connecting to a malicious SMB server (e.g. by clicking an "smb://" link). The vulnerability can also be exploited without user interaction if a Samba server is configured to run as a domain master browser (the "domain master" or "domain logons" and the "wins support" options are enabled in smb.conf). Specifically, an attacker can register itself as a local master browser and trick the Samba server into establishing an SMB session (as a client) to the attacker's machine. Another scenario in which a WINS server used by Samba can be tricked into registering a malicious domain master browser is also viable. Secunia Research has developed a PoC for the vulnerability. This is available to customers on Secunia Proof of Concept and Exploit Code Services. Characteristics: ================ Detection: Look for SMB connections established to remote hosts (usually on TCP ports 139 or 445). Received SMB packets with a length over 66559 should be considered malicious. Verification: Create a server listening on port 445, which sends SMB packets with a length of 0x1FFFF bytes. Connect to the server using smbclient (e.g. "smbclient -L <host>"). A "smbclient" binary coming from a vulnerable Samba package should crash. Generated by Secunia 29 May, 2008 Page 4 of 5

Identification: Samba versions 3.0.28a and 3.0.29 are confirmed to be vulnerable. Prior versions may also be affected. In order to determine the version of the installed Samba package execute one of the installed Samba binaries with the "--version" option attached (e.g. "smbd --version"). If no binaries are present, construct a program linked against libsmbclient, calling the "samba_version_string()" function. E.g.: void main() { printf("%s", samba_version_string()); } Tested Versions: ================ The vulnerability was analysed on Ubuntu 8.04 using Samba 3.0.28a. Fixed Versions: =============== The vendor has released version 3.0.30, which fixes the vulnerability by properly checking the size of incoming SMB packets. A patch for version 3.0.29 is also available. References: =========== SA30228: http://secunia.com/advisories/30228/ CVE-2008-1105: http://secunia.com/cve_reference/cve-2008-1105/ Secunia Research: http://secunia.com/secunia_research/2008-20/ Samba: http://www.samba.org/samba/security/cve-2008-1105.html Generated by Secunia 29 May, 2008 Page 5 of 5