Open Babel MOL2 format attribute and value out-of-bounds write vulnerability
An out-of-bounds write vulnerability exists in Open Babel's MOL2 format parsing when the 'c' option is used, due to an unbounded sscanf into fixed-size stack buffers. An attacker could provide a malicious file to trigger arbitrary code execution.
Originally disclosed on Cisco Talos
An out-of-bounds write vulnerability exists in the MOL2 format attribute and value functionality of Open Babel 3.1.1 and master commit 530dbfa3. A specially crafted malformed file can lead to arbitrary code execution.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The code uses sscanf with an unbounded %s format specifier to copy data into fixed-size stack buffers, causing a stack buffer overflow.
Impact
Depending on how the code is compiled and the stack is laid out, this issue can lead to arbitrary code execution.
What the attacker needed
Victim opens a malicious MOL2 file; the -ac option is used
How it was found
- Run obabel with MOL2 input, SDF output, and the -ac option.
- Provide a MOL2 file containing a line starting with '###########' followed by a long attribute and value.
- The sscanf call writes beyond the 32-byte attr and val buffers, causing a stack buffer overflow.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Open Babel is a tool that converts chemical file formats. When it reads a special comment line in a MOL2 file, it copies text into small fixed-size boxes on the stack without checking length, so a long line overflows those boxes and can overwrite other data, potentially letting an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.