Code Monkey home page Code Monkey logo

osx-sandbox--seatbelt--profiles's Introduction

Seatbelt Profiles

Description

This is a fork of a collection of profiles for the OSX Application Sandbox called Seatbelt. For some background information on how this whole thing works, check out Dion Blazakis's Blackhat Talk. Some guy also recently did "Buckle Up" which may help some. The original author's hopes were that people will start to make their own by maybe forking the original repository and adding new rules and profiles to it, and then committing back to it with pull-requests.

Basic Usage

To get things rolling immediately you should just be able to run the corresponding shell scripts. The original author has taken care to make them portable. Dropping to a terminal (for example) and running: ./safari.sh should fire up a "fresh" Safari. To learn more about the sandbox profile syntax you can't easily google for them. You can however learn a bit by looking at the ones that ship with OS X by default by dropping to a terminal and looking in /usr/share/sandbox, /System/Library/Sandbox/Profiles, or /Library/Sandbox/Profiles, or System/Library/Sandbox/Profiles:

 stephens-computer:sandbox_profiles s7$ cd /usr/share/sandbox/
 stephens-computer:sandbox s7$ ls
 awacsd.sb                    mds.sb                       sshd.sb
 bsd.sb                       mdworker.sb                  syslogd.sb
 cvmsCompAgent.sb             named.sb                     xgridagentd.sb
 cvmsServer.sb                ntpd.sb                      xgridagentd_task_nobody.sb
 fontmover.sb                 portmap.sb                   xgridagentd_task_somebody.sb
 kadmind.sb                   preview.sb                   xgridcontrollerd.sb
 krb5kdc.sb                   quicklookd-job-creation.sb
 mDNSResponder.sb             quicklookd.sb

You can also glean a bit more by checking the manpages for sandbox-exec(1), sandbox_init(3), sandbox(7), and sandboxd(8).

Writing Sandbox Profiles The Easy Way (from "Buckle Up")

Use the example.sb sandbox file that contains in particular the line

(trace "profile.sb")

This instructs sandbox-exec to output a profile.sb file that will contain the raw output of what resources are being accessed during the runtime of the target application.

You would therefore start the application with:

sandbox-exec -f example.sb /Path/To/The/Application/

Then run sandbox-simplify on the profile.sb and pipe it to another file:

sandbox-simplify profile.sb > simplified.sb

You can then start editing that simplified file to see what makes sense to keep, what can be compacted more and what should be changed.

A useful vi macro to keep handly is this:

%s/literal "\/Users\/replace_with_your_username/regex #"^\/Users\/[^\.]+/gc

This basically makes your profile work for people that don't have your same username.

Writing Sandbox Profiles the Boring way

You want to start from a basic sandbox profile that contains the bare minimum necessary to start the application. Something along the lines of this is a good starting point:

(version 1)
(debug allow)
(allow process*)
(deny default)

What this does it it allow processes to run and it is a whitelist based profile (i.e. the default policy is to not allow).

The next thing that you want to do is start

tail -f /var/log/system.log

All the denied by policy lines will end up in that file. Then start your application with your sandbox profile:

sandbox-exec -f <sandbox_file>.sb /path/to/the/app

You will then see in the tail -f terminal lines containing something like:

Dec 22 14:58:08 x sandboxd[12281] ([12280]): firefox-bin(12280) deny file-read-data /private/tmp

This is saying, for example, that firefox was denied "file-read-data" access to the file in /private/tmp. You should then evaluate if you want to allow that or not and in the first case add the entry that allows that in your sandbox file, like so:

(file-read-data
    (regex "^/private/tmp")
)

Continue iteratively until you reach a point where your application runs properly and all the error messages are thing you don't want to happen.

Safe hacking and remember to fasten your seatbelt :)

Resources

osx-sandbox--seatbelt--profiles's People

Contributors

s7ephen avatar cooljeanius avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.