Bug 2238464 (CVE-2023-39070)

Summary: CVE-2023-39070 cppcheck: a local code execution via the removeContradiction parameter in token.cpp:1934 due to use-after-free
Product: [Other] Security Response Reporter: Sandipan Roy <saroy>
Component: vulnerabilityAssignee: Product Security <prodsec-ir-bot>
Status: NEW --- QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: dodji, sipoyare
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
A flaw was found in the cppcheck package. A local code execution might be possible via the removeContradiction parameter in token.cpp:1934 due to a heap use-after-free.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2238466, 2238465    
Bug Blocks: 2238467    

Description Sandipan Roy 2023-09-12 04:29:26 UTC
An issue in Cppcheck 2.12 dev allows a local attacker to execute arbitrary code via the removeContradiction parameter in token.cpp:1934.

https://sourceforge.net/p/cppcheck/discussion/general/thread/fa43fb8ab1/

Comment 1 Sandipan Roy 2023-09-12 04:29:52 UTC
Created cppcheck tracking bugs for this issue:

Affects: epel-all [bug 2238466]
Affects: fedora-all [bug 2238465]

Comment 3 Siddhesh Poyarekar 2023-09-13 11:23:21 UTC
From the upstream bug:

"That is clearly invalid code. Cppcheck generally assumes that its input is compileable."

This is a bug, but clearly not a security vulnerability.  If a "local code execution" needs shell, it is possible for an attacker to do much more than pass arbitrary strings to cppcheck.

Comment 4 Dodji Seketeli 2023-09-19 13:26:59 UTC
(In reply to Siddhesh Poyarekar from comment #3)
> From the upstream bug:
> 
> "That is clearly invalid code. Cppcheck generally assumes that its input is
> compileable."
> 
> This is a bug, but clearly not a security vulnerability.  If a "local code
> execution" needs shell, it is possible for an attacker to do much more than
> pass arbitrary strings to cppcheck.

Indeed.

Also, how is this related to RHEL-8?

Unless I am mistaken, the version of cppcheck in RHEL-8 is 2.4 whereas this use-after-free error is on cppcheck 2.12.  Looking at the code, 2.4 is quite different from 2.12. I have tried to reproduce the error by compiling cppcheck 2.4 (from the RHEL 8.8 branch) with asan as described in https://sourceforge.net/p/cppcheck/discussion/general/thread/fa43fb8ab1, I ran bin/cppcheck on the "poc" input program and ... there was no error.

What am I missing?