Perl 5.22 VDir::MapPathA/W Out-Of-Bounds Reads / Buffer Over-Reads
Posted on 11 April 2016
---------------------------------------------------------------- Name: Perl 5.22 VDir::MapPathA/W Out-of-bounds Reads and Buffer Over-reads Discovered By: John Leitch, Bryce Darling Url: http://autosectools.com/Perl-VDir-MapPath-Out-of-bounds-Read Report: https://rt.perl.org/Public/Bug/Display.html?id=126755 CVE-ID: CVE-2015-8608 Reported: November 28, 2015 Disclosed: January 11, 2016 ---------------------------------------------------------------- Perl 5.22 suffers from two out-of-bounds reads and multiple small buffer over-read vulnerabilities in the VDir::MapPathA and VDir::MapPathW functions that could potentially be exploited to achieve arbitrary code execution. The out-of-bounds read issues exist because the functions in question do not validate that the chr argument passed to DriveIndex, which calculates an index: inline int DriveIndex(char chr) { if (chr == '\' || chr == '/') return ('Z'-'A')+1; return (chr | 0x20)-'a'; }; In the VDir::MapPathA function, DriveIndex is called with a potentially untrusted value, pInName, and the return value is then passed to GetDirA: char *VDir::MapPathA(const char *pInName) { /* * possiblities -- relative path or absolute path with or without drive letter * OR UNC name */ [...] if (pInName[1] == ':') { [...] } else { /* relative path with drive letter */ strcpy(szBuffer, GetDirA(DriveIndex(*pInName))); strcat(szBuffer, &pInName[2]); if(strlen(szBuffer) > MAX_PATH) szBuffer[MAX_PATH] = '