Vector35 / Vector35/binaryninja-api

Value zero sometimes incorrectly assumed for external symbols

Open
#8,189 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Description

Version and Platform (required):

  • Binary Ninja Version: 5.4.9670-dev (d8035518)
  • Edition: Commercial
  • OS: Arch Linux
  • OS Version: rolling release
  • CPU Architecture: x64

Bug Description:
In the below rv32gc binary, the HLIL of the do_something function shows a call to *8 instead of *(*some_struct_ptr + 8). I assume this is because the lw to a5 at 00010046 is incorrectly assumed to load the value 0 rather than an unknown value.

I have also seen more problematic cases of this or a similar bug, which led to large parts of a function being optimized away because the function does an early return if some external symbol is zero.

This bug seems to happen regardless of the type of the external symbol.

I do not know if this bug happens on other architectures. I only tested rv32gc.

Steps To Reproduce:
Please provide all steps required to reproduce the behavior:

  1. Open the binary in BN
  2. Set the view to HLIL
  3. Navigate to the do_something function at 0001005a
  4. Observe that the HLIL shows a call to *8

Expected Behavior:
I expect BN to not assume the value 0 for external symbols.

Screenshots/Video Recording:
Image

Binary:
omega regex transpiles magnificently

Additional Information:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the reported rv32gc binary in Binary Ninja and inspect the HLIL for do_something at 0001005a, including the lw at 00010046. Confirm how the external symbol is propagated into the call expression. Done means the external symbol remains unknown rather than becoming zero, and the HLIL no longer shows a call to *8.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
reverse-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.