SlideShare a Scribd company logo
Escaping)the
Mac$App$Sandbox
(or$at$least$a$small$part$of$it)
Ma#$Welch
Developer(working(on(iOS,(Mac,(and(node(
apps(by(night,(and(on(the(Force.com(
pla=orm(by(day.
ma#@welcher.net
@_Ma#Welch_
h#p://ma#wel.ch
Bearings
What%is%the%Mac%App%Sandbox?
App#Sandbox!is!an!access!control!technology!provided!in!OS!X,!
enforced!at!the!kernel!level.!Its!strategy!is!twofold:
• App$Sandbox$enables$you$to$describe$how$your$app$interacts$
with$the$system.$The$system$then$grants$your$app$the$access$it$
needs$to$get$its$job$done,$and$no$more.
• App$Sandbox$allows$the$user$to$transparently$grant$your$app$
addi=onal$access$by$way$of$Open$and$Save$dialogs,$drag$and$
drop,$and$other$familiar$user$interac=ons.
(From&the&Apple&"App&Sandbox&Design&Guide")
Sandbox(Filesystem(Limita2ons
Specifically,+sandboxing+limits+an+app+to+only+those+files+or+
directories+explicitly+opened+by+the+user.
For$most$cases$this$is$OK.$(In$fact,$Deckset$here$regularly$asks$
permission$to$access$a$photo$I$want$to$use$that's$on$my$filesystem.)
Temporary)Files
The$problem$is$that$temporary$files$are$
supposed$to$be$invisible$to$the$end$user.
What%kind%of%experience%would%this%be?
Now$mul(ply$this$bad$experience$by$10.$
Or$100.$Or$however$many$hundreds$of$
photos$(in$the$case$of$Bearings$app)$that$
need$to$be$processed.
Workaround:*File*Presenters
File%Presenters?
Yes,%File%Presenters.
• Around(since(10.7,(File(Presenters((and(their("parents"(File(
Coordinators)(have(made(working(with(the(file(system(in(a(mulDE
threaded,(mulDEprocessing(environment(easier(and(safer.
Yes,%File%Presenters.
• Around(since(10.7,(File(Presenters((and(their("parents"(File(
Coordinators)(have(made(working(with(the(file(system(in(a(mulDE
threaded,(mulDEprocessing(environment(easier(and(safer.
Yes,%File%Presenters.
• Around(since(10.7,(File(Presenters((and(their("parents"(File(
Coordinators)(have(made(working(with(the(file(system(in(a(mulDE
threaded,(mulDEprocessing(environment(easier(and(safer.
Yes,%File%Presenters.
• Around(since(10.7,(File(Presenters((and(their("parents"(File(
Coordinators)(have(made(working(with(the(file(system(in(a(mulDE
threaded,(mulDEprocessing(environment(easier(and(safer.
Yes,%File%Presenters.
• Around(since(10.7,(File(Presenters((and(their("parents"(File(
Coordinators)(have(made(working(with(the(file(system(in(a(mulDE
threaded,(mulDEprocessing(environment(easier(and(safer.
Implemen'ng)File)Presenters)for)Related)
Items
Apple%has%repurposed%File%Presenters%to%enable%"Related%Items"%in%
sandboxed%apps.
Related'Items
• Must&have&the&same&name&(minus&extension)&as&the&item&to&
which&they&are&related
• Must&have&a&known9ahead9of9;me&extension
Implemen'ng)File)Presenters)for)Related)
Items
Create&a&class&that&conforms&the&the&NSFilePresenter&protocol.&
Implement&these&methods:
1. primaryPresentedItemURL#–#The#URL#for#the#original#file
2. primaryItemURL#–#the#URL#for#the#temporary#file#(the#same#as#
above,#but#with#different#extension)
3. presentedItemOperationQueue#–#the#queue#on#which#the#
app#will#perform#file#presentaGon#tasks
WRFilePresenter
// WRFilePresenter.m
// Bearings
//
// Created by Matt Welch on 3/17/14.
//
#import "WRFilePresenter.h"
@implementation WRFilePresenter
{
NSOperationQueue* queue;
NSURL* pFileURL;
NSURL* tFileURL;
}
- (id) init {
self = [super init];
if (self) {
queue = [NSOperationQueue new];
[NSFileCoordinator addFilePresenter:self];
}
return self;
}
- (NSURL*) primaryPresentedItemURL {
return pFileURL;
}
- (NSURL *) presentedItemURL {
return tFileURL;
}
- (NSOperationQueue*) presentedItemOperationQueue {
return queue;
}
-(void) setURLs:(NSURL*)url {
pFileURL=url;
NSString *fURLS=[url absoluteString];
NSString *fURLSt=[NSString stringWithFormat:@"%@%@",fURLS,@"_temp_file_extension" ];
NSURL *surl = [NSURL URLWithString:fURLSt];
tFileURL=surl;
}
@end
Implemen'ng)File)Presenters
Given&a&file&with&a&url&of&realFileURL,&implement&a&presenter&for&
it:
WRFilePresenter *filePresenter=[[WRFilePresenter alloc] init];
[filePresenter setURLs:realFileURL];
And$we're$all$set$(at$least$as$far$as$code$is$concerned).
XCode&Target&Setup
In#the#Project#Navigator,#under#the#"Info"#tab,#there#is#a#
"Documents#Type"#sec=on.
• Set%"Extension"%to%be%the%known%temporary%file%extension.
• Add%NSIsRelatedItemType%of%type%Boolean%to%"Addi<onal%
document%type%proper<es"%and%set%it%to%YES
XCode&Target&Setup
Demo
Further'Informa.on
More%in(depth%informa0on%can%be%found%at:
h5p://ma5wel.ch/temporary(files(in(sandboxed(mac(apps/
This%presenta,on%is%on%github:
h2ps://github.com/ma2welch/mac_sandbox_tempfiles_deckset
A"ribu'ons
• happiness)from)a)sandbox)1)h2ps://www.flickr.com/photos/
celinesphotographer/326629023/
• App)Sandbox)Design)Guide)1)h2ps://developer.apple.com/
library/mac/documentaIon/Security/Conceptual/
AppSandboxDesignGuide/AboutAppSandbox/
AboutAppSandbox.html
• Paperama)1)h2ps://www.flickr.com/photos/kasaa/3103799093/

More Related Content

PDF
Pimp your data
PPTX
Amazon alexa
DOC
Reconocmientos de aprendizajes previos 1
PDF
Cocoaheads Stockholm 2014-02: Writing your own jailbreak tweak
PDF
OS X Malware: Let's Play Doctor
PDF
The Future Of Responsive Design Standards (Den Odell)
PDF
The Future Of Responsive Design Standards
PDF
Elixir on Containers
Pimp your data
Amazon alexa
Reconocmientos de aprendizajes previos 1
Cocoaheads Stockholm 2014-02: Writing your own jailbreak tweak
OS X Malware: Let's Play Doctor
The Future Of Responsive Design Standards (Den Odell)
The Future Of Responsive Design Standards
Elixir on Containers

Similar to Escaping the Mac App Store Sandbox (or at least a small part of it) (20)

PDF
Black Hat '15: Writing Bad @$$ Malware for OS X
PDF
RSA OSX Malware
PDF
Hexagonal architecture - message-oriented software design
PDF
Revoke-Obfuscation
PDF
Dynamic Adaptive Streaming over HTTP: From Content Creation to Consumption
PDF
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
PPTX
Building Mobile Apps with Visual Studio Tools for Apache Cordova
PDF
Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)
PDF
Be a microservices hero
PDF
Learn C Programming Language by Using GDB
PDF
Ready Layer One: Intro to the Model Context Protocol
PDF
Úvod do programování 7
PPTX
Bug Bounty for - Beginners
PDF
ContainerCon 2015 - Be a Microservices Hero
PDF
Advanced Mac Software Deployment and Configuration: Just Make It Work!
PDF
Defcon 22-colby-moore-patrick-wardle-synack-drop cam
PDF
Maxim Salnikov - Service Worker: taking the best from the past experience for...
PDF
Burn down the silos! Helping dev and ops gel on high availability websites
PPTX
20160225 OWASP Atlanta Prevoty RASP
KEY
Device deployment
Black Hat '15: Writing Bad @$$ Malware for OS X
RSA OSX Malware
Hexagonal architecture - message-oriented software design
Revoke-Obfuscation
Dynamic Adaptive Streaming over HTTP: From Content Creation to Consumption
DEF CON 27 - PATRICK WARDLE - harnessing weapons of Mac destruction
Building Mobile Apps with Visual Studio Tools for Apache Cordova
Climbing out from the digital mud with unikernels / Ian Eyberg (DeferPanic)
Be a microservices hero
Learn C Programming Language by Using GDB
Ready Layer One: Intro to the Model Context Protocol
Úvod do programování 7
Bug Bounty for - Beginners
ContainerCon 2015 - Be a Microservices Hero
Advanced Mac Software Deployment and Configuration: Just Make It Work!
Defcon 22-colby-moore-patrick-wardle-synack-drop cam
Maxim Salnikov - Service Worker: taking the best from the past experience for...
Burn down the silos! Helping dev and ops gel on high availability websites
20160225 OWASP Atlanta Prevoty RASP
Device deployment
Ad

Recently uploaded (20)

PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PPTX
assetexplorer- product-overview - presentation
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
Autodesk AutoCAD Crack Free Download 2025
PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PPTX
Tech Workshop Escape Room Tech Workshop
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
Introduction to Windows Operating System
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
How Tridens DevSecOps Ensures Compliance, Security, and Agility
assetexplorer- product-overview - presentation
Weekly report ppt - harsh dattuprasad patel.pptx
Autodesk AutoCAD Crack Free Download 2025
GSA Content Generator Crack (2025 Latest)
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Why Generative AI is the Future of Content, Code & Creativity?
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Tech Workshop Escape Room Tech Workshop
Wondershare Recoverit Full Crack New Version (Latest 2025)
Computer Software and OS of computer science of grade 11.pptx
Monitoring Stack: Grafana, Loki & Promtail
Introduction to Windows Operating System
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Ad

Escaping the Mac App Store Sandbox (or at least a small part of it)