• Stars
    star
    307
  • Rank 136,109 (Top 3 %)
  • Language
    C
  • License
    MIT License
  • Created about 1 year ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C library for manipulating MachO/FAT files and their code signatures

ChOma

ChOma is a simple library for parsing and manipulating MachO files and their CMS blobs. Written for exploitation of CVE-2023-41991, a vulnerability in the CoreTrust kernel extension, and for use in TrollStore, and in Dopamine as a kernel patchfinder.

Usage

To use the library, you can compile with make all. This will produce the choma_cli executable that demonstrates the abilities of this library, and then libchoma.a and libchoma.dylib which can be linked to your own project.

In output/tests, you will find choma_cli and ct_bypass. choma_cli is a simple CLI tool that demonstrates the abilities of this library, and ct_bypass is a proof-of-concept exploit for CVE-2023-41991 that uses this library. ct_bypass only works on iOS binaries, as trying to use macOS binaries will result in the bypass being unsuccessful as we use an iOS identity to insert into the code signature.

CoreTrust bypass

ChOma was written primarily for the purpose of exploiting CVE-2023-41991, which allows a binary to bypass CoreTrust during code-signing and appear as an App Store-signed binary. As a result, binaries can be permanently signed on device and have arbitrary entitlements, apart from a few restricted ones that are only allowed to be used by trustcached binaries.

The vulnerability is caused by CoreTrust incorrectly handling multiple SignerInfo structures in a CMS blob. By having one SignerInfo that contains a valid signature (but from an identity that is not trusted by CoreTrust), and another SignerInfo that contains an invalid signature (but from an App Store identity), we can trick CoreTrust into thinking that the binary is signed by the App Store identity, and therefore allow it to be executed.

The exploit is implemented in ct_bypass, and works by:

  1. Taking a pseudo-signed binary (a binary that has been signed by ldid).
  2. Updating the load commands by calculating the new sizes of the __LINKEDIT segment and the code signature.
  3. Updating the page hashes in the SHA256 CodeDirectory to match the new load command data.
  4. Replacing the SHA1 CodeDirectory with one from a valid App Store-signed binary.
  5. Inserting a template signature blob into the code signature, containing two SignerInfo structures.
  6. Updating the necessary fields in the signature blob to match the CD hashes.
  7. Signing the signature blob for the custom identity (the App Store identity will already have an intact signature).
  8. Inserting the new code signature into the binary.

Terminology

Inside ChOma, there are a few terms that are used to describe various parts of the MachO file. These are:

  • FAT - represents a FAT MachO file (a MachO file that contains multiple slices, which are each a MachO file for a different architecture).
  • MachO - represents either a single-architecture MachO file, or a slice of a FAT MachO file.

Underlying mechanisms

ChOma uses the MemoryBuffer structure to provide a unified way to read, write, shrink and expand data buffers, that works across both files and memory. Each MemoryBuffer has a context field that determines whether the functions interpret it as a BufferedStream object (for regular memory buffers) or as a FileStream object (for files).

Each MemoryBuffer object contains function pointers for reading, writing, retrieving the size, expanding, shrinking and then soft or hard cloning. You can inspect these inside src/MemoryBuffer.h, and can see how they are used by looking at how we manipulate MachO files across the library.

More Repositories

1

TrollStore

Jailed iOS app that can install IPAs permanently with arbitary entitlements and root helpers because it trolls Apple
Objective-C
17,532
star
2

Dopamine

Dopamine is a semi-untethered jailbreak for iOS 15 and 16
C
3,306
star
3

SafariPlus

Tweak for iOS App "Safari" - Various enhancements
Objective-C++
438
star
4

Choicy

Advanced tweak configurator for iOS 10 and up
Objective-C
333
star
5

opa334.github.io

Cydia Repo
HTML
312
star
6

opainject

iOS runtime dylib injection tool
Objective-C
198
star
7

TrollNonce

Boot nonce utility for TrollStore (15.0 - 15.5b4)
Objective-C
176
star
8

sandbox_extension_generator

iOS 15.0 - 15.3.1 sandbox escape technique using kernel read/write primitives
C
122
star
9

CCSupport

Support tweak for CC modules!
Logos
116
star
10

AltList

A modern AppList alternative
Objective-C
103
star
11

u0Launcher

Launches unc0ver in a way that works when it's installed through TrollStore
Objective-C
95
star
12

libSandy

Securely extend the sandbox of system processes and user applications
Objective-C
79
star
13

IGSideloadFix

Fix crash on login when Instagram is installed via sideloading (iOS)
Logos
79
star
14

libroot

Standardized API to get root path on iOS jailbreaks
C
68
star
15

Presentations

66
star
16

xnuspy_syscall_logger

Log all syscalls executed by a process (iOS / checkra1n / xnuspy)
C
57
star
17

libundirect

Patchfinder and rebinder for objc_direct methods
Objective-C
50
star
18

NotRecording

Spoof screen recording detection!
Objective-C
36
star
19

XPF

XNU Patch Finder (based on ChOma)
C
34
star
20

futurerestore-compile-windows

MSYS2 script to compile futurerestore and all of it's dependencies for Windows (dynamically and statically)
Shell
32
star
21

Downloadally

Tweak for iOS App "TikTok" - Adds a download button
Logos
23
star
22

TimeBomb

Spinlock panic with ease!
Logos
23
star
23

powerlogHelperdFix

Block tweak injection into powerlogHelperd, fixes issues on iOS 13
Makefile
20
star
24

WatchdogDisabler

Disables app launch watchdog timeouts
Makefile
20
star
25

FLEXSimject

Open Flex in iOS Simulator (Alt+F)
Logos
19
star
26

CCSupportExamples

Some example modules
Objective-C
18
star
27

CCSupportTemplates

Templates and headers for module development
Objective-C
16
star
28

litehook

Lightweight *OS hooking library with no dependencies except for libsystem
15
star
29

WhitePointModule

Control Center Module to toggle "Reduce White Point" with the ability to change the intensity
Objective-C
13
star
30

ChoicyLoader

Hacky workaround to always load Choicy first
Objective-C
11
star
31

syscallintercept

an attempt to intercept syscalls for iOS applications that is unfinished and works only partially
Logos
11
star
32

NoSubstitute12

Disable Substitute on a per app basis (DEPRECATED, use Choicy)
Logos
10
star
33

Crane-Resources

Objective-C
10
star
34

SliceFixup

Tool to remove unsupported arm64e slice from a dylib based on the iOS version
Objective-C
8
star
35

CCCleaner

Cleaning Tool for Control Center related System Files
Objective-C++
8
star
36

FastSafariPW

1Password / LastPass Shortcut Buttons inside Toolbar
Logos
7
star
37

SaveVideoDialog

Alert to prevent a recorded video from being saved
Logos
4
star
38

TerraSmart

C++
4
star