• Stars
    star
    181
  • Rank 205,112 (Top 5 %)
  • Language
    C
  • License
    MIT License
  • Created 7 months ago
  • Updated 2 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
15,417
star
2

Dopamine

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

SafariPlus

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

opa334.github.io

Cydia Repo
HTML
280
star
5

Choicy

Advanced tweak configurator for iOS 10 and up
Objective-C
268
star
6

TrollNonce

Boot nonce utility for TrollStore (15.0 - 15.5b4)
Objective-C
175
star
7

opainject

iOS runtime dylib injection tool
Objective-C
130
star
8

sandbox_extension_generator

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

CCSupport

Support tweak for CC modules!
Logos
104
star
10

u0Launcher

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

AltList

A modern AppList alternative
Objective-C
77
star
12

IGSideloadFix

Fix crash on login when Instagram is installed via sideloading (iOS)
Logos
74
star
13

libSandy

Securely extend the sandbox of system processes and user applications
Objective-C
70
star
14

xnuspy_syscall_logger

Log all syscalls executed by a process (iOS / checkra1n / xnuspy)
C
53
star
15

libundirect

Patchfinder and rebinder for objc_direct methods
Objective-C
49
star
16

libroot

Standardized API to get root path on iOS jailbreaks
C
38
star
17

Presentations

30
star
18

NotRecording

Spoof screen recording detection!
Objective-C
29
star
19

futurerestore-compile-windows

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

Downloadally

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

TimeBomb

Spinlock panic with ease!
Logos
22
star
22

powerlogHelperdFix

Block tweak injection into powerlogHelperd, fixes issues on iOS 13
Makefile
19
star
23

FLEXSimject

Open Flex in iOS Simulator (Alt+F)
Logos
18
star
24

CCSupportTemplates

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

CCSupportExamples

Some example modules
Objective-C
15
star
26

XPF

XNU Patch Finder (based on ChOma)
C
15
star
27

WatchdogDisabler

Disables app launch watchdog timeouts
Makefile
13
star
28

WhitePointModule

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

ChoicyLoader

Hacky workaround to always load Choicy first
Objective-C
10
star
30

NoSubstitute12

Disable Substitute on a per app basis (DEPRECATED, use Choicy)
Logos
9
star
31

syscallintercept

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

SliceFixup

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

Crane-Resources

Objective-C
7
star
34

CCCleaner

Cleaning Tool for Control Center related System Files
Objective-C++
6
star
35

FastSafariPW

1Password / LastPass Shortcut Buttons inside Toolbar
Logos
6
star
36

SaveVideoDialog

Alert to prevent a recorded video from being saved
Logos
3
star
37

TerraSmart

C++
2
star