Description
Vulnerable Products
- LibreCAD 2.2.0-rc3 and older
- Jw_cad 8.24a and older
Steps to reproduce or sample file
- Start LibreCAD 2.2.0-rc3 in a debugger
- File/Open...
- Unzip and open the attached proof of concept file
- Observe
ACCESS_VIOLATION
crash, witheip=0x41414141
(AAAA)
Screenshot:
Cause
The CDataMoji
entity deserialization at LibreCAD/libraries/jwwlib/src/jwwdoc.h
is vulnerable to
a stack buffer overflow.
char buf[512]
declared in CDataMoji::Serialize()
on line 512
is of fixed size 512. Some varieties of CDataMoji
provide their own size, e.g. MojiData2 on line 523
and no bounds checking is performed. This allows an attacker to overflow buf
and overwrite other stack variables,
including the return address.
The attached PoC file is tuned to trigger this behavior in the latest windows release of LibreCAD, but the same bug is also present
in older versions and on other platforms.
Impact
An attacker can craft a JW-CAD input file and thereby gain control over execution flow (EIP controlled directly).
This allows an attacker to run arbitrary code on the system running LibreCAD, with the privileges of the current user.
Proposed Mitigation
- Perform bounds checking in
CDataMoji::Serialize()
, and refuse to load the file if it would overflowbuf
. - Enable stack smashing protection in the windows build of LibreCAD.
Operating System and LibreCAD version info
Version: 2.2.0-rc3
Compiler: GNU GCC 7.3.0
Compiled on: Nov 29 2021
Qt Version: 5.12.4
Boost Version: 1.65.1
System: Windows 10 (10.0)