Top Banner
mike arpaia / facebook OS X Security at Scale ted reed / facebook
40

OS X security at Facebook

Jan 02, 2017

Download

Documents

lenguyet
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OS X security at Facebook

mike arpaia / facebookOS X Security at Scale

ted reed / facebook

Page 2: OS X security at Facebook

OS X security at Facebookproduction hardening

client engineering intrusion detection

Page 3: OS X security at Facebook

“detection” and “response”catch attackers

• insider threats•espionage

•external threats•APT•hacktivists•mass malware• the list is endless

Page 4: OS X security at Facebook

defend enterprise and production infrasingle intrusion detection team

•extract as much signal as possible•make high confidence decisions•harder for the more variable OS X client fleet

•avoid duplication in production•ease burden for humans•apply the same intelligence feeds•reuse storage

Page 5: OS X security at Facebook

mac and linux laptopsfocus on client machines

developerlaptop

Most variable

Largest attack surface

‘Highest’ risk

Page 6: OS X security at Facebook

but it’s a hard problem

“install to win”

network-based IDS host-based IDS

Page 7: OS X security at Facebook

but it’s a hard problem

“install to win”

network-based IDS host-based IDS

your machine is cookedmust be time for a newlaptop

do not install that again

“install and pray”

Page 8: OS X security at Facebook

we live in a windows centric world

•more OS X laptops•most production infrastructure runs on Linux

• few are instrumenting their OS X and Linux hosts•affordably• tailored to medium enterprises or large infrastructures•how would we solve that problem?

but, times are changing

Page 9: OS X security at Facebook

desired properties

Page 10: OS X security at Facebook

performant

easy

flexible

simpledevelopment

deployableupgrades

low maintenance

user impact

long uptimemetrics

configurable

integrations

compliance

automation

vulnerability management

Page 11: OS X security at Facebook

osquery

Page 12: OS X security at Facebook

SQL for your infrastructureosquery

use SQL queries to explore OS state•running processes• loaded kernel modules•active network connections• route table•firewall settings• installed software•file modifications

Page 13: OS X security at Facebook

why SQL?

SELECT pid, name, uid FROM processes

OS concepts are shared on Mac, Linux, and Windows

the “concepts” have attributes:user ids, process ids, descriptors, ports, paths

most developers and administrators know SQL

Page 14: OS X security at Facebook

why SQL?

SELECT pid, name, uid FROM processes[concept]

Page 15: OS X security at Facebook

why SQL?

SELECT pid, name, uid FROM processes[attributes] [concept]

Page 16: OS X security at Facebook

why SQL?

SELECT pid, name, uid FROM processes

[constraints]WHERE uid != 0

Page 17: OS X security at Facebook

why SQL?

JOIN users ON processes.uid=users.uid

SELECT pid, name, username FROM processes

WHERE uid != 0 [join]

[attribute]

Page 18: OS X security at Facebook

more tables are being written every daymany tables are available

•acpi_tables •arp_cache •crontab •file_events •kernel_info •listening_ports •logged_in_users •mounts •pci_devices

•processes •routes •shell_history •smbios_tables •suid_bin •system_controls •usb_devices •users •groups

•rpm_packages •apt_sources •deb_packages •homebrew_packages •kernel_modules •memory_map •shared_memory •browser_plugins •startup_items

Page 19: OS X security at Facebook

use simple tables, togetherosquery enables complex analysis by allowing users to join and aggregate across several simple tables•simple tables have many advantages•easier to write•easier to maintain•can be used in many contexts

Page 20: OS X security at Facebook

osquery is much more than a security tool

Page 21: OS X security at Facebook

osquery is much more than a security tool

actually, literally…

it is a family of tools

Page 22: OS X security at Facebook

osqueryi

Page 23: OS X security at Facebook
Page 24: OS X security at Facebook

LaunchDaemons which run a binary at boot

Page 25: OS X security at Facebook

running processes

Page 26: OS X security at Facebook

processes listening on ports

Page 27: OS X security at Facebook

osqueryd

Page 28: OS X security at Facebook

daemon for low-level host monitoringosqueryd

know how the results of a query change over time •schedule a query on your hosts via a config

• the daemon takes care of periodically executing your queries•buffers results to disk and generates a log of state changes• logs results for aggregation and analytics

Page 29: OS X security at Facebook

event-based operating system introspectionhost eventing stream

subscribe to key OS events to create dynamically growing tables•subscribe to “publishers”•filesystem changes (inotify, FSEvents)•network setting changes (SCNetwork)•application usages (NSNotificationCenter)

•query the history of your host, as it evolves

Page 30: OS X security at Facebook

for config distribution, data infrastructure and moreplugin system

•simple plugin API•specify your plugins at runtime with a command-line flag

filesystem

http

zookeeper

configuration

filesystem

flume

scribe

logging

tls

ldap

oauth

enrollment

Page 31: OS X security at Facebook

how we config and log results facebook workflow

1. osquery.pkg published automatically to https://osquery.io2. download weekly and update chef cookbook3. chef writes configuration and installs pkg

1. newsyslog.d rotation file2. list of scheduled queries

4. results written to /var/log/osqueryd.results.log5. splunk lightweight forwarder6. backend analytics

Page 32: OS X security at Facebook

tables

Page 33: OS X security at Facebook

creating tables is easy

easily define what your tables “look like” in Python and use C++ to implement what a full-table scan would return• the Python is used to generate faster C++ code transparently•you write a single C++ function which implements a full-table scan

Page 34: OS X security at Facebook

table_name("time") schema([ Column("hour", INTEGER), Column("minutes", INTEGER), Column("seconds",INTEGER), ]) implementation("time@genTime")

Page 35: OS X security at Facebook

namespace osquery { namespace tables {

QueryData genTime(QueryContext& ctx) { QueryData results; struct tm* now = localtime(time(0));

Row r; r["hour"] = INTEGER(now->tm_hour); r["minutes"] = INTEGER(now->tm_min); r["seconds"] = INTEGER(now->tm_sec); results.push_back(r);

return results; } } }

Page 36: OS X security at Facebook

https://osquery.io/tablesbrowse all tables, columns, descriptions, and example queries

Page 37: OS X security at Facebook

open source

Page 38: OS X security at Facebook

all development happens in the open, on GitHubwork on osquery with us

the problem that osquery solves isn't unique to facebook•https://github.com/facebook/osquery•https://osquery.io•https://osquery.readthedocs.org

this journey is 1% finished: get involved•we’re excited to take on future challenges in the open• let’s build together

Page 39: OS X security at Facebook
Page 40: OS X security at Facebook

questions

https://osquery.io