Skip to content

DSCView::Init accesses potentially inexisting field when parsing platform #6073

Closed
@droe

Description

@droe

Version and Platform (required):

  • Binary Ninja Version: 4.2.6335-dev Personal (1828c7e4)
  • OS: macOS
  • OS Version: 14.5 (23F79)
  • CPU Architecture: arm64

Bug Description:

DSCView::Init reads uint32_t platform from hardcoded offset 0xd8 of the dsc header. However, struct dyld_cache_header for older shared caches (say, iOS 10) is smaller than 0xd8 and does not include a platform field. When loading such a dyld shared cache, Binary Ninja fails to initialize DSCViewAlpha and logs a misleading error message showing a garbage platform value.

Steps To Reproduce:

  1. Download ipsw for some old iOS version, say, iOS 10.3
  2. Extract the dyld shared cache from the system volume dmg in the ipsw
  3. Open the dyld shared cache in Binary Ninja
  4. See that DSCViewAlpha failed to initialize with "unknown platform" and a garbage value read from outside of the header

Expected Behavior:

Ideally, load the shared cache with DSCView fully functional (happy to assist with testing).

At a minimum though, DSCView::Init should not read fields that do not exist in the header, and fail with a more self-explanatory error message such as "dyld shared cache format unsupported" or some such.

There is a trick to figure out the size of the header struct: Based on the assumption that the first mapping will immediately follow the header, we can look at mappingOffset and never read any header fields that extend beyond that offset.

Screenshots/Video Recording:

[Default] Unknown platform: 24576
[Default] BinaryView of type 'DSCViewAlpha' failed to initialize!

Binary:

See repro.

Additional Information:
Please add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions