avast / avast/retdec

incorrect value/control flow recovery

Open
#1,201 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
8.6k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

**Description:**
RetDec doesn't recover correct final values. (Not sure if it's due to incorrect control flow recovery)
In the original code, the arguments passed to `set_var` should be `2`, `321`, and 13134243433 (0x30edca669)
Instead, they are `15`, `123`, and 0x30edca669 in the decompiled code.
And the printed string should be `"another local string"`.

Decompiled code:
```
while (v1 < 111 != (110 - v1 & v1) < 0) {
// 0x4012e0
v1++;
v2 = 0x30edca669;
__asm_lfence();
}
// 0x401304
set_var(15, 123, v2); // should be (2, 321, v2)
*(int64_t *)&g4 = (int64_t)"local string";
return printf("%s", "local string"); // should be "another local string"
```

**Files:**
[retdec.zip](https://github.com/avast/retdec/files/15155934/retdec.zip)
The original code, compiled program and the decompiled code are included.
The program is compiled by clang-12.
Unfortunately I don't have the optimization options used to compile the program,
but if you run it, it'll print out the string assigned to `str` (`"another local string"`),
which is not presented in the decompiled code.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with retdec.zip, which contains the original code, compiled program, and decompiled output; compare the recovered control flow, set_var arguments, and string value. No source file or test is named in the issue, so identify the relevant recovery entry point first. Done means the sample decompiles with arguments 2, 321, and 13134243433 and prints "another local string".

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.