binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

_objc_msgSend rewrite parser cannot handle multiple functions sharing a selector name

Open elbiazo opened this issue 3 years ago • 5 comments

Lets say there are two class. Employee class and Student class. They are not related at all but they both have function called print. current _objc_msgSend resolver doesn't account for that and sets everyone function to just one function.

You can see below its calling a function from Student when Employee is not even related to it image

I think it should only set the address when you know for sure which object it is. maybe do sink -> init source analysis to know which class it is. and only change the call when it is likely correct.

elbiazo avatar Sep 21 '22 21:09 elbiazo

Is this binary shareable? I can recreate something I believe is similar but having this test case available to me would be convenient. You're welcome to share it in private via Slack, etc. if you would prefer not to upload it here.

jonpalmisc avatar Sep 21 '22 21:09 jonpalmisc

i can do that. will do in a bit. driving

elbiazo avatar Sep 21 '22 21:09 elbiazo

For employees: search internal Slack for Applause Weigh Train Urge to find the binary.

jonpalmisc avatar Sep 21 '22 22:09 jonpalmisc

We've taken steps to mitigate this in versions >= 5.1.7572. The Objective-C call rewrite functionality will now be disabled by default on Objective-C Binaries, with the option to re-enable it application-wide or in Open with Options.

The following iOS system binary is a strong example of us confidently getting these incorrect:

Calculator.armv7.iOS6.zip

Image


I'm going to leave this issue open to track our progress on further improving this functionality.

0cyn avatar Jun 05 '25 17:06 0cyn

Note that you can see the potential targets of a specific message send by clicking on the selector and looking at its cross references. After https://github.com/Vector35/binaryninja-api/pull/6814, the Objective-C workflow now adds cross-references from a selector to known implementations of that selector in the loaded binary.

bdash avatar Jun 05 '25 22:06 bdash