Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dyld Shared Cache - Method Symbol Resolution #6173

Open
frankmarco2000 opened this issue Nov 21, 2024 · 5 comments
Open

Dyld Shared Cache - Method Symbol Resolution #6173

frankmarco2000 opened this issue Nov 21, 2024 · 5 comments
Labels
File Format: SharedCache Issue with the dyld_shared_cache plugin State: Awaiting Triage Issue is waiting for more in-depth triage from a developer

Comments

@frankmarco2000
Copy link

Version and Platform (required):

  • Binary Ninja Version: 4.2.6455 (02c8da1e)
  • OS: macOS Sonoma
  • OS Version: 14.6.1
  • CPU Architecture: Apple M2 Max

Bug Description:
IPSW:
iPhone 8+
iOS 14.4.2
Version: 18D70
Link:
https://updates.cdn-apple.com/2021WinterFCS/fullrestores/071-22616/63E5DC4B-1767-4697-9CD3-97DD4A0E033A/iPhone_5.5_P3_14.4.2_18D70_Restore.ipsw

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

  1. Go to...
  2. Click on...
  3. Scroll down to...
  4. See error

Expected Behavior:
Please provide a clear and concise description of what you expected to happen.
I expect the symbols to be fully resolved as the attached screenshot from IDA Pro shows:
Screenshot 2024-11-21 at 12 14 05 PM

Opened dyld cache file and selected the MessageProtection framework.
When the analysis was complete, I started browsing the symbols. When looking at the class NGMFullDeviceIdentity, in the symbol viewer, the method names are corrupted.

Screenshots/Video [Recording:](Screenshot 2024-11-21 at 11 04 14 AM)
Screen shot showing corrupted method names is attached.
Screenshot 2024-11-21 at 11 04 14 AM

Binary:
Due to the size of the file it is not reasonable to attach to ticket. Download link is provided above.
Additional Information:
Please add any other context about the problem here.

@0cyn 0cyn added File Format: SharedCache Issue with the dyld_shared_cache plugin State: Awaiting Triage Issue is waiting for more in-depth triage from a developer labels Nov 21, 2024
@WeiN76LQh
Copy link

Might be related to #6172

@bdash
Copy link
Contributor

bdash commented Nov 22, 2024

I think the v3 slide info has the same bug I noticed in the v5 slide info and mentioned in #6172 (comment). The page_start[i] value needs to be divided by 8 before being used as an offset into the page.

@bdash
Copy link
Contributor

bdash commented Nov 22, 2024

The v2 slide info handling also appears to be incomplete. It doesn't deal with rebase locations being split across multiple linked lists (DYLD_CACHE_SLIDE_PAGE_ATTR_EXTRA). I'm not sure which slide info format is used by iOS 14.4.2.

@WeiN76LQh
Copy link

WeiN76LQh commented Nov 23, 2024

It seems the issue here is that reader->ReadCString in DSCObjCProcessor::ReadMethodList returns garbage if it attempts to read an unmapped address. The garbage data is probably uninitialised memory from reading MMappedFileAccessor.m_mmap.

I'm testing this on the same iOS version but different device. For me the DSC address its reading the method name from is not actually mapped yet because I didn't ask it to load the image containing the address. However VM::MappingAtAddress is actually returning a mapping for the address.

@bdash
Copy link
Contributor

bdash commented Nov 25, 2024

#6192 will fix selectors either loading as garbage or being entirely missing from the symbol list with shared caches for recent macOS versions and some older iOS versions (~14 or so).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
File Format: SharedCache Issue with the dyld_shared_cache plugin State: Awaiting Triage Issue is waiting for more in-depth triage from a developer
Projects
None yet
Development

No branches or pull requests

4 participants