Nytro Posted August 6, 2013 Report Posted August 6, 2013 PuTTY 0.62 Heap OverflowAuthored by Gergely EberhardtPuTTY versions 0.62 and below suffer from an SSH handshake heap overflow vulnerability.PuTTY SSH handshake heap overflow (CVE-2013-4852)Description:PuTTY versions 0.62 and earlier - as well as all software thatintegrates these versions of PuTTY - are vulnerable to an integer overflowleading to heap overflow during the SSH handshake before authentication,causedby improper bounds checking of the length parameter received from theSSH server.This allows remote attackers to cause denial of service, and may have moresevere impact on the operation of software that uses PuTTY code.Affected software products:- PuTTY up to and including 0.62- WinSCP before 5.1.6- all other software that uses vulnerable (revision 9895 or earlier)PuTTY codeDetails:A malformed size value in the SSH handshake could cause an integeroverflow, asthe getstring() function in sshrsa.c and sshdss.c read the handshakemessagelength without checking that it was not a negative number.Specifically, the bignum_from_bytes() function invoked by getstring()received adata buffer along with its length represented by a signed integer(nbytes) andperformed the following arithmetical operation before allocating memoryto storethe buffer: w = (nbytes + BIGNUM_INT_BYTES - 1) / BIGNUM_INT_BYTES; /*bytes->words */ result = newbn(w);If the value of nbytes was -1 (0xffffffff), the value of w wouldoverflow to avery small positive number (depending on the value of BIGNUM_INT_BYTES),causingnewbn() to reserve a very small memory area. Then a large number ofbytes wouldbe copied into the data buffer afterwards, resulting in a heap overflow.Similarly, if nbytes was chosen so that w would be -1, the newbn() functionwould allocate zero bytes in memory via snewn() and attempt to write thesize ofthe Bignum (in four bytes) into the allocated zero-byte area, alsoresulting ina heap overflow.Consequences:In the standalone PuTTY client the attacker does not have precisecontrol overthe memory corruption, so this bug can only cause a local denial-of-service(crash). However, in other software that uses PuTTY code, such heapcorruptioncould have more severe effects. Specifically in case of WinSCP, thisvulnerability could potentially lead to code execution due to the exceptionhandling employed by the program.Solution:This vulnerability has been fixed in the development version of PuTTY[2]. Alldevelopers using PuTTY code are recommended to use revision 9896 or later.The potential code execution vulnerability has been addressed in WinSCP5.1.6[3].Credits:This vulnerability was discovered and researched by Gergely Eberhardtfrom SEARCH-LAB Ltd. (www.search-lab.hu)References:[1] http://www.search-lab.hu/advisories/secadv-20130722[2] http://svn.tartarus.org/sgt?view=revision&sortby=date&revision=9896[3] http://winscp.net/tracker/show_bug.cgi?id=1017Sursa: PuTTY 0.62 Heap Overflow ? Packet Storm Quote