|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876 |
- <!doctype html><!-- This is a valid HTML5 document. -->
- <!-- Screen readers, SEO, extensions and so on. -->
- <html lang=fr>
- <!-- Has to be within the first 1024 bytes, hence before the <title>
- See: https://www.w3.org/TR/2012/CR-html5-20121217/document-metadata.html#charset -->
- <meta charset=utf-8>
- <!-- Why no `X-UA-Compatible` meta: https://stackoverflow.com/a/6771584 -->
- <!-- The viewport meta is quite crowded and we are responsible for that.
- See: https://codepen.io/tigt/post/meta-viewport-for-2015 -->
- <meta name=viewport content="width=device-width,minimum-scale=1,initial-scale=1,shrink-to-fit=no">
- <!-- Required to make a valid HTML5 document. -->
- <title>A practical guide to securing macOS. (archive) — David Larlet</title>
- <!-- Generated from https://realfavicongenerator.net/ such a mess. -->
- <link rel="apple-touch-icon" sizes="180x180" href="/static/david/icons/apple-touch-icon.png">
- <link rel="icon" type="image/png" sizes="32x32" href="/static/david/icons/favicon-32x32.png">
- <link rel="icon" type="image/png" sizes="16x16" href="/static/david/icons/favicon-16x16.png">
- <link rel="manifest" href="/manifest.json">
- <link rel="mask-icon" href="/static/david/icons/safari-pinned-tab.svg" color="#5bbad5">
- <link rel="shortcut icon" href="/static/david/icons/favicon.ico">
- <meta name="apple-mobile-web-app-title" content="David Larlet">
- <meta name="application-name" content="David Larlet">
- <meta name="msapplication-TileColor" content="#da532c">
- <meta name="msapplication-config" content="/static/david/icons/browserconfig.xml">
- <meta name="theme-color" content="#f0f0ea">
- <!-- That good ol' feed, subscribe :p. -->
- <link rel=alternate type="application/atom+xml" title=Feed href="/david/log/">
-
- <meta name="robots" content="noindex, nofollow">
- <meta content="origin-when-cross-origin" name="referrer">
- <!-- Canonical URL for SEO purposes -->
- <link rel="canonical" href="https://github.com/drduh/macOS-Security-and-Privacy-Guide">
-
- <style>
- /* http://meyerweb.com/eric/tools/css/reset/ */
- html, body, div, span,
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
- a, abbr, address, big, cite, code,
- del, dfn, em, img, ins,
- small, strike, strong, tt, var,
- dl, dt, dd, ol, ul, li,
- fieldset, form, label, legend,
- table, caption, tbody, tfoot, thead, tr, th, td,
- article, aside, canvas, details, embed,
- figure, figcaption, footer, header, hgroup,
- menu, nav, output, ruby, section, summary,
- time, mark, audio, video {
- margin: 0;
- padding: 0;
- border: 0;
- font-size: 100%;
- font: inherit;
- vertical-align: baseline;
- }
- /* HTML5 display-role reset for older browsers */
- article, aside, details, figcaption, figure,
- footer, header, hgroup, menu, nav, section { display: block; }
- body { line-height: 1; }
- blockquote, q { quotes: none; }
- blockquote:before, blockquote:after,
- q:before, q:after {
- content: '';
- content: none;
- }
- table {
- border-collapse: collapse;
- border-spacing: 0;
- }
-
- /* http://practicaltypography.com/equity.html */
- /* https://calendar.perfplanet.com/2016/no-font-face-bulletproof-syntax/ */
- /* https://www.filamentgroup.com/lab/js-web-fonts.html */
- @font-face {
- font-family: 'EquityTextB';
- src: url('/static/david/css/fonts/Equity-Text-B-Regular-webfont.woff2') format('woff2'),
- url('/static/david/css/fonts/Equity-Text-B-Regular-webfont.woff') format('woff');
- font-weight: 300;
- font-style: normal;
- font-display: swap;
- }
- @font-face {
- font-family: 'EquityTextB';
- src: url('/static/david/css/fonts/Equity-Text-B-Italic-webfont.woff2') format('woff2'),
- url('/static/david/css/fonts/Equity-Text-B-Italic-webfont.woff') format('woff');
- font-weight: 300;
- font-style: italic;
- font-display: swap;
- }
- @font-face {
- font-family: 'EquityTextB';
- src: url('/static/david/css/fonts/Equity-Text-B-Bold-webfont.woff2') format('woff2'),
- url('/static/david/css/fonts/Equity-Text-B-Bold-webfont.woff') format('woff');
- font-weight: 700;
- font-style: normal;
- font-display: swap;
- }
-
- @font-face {
- font-family: 'ConcourseT3';
- src: url('/static/david/css/fonts/concourse_t3_regular-webfont-20190806.woff2') format('woff2'),
- url('/static/david/css/fonts/concourse_t3_regular-webfont-20190806.woff') format('woff');
- font-weight: 300;
- font-style: normal;
- font-display: swap;
- }
-
-
- /* http://practice.typekit.com/lesson/caring-about-opentype-features/ */
- body {
- /* http://www.cssfontstack.com/ Palatino 99% Win 86% Mac */
- font-family: "EquityTextB", Palatino, serif;
- background-color: #f0f0ea;
- color: #07486c;
- font-kerning: normal;
- -moz-osx-font-smoothing: grayscale;
- -webkit-font-smoothing: subpixel-antialiased;
- text-rendering: optimizeLegibility;
- font-variant-ligatures: common-ligatures contextual;
- font-feature-settings: "kern", "liga", "clig", "calt";
- }
- pre, code, kbd, samp, var, tt {
- font-family: 'TriplicateT4c', monospace;
- }
- em {
- font-style: italic;
- color: #323a45;
- }
- strong {
- font-weight: bold;
- color: black;
- }
- nav {
- background-color: #323a45;
- color: #f0f0ea;
- display: flex;
- justify-content: space-around;
- padding: 1rem .5rem;
- }
- nav:last-child {
- border-bottom: 1vh solid #2d7474;
- }
- nav a {
- color: #f0f0ea;
- }
- nav abbr {
- border-bottom: 1px dotted white;
- }
-
- h1 {
- border-top: 1vh solid #2d7474;
- border-bottom: .2vh dotted #2d7474;
- background-color: #e3e1e1;
- color: #323a45;
- text-align: center;
- padding: 5rem 0 4rem 0;
- width: 100%;
- font-family: 'ConcourseT3';
- display: flex;
- flex-direction: column;
- }
- h1.single {
- padding-bottom: 10rem;
- }
- h1 span {
- position: absolute;
- top: 1vh;
- left: 20%;
- line-height: 0;
- }
- h1 span a {
- line-height: 1.7;
- padding: 1rem 1.2rem .6rem 1.2rem;
- border-radius: 0 0 6% 6%;
- background: #2d7474;
- font-size: 1.3rem;
- color: white;
- text-decoration: none;
- }
- h2 {
- margin: 4rem 0 1rem;
- border-top: .2vh solid #2d7474;
- padding-top: 1vh;
- }
- h3 {
- text-align: center;
- margin: 3rem 0 .75em;
- }
- hr {
- height: .4rem;
- width: .4rem;
- border-radius: .4rem;
- background: #07486c;
- margin: 2.5rem auto;
- }
- time {
- display: bloc;
- margin-left: 0 !important;
- }
- ul, ol {
- margin: 2rem;
- }
- ul {
- list-style-type: square;
- }
- a {
- text-decoration-skip-ink: auto;
- text-decoration-thickness: 0.05em;
- text-underline-offset: 0.09em;
- }
- article {
- max-width: 50rem;
- display: flex;
- flex-direction: column;
- margin: 2rem auto;
- }
- article.single {
- border-top: .2vh dotted #2d7474;
- margin: -6rem auto 1rem auto;
- background: #f0f0ea;
- padding: 2rem;
- }
- article p:last-child {
- margin-bottom: 1rem;
- }
- p {
- padding: 0 .5rem;
- margin-left: 3rem;
- }
- p + p,
- figure + p {
- margin-top: 2rem;
- }
-
- blockquote {
- background-color: #e3e1e1;
- border-left: .5vw solid #2d7474;
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 1rem;
- margin: 1.5rem;
- }
- blockquote cite {
- font-style: italic;
- }
- blockquote p {
- margin-left: 0;
- }
-
- figure {
- border-top: .2vh solid #2d7474;
- background-color: #e3e1e1;
- text-align: center;
- padding: 1.5rem 0;
- margin: 1rem 0 0;
- font-size: 1.5rem;
- width: 100%;
- }
- figure img {
- max-width: 250px;
- max-height: 250px;
- border: .5vw solid #323a45;
- padding: 1px;
- }
- figcaption {
- padding: 1rem;
- line-height: 1.4;
- }
- aside {
- display: flex;
- flex-direction: column;
- background-color: #e3e1e1;
- padding: 1rem 0;
- border-bottom: .2vh solid #07486c;
- }
- aside p {
- max-width: 50rem;
- margin: 0 auto;
- }
-
- /* https://fvsch.com/code/css-locks/ */
- p, li, pre, code, kbd, samp, var, tt, time, details, figcaption {
- font-size: 1rem;
- line-height: calc( 1.5em + 0.2 * 1rem );
- }
- h1 {
- font-size: 1.9rem;
- line-height: calc( 1.2em + 0.2 * 1rem );
- }
- h2 {
- font-size: 1.6rem;
- line-height: calc( 1.3em + 0.2 * 1rem );
- }
- h3 {
- font-size: 1.35rem;
- line-height: calc( 1.4em + 0.2 * 1rem );
- }
- @media (min-width: 20em) {
- /* The (100vw - 20rem) / (50 - 20) part
- resolves to 0-1rem, depending on the
- viewport width (between 20em and 50em). */
- p, li, pre, code, kbd, samp, var, tt, time, details, figcaption {
- font-size: calc( 1rem + .6 * (100vw - 20rem) / (50 - 20) );
- line-height: calc( 1.5em + 0.2 * (100vw - 50rem) / (20 - 50) );
- margin-left: 0;
- }
- h1 {
- font-size: calc( 1.9rem + 1.5 * (100vw - 20rem) / (50 - 20) );
- line-height: calc( 1.2em + 0.2 * (100vw - 50rem) / (20 - 50) );
- }
- h2 {
- font-size: calc( 1.5rem + 1.5 * (100vw - 20rem) / (50 - 20) );
- line-height: calc( 1.3em + 0.2 * (100vw - 50rem) / (20 - 50) );
- }
- h3 {
- font-size: calc( 1.35rem + 1.5 * (100vw - 20rem) / (50 - 20) );
- line-height: calc( 1.4em + 0.2 * (100vw - 50rem) / (20 - 50) );
- }
- }
- @media (min-width: 50em) {
- /* The right part of the addition *must* be a
- rem value. In this example we *could* change
- the whole declaration to font-size:2.5rem,
- but if our baseline value was not expressed
- in rem we would have to use calc. */
- p, li, pre, code, kbd, samp, var, tt, time, details, figcaption {
- font-size: calc( 1rem + .6 * 1rem );
- line-height: 1.5em;
- }
- p, li, pre, details {
- margin-left: 3rem;
- }
- h1 {
- font-size: calc( 1.9rem + 1.5 * 1rem );
- line-height: 1.2em;
- }
- h2 {
- font-size: calc( 1.5rem + 1.5 * 1rem );
- line-height: 1.3em;
- }
- h3 {
- font-size: calc( 1.35rem + 1.5 * 1rem );
- line-height: 1.4em;
- }
- figure img {
- max-width: 500px;
- max-height: 500px;
- }
- }
-
- figure.unsquared {
- margin-bottom: 1.5rem;
- }
- figure.unsquared img {
- height: inherit;
- }
-
-
-
- @media print {
- body { font-size: 100%; }
- a:after { content: " (" attr(href) ")"; }
- a, a:link, a:visited, a:after {
- text-decoration: underline;
- text-shadow: none !important;
- background-image: none !important;
- background: white;
- color: black;
- }
- abbr[title] { border-bottom: 0; }
- abbr[title]:after { content: " (" attr(title) ")"; }
- img { page-break-inside: avoid; }
- @page { margin: 2cm .5cm; }
- h1, h2, h3 { page-break-after: avoid; }
- p3 { orphans: 3; widows: 3; }
- img {
- max-width: 250px !important;
- max-height: 250px !important;
- }
- nav, aside { display: none; }
- }
-
- ul.with_columns {
- column-count: 1;
- }
- @media (min-width: 20em) {
- ul.with_columns {
- column-count: 2;
- }
- }
- @media (min-width: 50em) {
- ul.with_columns {
- column-count: 3;
- }
- }
- ul.with_two_columns {
- column-count: 1;
- }
- @media (min-width: 20em) {
- ul.with_two_columns {
- column-count: 1;
- }
- }
- @media (min-width: 50em) {
- ul.with_two_columns {
- column-count: 2;
- }
- }
-
- .gallery {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-around;
- }
- .gallery figure img {
- margin-left: 1rem;
- margin-right: 1rem;
- }
- .gallery figure figcaption {
- font-family: 'ConcourseT3'
- }
-
- footer {
- font-family: 'ConcourseT3';
- display: flex;
- flex-direction: column;
- border-top: 3px solid white;
- padding: 4rem 0;
- background-color: #07486c;
- color: white;
- }
- footer > * {
- max-width: 50rem;
- margin: 0 auto;
- }
- footer a {
- color: #f1c40f;
- }
- footer .avatar {
- width: 200px;
- height: 200px;
- border-radius: 50%;
- float: left;
- -webkit-shape-outside: circle();
- shape-outside: circle();
- margin-right: 2rem;
- padding: 2px 5px 5px 2px;
- background: white;
- border-left: 1px solid #f1c40f;
- border-top: 1px solid #f1c40f;
- border-right: 5px solid #f1c40f;
- border-bottom: 5px solid #f1c40f;
- }
- </style>
-
- <h1>
- <span><a id="jumper" href="#jumpto" title="Un peu perdu ?">?</a></span>
- A practical guide to securing macOS. (archive)
- <time>Pour la pérennité des contenus liés. Non-indexé, retrait sur simple email.</time>
- </h1>
- <section>
- <article>
- <h3><a href="https://github.com/drduh/macOS-Security-and-Privacy-Guide">Source originale du contenu</a></h3>
- <p>This is a collection of thoughts on securing a modern Apple Mac computer using macOS (formerly <em>OS X</em>) 10.12 "Sierra", as well as steps to improving online privacy.</p>
- <p>This guide is targeted to “power users” who wish to adopt enterprise-standard security, but is also suitable for novice users with an interest in improving their privacy and security on a Mac.</p>
- <p>A system is only as secure as its administrator is capable of making it. There is no one single technology, software, nor technique to guarantee perfect computer security; a modern operating system and computer is very complex, and requires numerous incremental changes to meaningfully improve one's security and privacy posture.</p>
- <p>I am <strong>not</strong> responsible if you break a Mac by following any of these steps.</p>
- <p>If you wish to make a correction or improvement, please send a pull request or <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues">open an issue</a>.</p>
- <ul>
- <li><a href="#basics">Basics</a></li>
- <li><a href="#firmware">Firmware</a></li>
- <li><a href="#preparing-and-installing-macos">Preparing and Installing macOS</a><ul>
- <li><a href="#virtualization">Virtualization</a></li>
- </ul>
- </li>
- <li><a href="#first-boot">First boot</a></li>
- <li><a href="#admin-and-standard-user-accounts">Admin and standard user accounts</a></li>
- <li><a href="#full-disk-encryption">Full disk encryption</a></li>
- <li><a href="#firewall">Firewall</a><ul>
- <li><a href="#application-layer-firewall">Application layer firewall</a></li>
- <li><a href="#third-party-firewalls">Third party firewalls</a></li>
- <li><a href="#kernel-level-packet-filtering">Kernel level packet filtering</a></li>
- </ul>
- </li>
- <li><a href="#services">Services</a></li>
- <li><a href="#spotlight-suggestions">Spotlight Suggestions</a></li>
- <li><a href="#homebrew">Homebrew</a></li>
- <li><a href="#dns">DNS</a><ul>
- <li><a href="#hosts-file">Hosts file</a></li>
- <li><a href="#dnsmasq">Dnsmasq</a></li>
- <li><a href="#test-dnssec-validation">Test DNSSEC validation</a></li>
- <li><a href="#dnscrypt">DNSCrypt</a></li>
- </ul>
- </li>
- <li><a href="#captive-portal">Captive portal</a></li>
- <li><a href="#certificate-authorities">Certificate authorities</a></li>
- <li><a href="#openssl">OpenSSL</a></li>
- <li><a href="#curl">Curl</a></li>
- <li><a href="#web">Web</a><ul>
- <li><a href="#privoxy">Privoxy</a></li>
- <li><a href="#browser">Browser</a></li>
- <li><a href="#plugins">Plugins</a></li>
- </ul>
- </li>
- <li><a href="#pgpgpg">PGP/GPG</a></li>
- <li><a href="#otr">OTR</a></li>
- <li><a href="#tor">Tor</a></li>
- <li><a href="#vpn">VPN</a></li>
- <li><a href="#viruses-and-malware">Viruses and malware</a></li>
- <li><a href="#system-integrity-protection">System Integrity Protection</a></li>
- <li><a href="#gatekeeper-and-xprotect">Gatekeeper and XProtect</a></li>
- <li><a href="#passwords">Passwords</a></li>
- <li><a href="#backup">Backup</a></li>
- <li><a href="#wi-fi">Wi-Fi</a></li>
- <li><a href="#ssh">SSH</a></li>
- <li><a href="#physical-access">Physical access</a></li>
- <li><a href="#system-monitoring">System monitoring</a><ul>
- <li><a href="#openbsm-audit">OpenBSM audit</a></li>
- <li><a href="#dtrace">DTrace</a></li>
- <li><a href="#execution">Execution</a></li>
- <li><a href="#network">Network</a></li>
- </ul>
- </li>
- <li><a href="#binary-whitelisting">Binary Whitelisting</a></li>
- <li><a href="#miscellaneous">Miscellaneous</a></li>
- <li><a href="#related-software">Related software</a></li>
- <li><a href="#additional-resources">Additional resources</a></li>
- </ul>
- <h2>Basics</h2>
- <p>The standard best security practices apply:</p>
- <ul>
- <li>
- <p>Create a threat model</p>
- <ul>
- <li>What are you trying to protect and from whom? Is your adversary a <a href="https://theintercept.com/document/2015/03/10/strawhorse-attacking-macos-ios-software-development-kit/">three letter agency</a> (if so, you may want to consider using <a href="http://www.openbsd.org/">OpenBSD</a> instead), a nosy eavesdropper on the network, or determined <a href="https://en.wikipedia.org/wiki/Advanced_persistent_threat">apt</a> orchestrating a campaign against you?</li>
- <li>Study and <a href="https://www.usenix.org/system/files/1401_08-12_mickens.pdf">recognize threats</a> and how to reduce attack surface against them.</li>
- </ul>
- </li>
- <li>
- <p>Keep the system up to date</p>
- <ul>
- <li>Patch, patch, patch your system and software.</li>
- <li>macOS system updates can be completed using the App Store application, or the <code>softwareupdate</code> command-line utility - neither requires registering an Apple account.</li>
- <li>Subscribe to announcement mailing lists (e.g., <a href="https://lists.apple.com/mailman/listinfo/security-announce">Apple security-announce</a>) for programs you use often.</li>
- </ul>
- </li>
- <li>
- <p>Encrypt sensitive data</p>
- <ul>
- <li>In addition to full disk encryption, create one or many encrypted containers to store passwords, keys, personal documents, and other data at rest.</li>
- <li>This will mitigate damage in case of compromise and data exfiltration.</li>
- </ul>
- </li>
- <li>
- <p>Frequent backups</p>
- <ul>
- <li>Create <a href="https://www.amazon.com/o/ASIN/0596102461/backupcentral">regular backups</a> of your data and be ready to reimage in case of compromise.</li>
- <li>Always encrypt before copying backups to external media or the "cloud".</li>
- <li>Verify backups work by testing them regularly, for example by accessing certain files or performing a hash based comparison.</li>
- </ul>
- </li>
- <li>
- <p>Click carefully</p>
- <ul>
- <li>Ultimately, the security of a system can be reduced to its administrator.</li>
- <li>Care should be taken when installing new software. Always prefer <a href="https://www.gnu.org/philosophy/free-sw.en.html">free</a> and open source software (<a href="https://superuser.com/questions/19492/is-mac-os-x-open-source">which macOS is not</a>).</li>
- </ul>
- </li>
- </ul>
- <h2>Firmware</h2>
- <p>Setting a firmware password prevents your Mac from starting up from any device other than your startup disk. It may also be set to be required on each boot.</p>
- <p>This feature <a href="https://www.ftc.gov/news-events/blogs/techftc/2015/08/virtues-strong-enduser-device-controls">can be helpful if your laptop is stolen</a>, as the only way to reset the firmware password is through an Apple Store, or by using an <a href="https://reverse.put.as/2016/06/25/apple-efi-firmware-passwords-and-the-scbo-myth/">SPI programmer</a>, such as <a href="http://ho.ax/posts/2012/06/unbricking-a-macbook/">Bus Pirate</a> or other flash IC programmer.</p>
- <ol>
- <li>
- <p>Start up pressing <code>Command</code> <code>R</code> keys to boot to <a href="https://support.apple.com/en-au/HT201314">Recovery Mode</a> mode.</p>
- </li>
- <li>
- <p>When the Recovery window appears, choose <strong>Firmware Password Utility</strong> from the Utilities menu.</p>
- </li>
- <li>
- <p>In the Firmware Utility window that appears, select <strong>Turn On Firmware Password</strong>.</p>
- </li>
- <li>
- <p>Enter a new password, then enter the same password in the <strong>Verify</strong> field.</p>
- </li>
- <li>
- <p>Select <strong>Set Password</strong>.</p>
- </li>
- <li>
- <p>Select <strong>Quit Firmware Utility</strong> to close the Firmware Password Utility.</p>
- </li>
- <li>
- <p>Select the Apple menu and choose Restart or Shutdown.</p>
- </li>
- </ol>
- <p>The firmware password will activate at next boot. To validate the password, hold <code>Alt</code> during boot - you should be prompted to enter the password.</p>
- <p>The firmware password can also be managed with the <code>firmwarepasswd</code> utility while booted into the OS.</p>
- <p><img width="750" alt="Using a Dediprog SF600 to dump and flash a 2013 MacBook SPI Flash chip to remove a firmware password, sans Apple" src="https://cloud.githubusercontent.com/assets/12475110/17075918/0f851c0c-50e7-11e6-904d-0b56cf0080c1.png"></p>
- <p><em>Using a <a href="http://www.dediprog.com/pd/spi-flash-solution/sf600">Dediprog SF600</a> to dump and flash a 2013 MacBook SPI Flash chip to remove a firmware password, sans Apple</em></p>
- <p>See <a href="https://support.apple.com/en-au/HT204455">HT204455</a>, <a href="https://github.com/LongSoft/UEFITool">LongSoft/UEFITool</a> and <a href="https://github.com/chipsec/chipsec">chipsec/chipsec</a> for more information.</p>
- <h2>Preparing and Installing macOS</h2>
- <p>There are several ways to install a fresh copy of macOS.</p>
- <p>The simplest way is to boot into <a href="https://support.apple.com/en-us/HT201314">Recovery Mode</a> by holding <code>Command</code> <code>R</code> keys at boot. A system image can be downloaded and applied directly from Apple. However, this way exposes the serial number and other identifying information over the network in plaintext.</p>
- <p><img width="500" alt="PII is transmitted to Apple in plaintext when using macOS Recovery" src="https://cloud.githubusercontent.com/assets/12475110/20312189/8987c958-ab20-11e6-90fa-7fd7c8c1169e.png"></p>
- <p><em>Packet capture of an unencrypted HTTP conversation during macOS recovery</em></p>
- <p>Another way is to download <strong>macOS Sierra</strong> from the <a href="https://itunes.apple.com/us/app/macos-sierra/id1127487414">App Store</a> or some other place and create a custom, installable system image.</p>
- <p>The macOS Sierra installer application is <a href="https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW6">code signed</a>, which should be verified to make sure you received a legitimate copy, using the <code>codesign</code> command:</p>
- <p><code>$ codesign -dvv /Applications/Install\ macOS\ Sierra.app
- Executable=/Applications/Install macOS Sierra.app/Contents/MacOS/InstallAssistant
- Identifier=com.apple.InstallAssistant.Sierra
- Format=app bundle with Mach-O thin (x86_64)
- CodeDirectory v=20200 size=297 flags=0x200(kill) hashes=5+5 location=embedded
- Signature size=4167
- Authority=Apple Mac OS Application Signing
- Authority=Apple Worldwide Developer Relations Certification Authority
- Authority=Apple Root CA
- Info.plist entries=30
- TeamIdentifier=K36BKF7T3D
- Sealed Resources version=2 rules=7 files=137
- Internal requirements count=1 size=124</code></p>
- <p>macOS installers can be made with the <code>createinstallmedia</code> utility included in <code>Install macOS Sierra.app/Contents/Resources/</code>. See <a href="https://support.apple.com/en-us/HT201372">Create a bootable installer for macOS</a>, or run the utility without arguments to see how it works.</p>
- <p><strong>Note</strong> Apple's installer <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/120">does not appear to work</a> across OS versions. If you want to build a 10.12 image, for example, the following steps must be run on a 10.12 machine!</p>
- <p>To create a <strong>bootable USB macOS installer</strong>, mount a USB drive, and erase and partition it, then use the <code>createinstallmedia</code> utility:</p>
- <p>```
- $ diskutil list
- [Find disk matching correct size, usually "disk2"]</p>
- <p>$ diskutil unmountDisk /dev/disk2</p>
- <p>$ diskutil partitionDisk /dev/disk2 1 JHFS+ Installer 100%</p>
- <p>$ cd /Applications/Install\ macOS\ Sierra.app</p>
- <p>$ sudo ./Contents/Resources/createinstallmedia --volume /Volumes/Installer --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction
- Erasing Disk: 0%... 10%... 20%... 30%... 100%...
- Copying installer files to disk...
- Copy complete.
- Making disk bootable...
- Copying boot files...
- Copy complete.
- Done.
- ```</p>
- <p>To create a custom, installable image which can be <a href="https://en.wikipedia.org/wiki/Apple_Software_Restore">restored</a> to a Mac, you will need to find the file <code>InstallESD.dmg</code>, which is also inside <code>Install macOS Sierra.app</code>.</p>
- <p>With Finder, right click on the app, select <strong>Show Package Contents</strong> and navigate to <strong>Contents</strong> > <strong>SharedSupport</strong> to find the file <code>InstallESD.dmg</code>.</p>
- <p>You can <a href="https://support.apple.com/en-us/HT201259">verify</a> the following cryptographic hashes to ensure you have the same copy with <code>openssl sha1 InstallESD.dmg</code> or <code>shasum -a 1 InstallESD.dmg</code> or <code>shasum -a 256 InstallESD.dmg</code> (in Finder, you can drag the file into a Terminal window to provide the full path).</p>
- <p>To determine which macOS versions and builds originally shipped with or are available for your Mac, see <a href="https://support.apple.com/en-us/HT204319">HT204319</a>.</p>
- <p>See <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/blob/master/InstallESD_Hashes.csv">InstallESD_Hashes.csv</a> in this repository for a list of current and previous file hashes. You can also Google the cryptographic hashes to ensure the file is genuine and has not been tampered with.</p>
- <p>To create the image, use <a href="https://github.com/MagerValp/AutoDMG">MagerValp/AutoDMG</a>, or to create it manually, mount and install the operating system to a temporary image:</p>
- <pre><code>$ hdiutil attach -mountpoint /tmp/install_esd ./InstallESD.dmg
-
- $ hdiutil create -size 32g -type SPARSE -fs HFS+J -volname "macOS" -uid 0 -gid 80 -mode 1775 /tmp/output.sparseimage
-
- $ hdiutil attach -mountpoint /tmp/os -owners on /tmp/output.sparseimage
-
- $ sudo installer -pkg /tmp/install_esd/Packages/OSInstall.mpkg -tgt /tmp/os -verbose
- </code></pre>
- <p>This part will take a while, so be patient. You can <code>tail -F /var/log/install.log</code> in another Terminal window to check progress.</p>
- <p><strong>(Optional)</strong> Install additional software, such as <a href="https://www.wireshark.org/download.html">Wireshark</a>:</p>
- <pre><code>$ hdiutil attach Wireshark\ 2.2.0\ Intel\ 64.dmg
-
- $ sudo installer -pkg /Volumes/Wireshark/Wireshark\ 2.2.0\ Intel\ 64.pkg -tgt /tmp/os
-
- $ hdiutil unmount /Volumes/Wireshark
- </code></pre>
- <p>See <a href="https://github.com/MagerValp/AutoDMG/wiki/Packages-Suitable-for-Deployment">MagerValp/AutoDMG/wiki/Packages-Suitable-for-Deployment</a> for caveats and <a href="https://github.com/chilcote/outset">chilcote/outset</a> to instead processes packages and scripts at first boot.</p>
- <p>When you're done, detach, convert and verify the image:</p>
- <pre><code>$ hdiutil detach /tmp/os
-
- $ hdiutil detach /tmp/install_esd
-
- $ hdiutil convert -format UDZO /tmp/output.sparseimage -o ~/sierra.dmg
-
- $ asr imagescan --source ~/sierra.dmg
- </code></pre>
- <p>Now <code>sierra.dmg</code> is ready to be applied to one or multiple Macs. One could futher customize the image to include premade users, applications, preferences, etc.</p>
- <p>This image can be installed using another Mac in <a href="https://support.apple.com/en-us/HT201462">Target Disk Mode</a> or from a bootable USB installer.</p>
- <p>To use <strong>Target Disk Mode</strong>, boot up the Mac you wish to image while holding the <code>T</code> key and connect it to another Mac using a Firewire, Thunderbolt or USB-C cable.</p>
- <p>If you don't have another Mac, boot to a USB installer, with <code>sierra.dmg</code> and other required files copied to it, by holding the <em>Option</em> key at boot.</p>
- <p>Run <code>diskutil list</code> to identify the connected Mac's disk, usually <code>/dev/disk2</code></p>
- <p><strong>(Optional)</strong> <a href="https://www.backblaze.com/blog/securely-erase-mac-ssd/">Securely erase</a> the disk with a single pass (if previously FileVault-encrypted, the disk must first be unlocked and mounted as <code>/dev/disk3s2</code>):</p>
- <pre><code>$ sudo diskutil secureErase freespace 1 /dev/disk3s2
- </code></pre>
- <p>Partition the disk to Journaled HFS+:</p>
- <pre><code>$ sudo diskutil unmountDisk /dev/disk2
-
- $ sudo diskutil partitionDisk /dev/disk2 1 JHFS+ macOS 100%
- </code></pre>
- <p>Restore the image to the new volume:</p>
- <pre><code>$ sudo asr restore --source ~/sierra.dmg --target /Volumes/macOS --erase --buffersize 4m
- </code></pre>
- <p>You can also use the <strong>Disk Utility</strong> application to erase the connected Mac's disk, then restore <code>sierra.dmg</code> to the newly created partition.</p>
- <p>If you've followed these steps correctly, the target Mac should now have a new install of macOS Sierra.</p>
- <p>If you want to transfer any files, copy them to a shared folder like <code>/Users/Shared</code> on the mounted disk image, e.g. <code>cp Xcode_8.0.dmg /Volumes/macOS/Users/Shared</code></p>
- <p><img width="1280" alt="Finished restore install from USB recovery boot" src="https://cloud.githubusercontent.com/assets/12475110/14804078/f27293c8-0b2d-11e6-8e1f-0fb0ac2f1a4d.png"></p>
- <p><em>Finished restore install from USB recovery boot</em></p>
- <p>We're not done yet! Unless you have built the image with <a href="https://github.com/MagerValp/AutoDMG">AutoDMG</a>, or installed macOS to a second partition on your Mac, you will need to create a recovery partition (in order to use full disk encryption). You can do so using <a href="https://github.com/MagerValp/Create-Recovery-Partition-Installer">MagerValp/Create-Recovery-Partition-Installer</a> or using the following manual steps:</p>
- <p>Download the file <a href="https://support.apple.com/downloads/DL1464/en_US/RecoveryHDUpdate.dmg">RecoveryHDUpdate.dmg</a>.</p>
- <p><code>RecoveryHDUpdate.dmg
- SHA-256: f6a4f8ac25eaa6163aa33ac46d40f223f40e58ec0b6b9bf6ad96bdbfc771e12c
- SHA-1: 1ac3b7059ae0fcb2877d22375121d4e6920ae5ba</code></p>
- <p>Attach and expand the installer, then run it:</p>
- <p>```
- $ hdiutil attach RecoveryHDUpdate.dmg</p>
- <p>$ pkgutil --expand /Volumes/Mac\ OS\ X\ Lion\ Recovery\ HD\ Update/RecoveryHDUpdate.pkg /tmp/recovery</p>
- <p>$ hdiutil attach /tmp/recovery/RecoveryHDUpdate.pkg/RecoveryHDMeta.dmg</p>
- <p>$ /tmp/recovery/RecoveryHDUpdate.pkg/Scripts/Tools/dmtest ensureRecoveryPartition /Volumes/macOS/ /Volumes/Recovery\ HD\ Update/BaseSystem.dmg 0 0 /Volumes/Recovery\ HD\ Update/BaseSystem.chunklist
- ```</p>
- <p>Replace <code>/Volumes/macOS</code> with the path to the target disk mode-booted Mac as necessary.</p>
- <p>This step will take several minutes. Run <code>diskutil list</code> again to make sure <strong>Recovery HD</strong> now exists on <code>/dev/disk2</code> or equivalent identifier.</p>
- <p>Once you're done, eject the disk with <code>hdiutil unmount /Volumes/macOS</code> and power down the target disk mode-booted Mac.</p>
- <h3>Virtualization</h3>
- <p>To install macOS as a virtual machine (vm) using <a href="https://www.vmware.com/products/fusion.html">VMware Fusion</a>, follow the instructions above to create an image. You will <strong>not</strong> need to download and create a recovery partition manually.</p>
- <p><code>VMware-Fusion-8.5.2-4635224.dmg
- SHA-256: f6c54b98c9788d1df94d470661eedff3e5d24ca4fb8962fac5eb5dc56de63b77
- SHA-1: 37ec465673ab802a3f62388d119399cb94b05408</code></p>
- <p>For the Installation Method, select <em>Install OS X from the recovery partition</em>. Customize any memory or CPU requirements and complete setup. The guest vm should boot into <a href="https://support.apple.com/en-us/HT201314">Recovery Mode</a> by default.</p>
- <p>In Recovery Mode, select a language, then Utilities > Terminal from the menubar.</p>
- <p>In the guest vm, type <code>ifconfig | grep inet</code> - you should see a private address like <code>172.16.34.129</code></p>
- <p>On the host Mac, type <code>ifconfig | grep inet</code> - you should see a private gateway address like <code>172.16.34.1</code></p>
- <p>From the host Mac, serve the installable image to the guest vm by editing <code>/etc/apache2/httpd.conf</code> and adding the following line to the top (using the gateway address assigned to the host Mac and port 80):</p>
- <pre><code>Listen 172.16.34.1:80
- </code></pre>
- <p>On the host Mac, link the image to the default Apache Web server directory:</p>
- <pre><code>$ sudo ln ~/sierra.dmg /Library/WebServer/Documents
- </code></pre>
- <p>From the host Mac, start Apache in the foreground:</p>
- <pre><code>$ sudo httpd -X
- </code></pre>
- <p>From the guest VM, install the disk image to the volume over the local network using <code>asr</code>:</p>
- <p><code>-bash-3.2# asr restore --source http://172.16.34.1/sierra.dmg --target /Volumes/Macintosh\ HD/ --erase --buffersize 4m
- Validating target...done
- Validating source...done
- Erase contents of /dev/disk0s2 (/Volumes/Macintosh HD)? [ny]: y
- Retrieving scan information...done
- Validating sizes...done
- Restoring ....10....20....30....40....50....60....70....80....90....100
- Verifying ....10....20....30....40....50....60....70....80....90....100
- Remounting target volume...done</code></p>
- <p>When it's finished, stop the Apache Web server on the host Mac by pressing <code>Control</code> <code>C</code> at the <code>sudo httpd -X</code> window and remove the image copy with <code>sudo rm /Library/WebServer/Documents/sierra.dmg</code></p>
- <p>In the guest vm, select <em>Startup Disk</em> from the top-left corner Apple menu, select the hard drive and restart. You may wish to disable the Network Adapter in VMware for the initial guest vm boot.</p>
- <p>Take and Restore from saved guest vm snapshots before and after attempting risky browsing, for example, or use a guest vm to install and operate questionable software.</p>
- <h2>First boot</h2>
- <p><strong>Note</strong> Before setting up macOS, consider disconnecting networking and configuring a firewall(s) first. However, <a href="https://www.ifixit.com/Device/MacBook_Pro_15%22_Late_2016_Touch_Bar">late 2016 MacBooks</a> with Touch Bar hardware <a href="https://onemoreadmin.wordpress.com/2016/11/27/the-untouchables-apples-new-os-activation-for-touch-bar-macbook-pros/">require online OS activation</a>.</p>
- <p>On first boot, hold <code>Command</code> <code>Option</code> <code>P</code> <code>R</code> keys to <a href="https://support.apple.com/en-us/HT204063">clear NVRAM</a>.</p>
- <p>When macOS first starts, you'll be greeted by <strong>Setup Assistant</strong>.</p>
- <p>When creating your account, use a <a href="http://www.explainxkcd.com/wiki/index.php/936:_Password_Strength">strong password</a> without a hint.</p>
- <p>If you enter your real name at the account setup process, be aware that your <a href="https://support.apple.com/kb/PH18720">computer's name and local hostname</a> will comprise that name (e.g., <em>John Appleseed's MacBook</em>) and thus will appear on local networks and in various preference files. You can change them both in <strong>System Preferences > Sharing</strong> or with the following commands:</p>
- <pre><code>$ sudo scutil --set ComputerName your_computer_name
-
- $ sudo scutil --set LocalHostName your_hostname
- </code></pre>
- <h2>Admin and standard user accounts</h2>
- <p>The first user account is always an admin account. Admin accounts are members of the admin group and have access to <code>sudo</code>, which allows them to usurp other accounts, in particular root, and gives them effective control over the system. Any program that the admin executes can potentially obtain the same access, making this a security risk. Utilities like <code>sudo</code> have <a href="https://bogner.sh/2014/03/another-mac-os-x-sudo-password-bypass/">weaknesses that can be exploited</a> by concurrently running programs and many panes in System Preferences are <a href="http://csrc.nist.gov/publications/drafts/800-179/sp800_179_draft.pdf">unlocked by default</a> [p. 61–62] for admin accounts. It is considered a best practice by <a href="https://help.apple.com/machelp/mac/10.12/index.html#/mh11389">Apple</a> and <a href="http://csrc.nist.gov/publications/drafts/800-179/sp800_179_draft.pdf">others</a> [p. 41–42] to use a separate standard account for day-to-day work and use the admin account for installations and system configuration.</p>
- <p>It is not strictly required to ever log into the admin account via the macOS login screen. The system will prompt for authentication when required and Terminal can do the rest. To that end, Apple provides some <a href="https://support.apple.com/HT203998">recommendations</a> for hiding the admin account and its home directory. This can be an elegant solution to avoid having a visible 'ghost' account. The admin account can also be <a href="http://apple.stackexchange.com/a/94373">removed from FileVault</a>.</p>
- <h4>Caveats</h4>
- <ol>
- <li>
- <p>Only administrators can install applications in <code>/Applications</code> (local directory). Finder and Installer will prompt a standard user with an authentication dialog. Many applications can be installed in <code>~/Applications</code> instead (the directory can be created manually). As a rule of thumb: applications that do not require admin access – or do not complain about not being installed in <code>/Applications</code> – should be installed in the user directory, the rest in the local directory. Mac App Store applications are still installed in <code>/Applications</code> and require no additional authentication.</p>
- </li>
- <li>
- <p><code>sudo</code> is not available in shells of the standard user, which requires using <code>su</code> or <code>login</code> to enter a shell of the admin account. This can make some maneuvers trickier and requires some basic experience with command-line interfaces.</p>
- </li>
- <li>
- <p>System Preferences and several system utilities (e.g. Wi-Fi Diagnostics) will require root privileges for full functionality. Many panels in System Preferences are locked and need to be unlocked separately by clicking on the lock icon. Some applications will simply prompt for authentication upon opening, others must be opened by an admin account directly to get access to all functions (e.g. Console).</p>
- </li>
- <li>
- <p>There are third-party applications that will not work correctly because they assume that the user account is an admin. These programs may have to be executed by logging into the admin account, or by using the <code>open</code> utility.</p>
- </li>
- </ol>
- <h4>Setup</h4>
- <p>Accounts can be created and managed in System Preferences. On settled systems, it is generally easier to create a second admin account and then demote the first account. This avoids data migration. Newly installed systems can also just add a standard account. Demoting an account can be done either from the the new admin account in System Preferences – the other account must be logged out – or by executing this command:
- <code>sudo dscl . -delete /Groups/admin GroupMembership user_name</code></p>
- <h2>Full disk encryption</h2>
- <p><a href="https://en.wikipedia.org/wiki/FileVault">FileVault</a> provides full disk (technically, full <em>volume</em>) encryption on macOS.</p>
- <p>FileVault encryption will protect data at rest and prevent someone with physical access from stealing data or tampering with your Mac.</p>
- <p>With much of the cryptographic operations happening <a href="https://software.intel.com/en-us/articles/intel-advanced-encryption-standard-aes-instructions-set/">efficiently in hardware</a>, the performance penalty for FileVault is not noticeable.</p>
- <p>The security of FileVault greatly depends on the pseudo random number generator (PRNG).</p>
- <blockquote>
- <p>The random device implements the Yarrow pseudo random number generator algorithm and maintains its entropy pool. Additional entropy is fed to the generator regularly by the SecurityServer daemon from random jitter measurements of the kernel.</p>
- <p>SecurityServer is also responsible for periodically saving some entropy to disk and reloading it during startup to provide entropy in early system operation.</p>
- </blockquote>
- <p>See <code>man 4 random</code> for more information.</p>
- <p>The PRNG can be manually seeded with entropy by writing to /dev/random <strong>before</strong> enabling FileVault. This can be done by simply using the Mac for a little while before activating FileVault.</p>
- <p>To manually seed entropy <em>before</em> enabling FileVault:</p>
- <pre><code>$ cat > /dev/random
- [Type random letters for a long while, then press Control-D]
- </code></pre>
- <p>Enable FileVault with <code>sudo fdesetup enable</code> or through <strong>System Preferences</strong> > <strong>Security & Privacy</strong> and reboot.</p>
- <p>If you can remember your password, there's no reason to save the <strong>recovery key</strong>. However, your encrypted data will be lost forever if you can't remember the password or recovery key.</p>
- <p>If you want to know more about how FileVault works, see the paper <a href="https://eprint.iacr.org/2012/374.pdf">Infiltrate the Vault: Security Analysis and Decryption of Lion Full Disk Encryption</a> (pdf) and related <a href="http://www.cl.cam.ac.uk/~osc22/docs/slides_fv2_ifip_2013.pdf">presentation</a> (pdf). Also see <a href="http://libeccio.di.unisa.it/Crypto14/Lab/p1619.pdf">IEEE Std 1619-2007 “The XTS-AES Tweakable Block Cipher”</a> (pdf).</p>
- <p>You may wish to enforce <strong>hibernation</strong> and evict FileVault keys from memory instead of traditional sleep to memory:</p>
- <pre><code>$ sudo pmset -a destroyfvkeyonstandby 1
- $ sudo pmset -a hibernatemode 25
- </code></pre>
- <blockquote>
- <p>All computers have firmware of some type—EFI, BIOS—to help in the discovery of hardware components and ultimately to properly bootstrap the computer using the desired OS instance. In the case of Apple hardware and the use of EFI, Apple stores relevant information within EFI to aid in the functionality of macOS. For example, the FileVault key is stored in EFI to transparently come out of standby mode.</p>
- <p>Organizations especially sensitive to a high-attack environment, or potentially exposed to full device access when the device is in standby mode, should mitigate this risk by destroying the FileVault key in firmware. Doing so doesn’t destroy the use of FileVault, but simply requires the user to enter the password in order for the system to come out of standby mode.</p>
- </blockquote>
- <p>If you choose to evict FileVault keys in standby mode, you should also modify your standby and power nap settings. Otherwise, your machine may wake while in standby mode and then power off due to the absence of the FileVault key. See <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/124">issue #124</a> for more information. These settings can be changed with:</p>
- <pre><code>$ sudo pmset -a powernap 0
- $ sudo pmset -a standby 0
- $ sudo pmset -a standbydelay 0
- $ sudo pmset -a autopoweroff 0
- </code></pre>
- <p>For more information, see <a href="http://training.apple.com/pdf/WP_FileVault2.pdf">Best Practices for
- Deploying FileVault 2</a> (pdf) and paper <a href="https://www.usenix.org/legacy/event/sec08/tech/full_papers/halderman/halderman.pdf">Lest We Remember: Cold Boot Attacks on Encryption Keys</a> (pdf)</p>
- <h2>Firewall</h2>
- <p>Before connecting to the Internet, it's a good idea to first configure a firewall.</p>
- <p>There are several types of firewall available for macOS.</p>
- <h4>Application layer firewall</h4>
- <p>Built-in, basic firewall which blocks <strong>incoming</strong> connections only.</p>
- <p>Note, this firewall does not have the ability to monitor, nor block <strong>outgoing</strong> connections.</p>
- <p>It can be controlled by the <strong>Firewall</strong> tab of <strong>Security & Privacy</strong> in <strong>System Preferences</strong>, or with the following commands.</p>
- <p>Enable the firewall:</p>
- <pre><code>$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
- </code></pre>
- <p>Enable logging:</p>
- <pre><code>$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setloggingmode on
- </code></pre>
- <p>You may also wish to enable stealth mode:</p>
- <pre><code>$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on
- </code></pre>
- <blockquote>
- <p>Computer hackers scan networks so they can attempt to identify computers to attack. You can prevent your computer from responding to some of these scans by using <strong>stealth mode</strong>. When stealth mode is enabled, your computer does not respond to ICMP ping requests, and does not answer to connection attempts from a closed TCP or UDP port. This makes it more difficult for attackers to find your computer.</p>
- </blockquote>
- <p>Finally, you may wish to prevent <em>built-in software</em> as well as <em>code-signed, downloaded software from being whitelisted automatically</em>:</p>
- <pre><code>$ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsigned off
-
- $ sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsignedapp off
- </code></pre>
- <blockquote>
- <p>Applications that are signed by a valid certificate authority are automatically added to the list of allowed apps, rather than prompting the user to authorize them. Apps included in macOS are signed by Apple and are allowed to receive incoming connections when this setting is enabled. For example, since iTunes is already signed by Apple, it is automatically allowed to receive incoming connections through the firewall.</p>
- <p>If you run an unsigned app that is not listed in the firewall list, a dialog appears with options to Allow or Deny connections for the app. If you choose "Allow", macOS signs the application and automatically adds it to the firewall list. If you choose "Deny", macOS adds it to the list but denies incoming connections intended for this app.</p>
- </blockquote>
- <p>After interacting with <code>socketfilterfw</code>, you may want to restart (or terminate) the process:</p>
- <pre><code>$ sudo pkill -HUP socketfilterfw
- </code></pre>
- <h4>Third party firewalls</h4>
- <p>Programs such as <a href="https://www.obdev.at/products/littlesnitch/index.html">Little Snitch</a>, <a href="https://www.oneperiodic.com/products/handsoff/">Hands Off</a>, <a href="http://radiosilenceapp.com/">Radio Silence</a> and <a href="https://pirate.github.io/security-growler/">Security Growler</a> provide a good balance of usability and security.</p>
- <p><img width="349" alt="Example of Little Snitch monitored session" src="https://cloud.githubusercontent.com/assets/12475110/10596588/c0eed3c0-76b3-11e5-95b8-9ce7d51b3d82.png"></p>
- <p><em>Example of Little Snitch-monitored session</em></p>
- <p><code>LittleSnitch-3.7.1.dmg
- SHA-256: e6332ee70385f459d9803b0a582d5344bb9dab28bcd56e247ae69866cc321802
- SHA-1: d5d602c0f76cd73051792dff0ac334bbdc66ae32</code></p>
- <p>These programs are capable of monitoring and blocking <strong>incoming</strong> and <strong>outgoing</strong> network connections. However, they may require the use of a closed source <a href="https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/KernelProgramming/Extend/Extend.html">kernel extension</a>.</p>
- <p>If the number of choices of allowing/blocking network connections is overwhelming, use <strong>Silent Mode</strong> with connections allowed, then periodically check your settings to gain understanding of what various applications are doing.</p>
- <p>It is worth noting that these firewalls can be bypassed by programs running as <strong>root</strong> or through <a href="https://www.blackhat.com/docs/us-15/materials/us-15-Wardle-Writing-Bad-A-Malware-For-OS-X.pdf">OS vulnerabilities</a> (pdf), but they are still worth having - just don't expect absolute protection.</p>
- <p>For more on how Little Snitch works, see the <a href="https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/NKEConceptual/socket_nke/socket_nke.html#//apple_ref/doc/uid/TP40001858-CH228-SW1">Network Kernel Extensions Programming Guide</a> and <a href="https://reverse.put.as/2016/07/22/shut-up-snitch-reverse-engineering-and-exploiting-a-critical-little-snitch-vulnerability/">Shut up snitch! – reverse engineering and exploiting a critical Little Snitch vulnerability</a>.</p>
- <h4>Kernel level packet filtering</h4>
- <p>A highly customizable, powerful, but also most complicated firewall exists in the kernel. It can be controlled with <code>pfctl</code> and various configuration files.</p>
- <p>pf can also be controlled with a GUI application such as <a href="http://www.hanynet.com/icefloor/">IceFloor</a> or <a href="http://www.murusfirewall.com/">Murus</a>.</p>
- <p>There are many books and articles on the subject of pf firewall. Here's is just one example of blocking traffic by IP address.</p>
- <p>Add the following into a file called <code>pf.rules</code>:</p>
- <p><code>set block-policy drop
- set fingerprints "/etc/pf.os"
- set ruleset-optimization basic
- set skip on lo0
- scrub in all no-df
- table <blocklist> persist
- block in log
- block in log quick from no-route to any
- pass out proto tcp from any to any keep state
- pass out proto udp from any to any keep state
- block log on en0 from {<blocklist>} to any</code></p>
- <p>Use the following commands:</p>
- <ul>
- <li><code>sudo pfctl -e -f pf.rules</code> to enable the firewall</li>
- <li><code>sudo pfctl -d</code> to disable the firewall</li>
- <li><code>sudo pfctl -t blocklist -T add 1.2.3.4</code> to add hosts to a blocklist</li>
- <li><code>sudo pfctl -t blocklist -T show</code> to view the blocklist</li>
- <li><code>sudo ifconfig pflog0 create</code> to create an interface for logging</li>
- <li><code>sudo tcpdump -ni pflog0</code> to dump the packets</li>
- </ul>
- <p>Unless you're already familiar with packet filtering, spending too much time configuring pf is not recommended. It is also probably unnecessary if your Mac is behind a <a href="https://www.grc.com/nat/nat.htm">NAT</a> on a secured home network, for example.</p>
- <p>For an example of using pf to audit "phone home" behavior of user and system-level processes, see <a href="https://github.com/fix-macosx/net-monitor">fix-macosx/net-monitor</a>.</p>
- <h2>Services</h2>
- <p>Before you connect to the Internet, you may wish to disable some system services, which use up resources or phone home to Apple.</p>
- <p>See <a href="https://github.com/fix-macosx/yosemite-phone-home">fix-macosx/yosemite-phone-home</a>, <a href="https://github.com/l1k/osxparanoia">l1k/osxparanoia</a> and <a href="https://github.com/karek314/macOS-home-call-drop">karek314/macOS-home-call-drop</a> for further recommendations.</p>
- <p>Services on macOS are managed by <strong>launchd</strong>. See (launchd.info)[http://launchd.info/], as well as <a href="https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html">Apple's Daemons and Services Programming Guide</a> and <a href="https://developer.apple.com/library/mac/technotes/tn2083/_index.html">Technical Note TN2083</a></p>
- <p>You can also run <a href="https://github.com/synack/knockknock">KnockKnock</a> that shows more information about startup items.</p>
- <ul>
- <li>Use <code>launchctl list</code> to view running user agents</li>
- <li>Use <code>sudo launchctl list</code> to view running system daemons</li>
- <li>Specify the service name to examine it, e.g. <code>launchctl list com.apple.Maps.mapspushd</code></li>
- <li>Use <code>defaults read</code> to examine job plists in <code>/System/Library/LaunchDaemons</code> and <code>/System/Library/LaunchAgents</code></li>
- <li>Use <code>man</code>, <code>strings</code> and Google to learn about what the agent/daemon runs</li>
- </ul>
- <p>For example, to learn what a system launch daemon or agent does, start with:</p>
- <pre><code>$ defaults read /System/Library/LaunchDaemons/com.apple.apsd.plist
- </code></pre>
- <p>Look at the <code>Program</code> or <code>ProgramArguments</code> section to see which binary is run, in this case <code>apsd</code>. To find more information about that, look at the man page with <code>man apsd</code></p>
- <p>For example, if you're not interested in Apple Push Notifications, disable the service:</p>
- <pre><code>$ sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.apsd.plist
- </code></pre>
- <p><strong>Note</strong> Unloading services may break usability of some applications. Read the manual pages and use Google to make sure you understand what you're doing first.</p>
- <p>Be careful about disabling any system daemons you don't understand, as it may render your system unbootable. If you break your Mac, use <a href="https://support.apple.com/en-us/HT201573">single user mode</a> to fix it.</p>
- <p>Use <a href="https://en.wikipedia.org/wiki/Console_(OS_X)">Console</a> and <a href="https://support.apple.com/en-us/HT201464">Activity Monitor</a> applications if you notice your Mac heating up, feeling sluggish, or generally misbehaving, as it may have resulted from your tinkering.</p>
- <p>To view currently disabled services:</p>
- <pre><code>$ find /var/db/com.apple.xpc.launchd/ -type f -print -exec defaults read {} \; 2>/dev/null
- </code></pre>
- <p>Annotated lists of launch daemons and agents, the respective program executed, and the programs' hash sums are included in this repository.</p>
- <p><strong>(Optional)</strong> Run the <code>read_launch_plists.py</code> script and <code>diff</code> output to check for any discrepancies on your system, e.g.:</p>
- <pre><code>$ diff <(python read_launch_plists.py) <(cat 16A323_launchd.csv)
- </code></pre>
- <p>See also <a href="http://cirrusj.github.io/Yosemite-Stop-Launch/">cirrusj.github.io/Yosemite-Stop-Launch</a> for descriptions of services and <a href="https://vilimpoc.org/blog/2014/01/15/provisioning-os-x-and-disabling-unnecessary-services/">Provisioning OS X and Disabling Unnecessary Services</a> for another explanation.</p>
- <h2>Spotlight Suggestions</h2>
- <p>Disable <strong>Spotlight Suggestions</strong> in both the Spotlight preferences and Safari's Search preferences to avoid your search queries being sent to Apple.</p>
- <p>Also disable <strong>Bing Web Searches</strong> in the Spotlight preferences to avoid your search queries being sent to Microsoft.</p>
- <p>See <a href="https://fix-macosx.com/">fix-macosx.com</a> for detailed instructions.</p>
- <blockquote>
- <p>If you've upgraded to OS X 10.10 "Yosemite" and you're using the default settings, each time you start typing in Spotlight (to open an application or search for a file on your computer), your local search terms and location are sent to Apple and third parties (including Microsoft).</p>
- </blockquote>
- <p><strong>Note</strong> This Web site and instructions may no longer work on macOS Sierra - see <a href="https://github.com/drduh/macOS-Security-and-Privacy-Guide/issues/164">issue 164</a>.</p>
- <p>To download, view and apply their suggested fixes:</p>
- <p>```
- $ curl -O https://fix-macosx.com/fix-macosx.py</p>
- <p>$ less fix-macosx.py</p>
- <p>$ python fix-macosx.py
- All done. Make sure to log out (and back in) for the changes to take effect.
- ```</p>
- <p>Speaking of Microsoft, you may want to see <a href="https://fix10.isleaked.com/">https://fix10.isleaked.com/</a> just for fun.</p>
- <h2>Homebrew</h2>
- <p>Consider using <a href="http://brew.sh/">Homebrew</a> to make software installations easier and to update userland tools (see <a href="http://meta.ath0.com/2012/02/05/apples-great-gpl-purge/">Apple’s great GPL purge</a>).</p>
- <p><strong>Note</strong> If you have not already installed Xcode or Command Line Tools, use <code>xcode-select --install</code> to download and install them from Apple.</p>
- <p>To <a href="https://github.com/Homebrew/brew/blob/master/docs/Installation.md#installation">install Homebrew</a>:</p>
- <pre><code>$ mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
- </code></pre>
- <p>Edit <code>PATH</code> in your shell or shell rc file to use <code>~/homebrew/bin</code> and <code>~/homebrew/sbin</code>. For example, <code>echo 'PATH=$PATH:~/homebrew/sbin:~/homebrew/bin' >> .zshrc</code>, then change your login shell to Z shell with <code>chsh -s /bin/zsh</code>, open a new Terminal window and run <code>brew update</code>.</p>
- <p>Homebrew uses SSL/TLS to talk with GitHub and verifies checksums of downloaded packages, so it's <a href="https://github.com/Homebrew/homebrew/issues/18036">fairly secure</a>.</p>
- <p>Remember to periodically run <code>brew update</code> and <code>brew upgrade</code> on trusted and secure networks to download and install software updates. To get information on a package before installation, run <code>brew info <package></code> and check its recipe online.</p>
- <p>According to <a href="https://github.com/Homebrew/brew/blob/master/docs/Analytics.md">Homebrew's Anonymous Aggregate User Behaviour Analytics</a>, Homebrew gathers anonymous aggregate user behaviour analytics and reporting these to Google Analytics.</p>
- <p>To opt out of Homebrew's analytics, you can set <code>export HOMEBREW_NO_ANALYTICS=1</code> in your environment or shell rc file, or use <code>brew analytics off</code>.</p>
- <p>You may also wish to enable <a href="https://github.com/drduh/macOS-Security-and-Privacy-Guide/issues/138">additional security options</a>, such as <code>HOMEBREW_NO_INSECURE_REDIRECT=1</code> and <code>HOMEBREW_CASK_OPTS=--require-sha</code>.</p>
- <h2>DNS</h2>
- <h4>Hosts file</h4>
- <p>Use the <a href="https://en.wikipedia.org/wiki/Hosts_(file)">hosts file</a> to block known malware, advertising or otherwise unwanted domains.</p>
- <p>Edit the hosts file as root, for example with <code>sudo vi /etc/hosts</code>. The hosts file can also be managed with the GUI app <a href="https://github.com/2ndalpha/gasmask">2ndalpha/gasmask</a>.</p>
- <p>To block a domain, append <code>0 example.com</code> or <code>0.0.0.0 example.com</code> or <code>127.0.0.1 example.com</code> to <code>/etc/hosts</code></p>
- <p>There are many lists of domains available online which you can paste in, just make sure each line starts with <code>0</code>, <code>0.0.0.0</code>, <code>127.0.0.1</code>, and the line <code>127.0.0.1 localhost</code> is included.</p>
- <p>For hosts lists, see <a href="http://someonewhocares.org/hosts/zero/hosts">someonewhocares.org</a>, <a href="https://github.com/l1k/osxparanoia/blob/master/hosts">l1k/osxparanoia/blob/master/hosts</a>, <a href="https://github.com/StevenBlack/hosts">StevenBlack/hosts</a> and <a href="https://github.com/gorhill/uMatrix/blob/master/assets/umatrix/hosts-files.json">gorhill/uMatrix/hosts-files.json</a>.</p>
- <p>To append a raw list:</p>
- <p>```
- $ curl "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" | sudo tee -a /etc/hosts</p>
- <p>$ wc -l /etc/hosts
- 31998</p>
- <p>$ egrep -ve "^#|^255.255.255|^0.0.0.0|^127.0.0.0|^0 " /etc/hosts
- ::1 localhost
- fe80::1%lo0 localhost
- [should not return any other IP addresses]
- ```</p>
- <p>See <code>man hosts</code> and <a href="https://www.freebsd.org/doc/handbook/configtuning-configfiles.html">FreeBSD Configuration Files</a> for more information.</p>
- <h4>Dnsmasq</h4>
- <p>Among other features, <a href="http://www.thekelleys.org.uk/dnsmasq/doc.html">dnsmasq</a> is able to cache replies, prevent upstreaming queries for unqualified names, and block entire TLDs.</p>
- <p>Use in combination with DNSCrypt to additionally encrypt outgoing DNS traffic.</p>
- <p>If you don't wish to use DNSCrypt, you should at least use DNS <a href="http://bcn.boulder.co.us/~neal/ietf/verisign-abuse.html">not provided</a> <a href="http://hackercodex.com/guide/how-to-stop-isp-dns-server-hijacking/">by your ISP</a>. Two popular alternatives are <a href="https://developers.google.com/speed/public-dns/">Google DNS</a> and <a href="https://www.opendns.com/home-internet-security/">OpenDNS</a>.</p>
- <p><strong>(Optional)</strong> <a href="https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions">DNSSEC</a> is a set of extensions to DNS which provide to DNS clients (resolvers) origin authentication of DNS data, authenticated denial of existence, and data integrity. All answers from DNSSEC protected zones are digitally signed. The signed records are authenticated via a chain of trust, starting with a set of verified public keys for the DNS root-zone. The current root-zone trust anchors may be downloaded <a href="https://www.iana.org/dnssec/files">from IANA website</a>. There are a number of resources on DNSSEC, but probably the best one is <a href="http://www.dnssec.net">dnssec.net website</a>.</p>
- <p>Install Dnsmasq (DNSSEC is optional):</p>
- <pre><code>$ brew install dnsmasq --with-dnssec
-
- $ cp ~/homebrew/opt/dnsmasq/dnsmasq.conf.example ~/homebrew/etc/dnsmasq.conf
- </code></pre>
- <p>Edit the configuration:</p>
- <pre><code>$ vim ~/homebrew/etc/dnsmasq.conf
- </code></pre>
- <p>Examine all the options. Here are a few recommended settings to enable:</p>
- <p>```</p>
- <h1>Forward queries to DNSCrypt on localhost port 5355</h1>
- <p>server=127.0.0.1#5355</p>
- <h1>Uncomment to forward queries to Google Public DNS</h1>
- <h1>server=8.8.8.8</h1>
- <h1>Never forward plain names</h1>
- <p>domain-needed</p>
- <h1>Examples of blocking TLDs or subdomains</h1>
- <p>address=/.onion/0.0.0.0
- address=/.local/0.0.0.0
- address=/.mycoolnetwork/0.0.0.0
- address=/.facebook.com/0.0.0.0</p>
- <h1>Never forward addresses in the non-routed address spaces</h1>
- <p>bogus-priv</p>
- <h1>Reject private addresses from upstream nameservers</h1>
- <p>stop-dns-rebind</p>
- <h1>Query servers in order</h1>
- <p>strict-order</p>
- <h1>Set the size of the cache</h1>
- <h1>The default is to keep 150 hostnames</h1>
- <p>cache-size=8192</p>
- <h1>Optional logging directives</h1>
- <p>log-async
- log-dhcp
- log-facility=/var/log/dnsmasq.log</p>
- <h1>Uncomment to log all queries</h1>
- <h1>log-queries</h1>
- <h1>Uncomment to enable DNSSEC</h1>
- <h1>dnssec</h1>
- <h1>trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5</h1>
- <h1>dnssec-check-unsigned</h1>
- <p>```</p>
- <p>Install and start the program (sudo is required to bind to <a href="https://unix.stackexchange.com/questions/16564/why-are-the-first-1024-ports-restricted-to-the-root-user-only">privileged port</a> 53):</p>
- <pre><code>$ sudo brew services start dnsmasq
- </code></pre>
- <p>To set Dnsmasq as your local DNS server, open <strong>System Preferences</strong> > <strong>Network</strong> and select the active interface, then the <strong>DNS</strong> tab, select <strong>+</strong> and add <code>127.0.0.1</code>, or use:</p>
- <pre><code>$ sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1
- </code></pre>
- <p>Make sure Dnsmasq is correctly configured:</p>
- <p>```
- $ scutil --dns
- DNS configuration</p>
- <p>resolver #1
- search domain[0] : whatever
- nameserver[0] : 127.0.0.1
- flags : Request A records, Request AAAA records
- reach : Reachable, Local Address, Directly Reachable Address</p>
- <p>$ networksetup -getdnsservers "Wi-Fi"
- 127.0.0.1
- ```</p>
- <p><strong>Note</strong> Some VPN software overrides DNS settings on connect. See <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/24">issue #24</a> for more information.</p>
- <h5>Test DNSSEC validation</h5>
- <p>Test DNSSEC validation succeeds for signed zones:</p>
- <pre><code>$ dig +dnssec icann.org
- </code></pre>
- <p>Reply should have <code>NOERROR</code> status and contain <code>ad</code> flag. For instance,</p>
- <pre><code>;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47039
- ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
- </code></pre>
- <p>Test DNSSEC validation fails for zones that are signed improperly:</p>
- <pre><code>$ dig www.dnssec-failed.org
- </code></pre>
- <p>Reply should have <code>SERVFAIL</code> status. For instance,</p>
- <pre><code>;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 15190
- ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
- </code></pre>
- <h4>dnscrypt</h4>
- <p>Use <a href="https://dnscrypt.org/">dnscrypt</a> to encrypt DNS traffic to the provider of choice.</p>
- <p>If you prefer a GUI application, see <a href="https://github.com/alterstep/dnscrypt-osxclient">alterstep/dnscrypt-osxclient</a>.</p>
- <p>Install DNSCrypt from Homebrew:</p>
- <pre><code>$ brew install dnscrypt-proxy
- </code></pre>
- <p>If using in combination with Dnsmasq, find the file <code>homebrew.mxcl.dnscrypt-proxy.plist</code></p>
- <p><code>$ find ~/homebrew -name homebrew.mxcl.dnscrypt-proxy.plist
- /Users/drduh/homebrew/Cellar/dnscrypt-proxy/1.7.0/homebrew.mxcl.dnscrypt-proxy.plist</code></p>
- <p>Edit it to have the line:</p>
- <pre><code><string>--local-address=127.0.0.1:5355</string>
- </code></pre>
- <p>Below the line:</p>
- <pre><code><string>/usr/local/opt/dnscrypt-proxy/sbin/dnscrypt-proxy</string>
- </code></pre>
- <p><img width="1015" alt="dnscrypt" src="https://cloud.githubusercontent.com/assets/12475110/19222914/8e6f853e-8e31-11e6-8dd6-27c33cbfaea5.png"></p>
- <p><em>Append a local-address line to use DNScrypt on a port other than 53, like 5355</em></p>
- <p>This can also be done using Homebrew, by installing <code>gnu-sed</code> and using the <code>gsed</code> command:</p>
- <pre><code>$ sudo gsed -i "/sbin\\/dnscrypt-proxy<\\/string>/a<string>--local-address=127.0.0.1:5355<\\/string>\n" $(find ~/homebrew -name homebrew.mxcl.dnscrypt-proxy.plist)
- </code></pre>
- <p>By default, the <code>resolvers-list</code> will point to the dnscrypt version specific resolvers file. When dnscrypt is updated, this version may no longer exist, and if it does, may point to an outdated file. This can be fixed by changing the resolvers file in <code>/Library/LaunchDaemons/homebrew.mxcl.dnscrypt-proxy.plist</code> to the symlinked version in <code>/usr/local/share</code>:</p>
- <pre><code><string>--resolvers-list=/usr/local/share/dnscrypt-proxy/dnscrypt-resolvers.csv</string>
- </code></pre>
- <p>Start DNSCrypt:</p>
- <pre><code>$ brew services start dnscrypt-proxy
- </code></pre>
- <p>Make sure DNSCrypt is running:</p>
- <p>```
- $ sudo lsof -Pni UDP:5355
- COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
- dnscrypt- 83 nobody 7u IPv4 0x1773f85ff9f8bbef 0t0 UDP 127.0.0.1:5355</p>
- <p>$ ps A | grep '[d]nscrypt'
- 83 ?? Ss 0:00.27 /Users/drduh/homebrew/opt/dnscrypt-proxy/sbin/dnscrypt-proxy --local-address=127.0.0.1:5355 --ephemeral-keys --resolvers-list=/Users/drduh/homebrew/opt/dnscrypt-proxy/share/dnscrypt-proxy/dnscrypt-resolvers.csv --resolver-name=dnscrypt.eu-dk --user=nobody
- ```</p>
- <blockquote>
- <p>By default, dnscrypt-proxy runs on localhost (127.0.0.1), port 53,
- and under the "nobody" user using the dnscrypt.eu-dk DNSCrypt-enabled
- resolver. If you would like to change these settings, you will have to edit the plist file (e.g., --resolver-address, --provider-name, --provider-key, etc.)</p>
- </blockquote>
- <p>This can be accomplished by editing <code>homebrew.mxcl.dnscrypt-proxy.plist</code></p>
- <p>You can run your own <a href="https://github.com/Cofyc/dnscrypt-wrapper">dnscrypt server</a> (see also <a href="https://github.com/drduh/Debian-Privacy-Server-Guide#dnscrypt">drduh/Debian-Privacy-Server-Guide#dnscrypt</a>) from a trusted location or use one of many <a href="https://github.com/jedisct1/dnscrypt-proxy/blob/master/dnscrypt-resolvers.csv">public servers</a> instead.</p>
- <p>Confirm outgoing DNS traffic is encrypted:</p>
- <p>```
- $ sudo tcpdump -qtni en0
- IP 10.8.8.8.59636 > 77.66.84.233.443: UDP, length 512
- IP 77.66.84.233.443 > 10.8.8.8.59636: UDP, length 368</p>
- <p>$ dig +short -x 77.66.84.233
- resolver2.dnscrypt.eu
- ```</p>
- <p>See also <a href="https://dnsleaktest.com/what-is-a-dns-leak.html">What is a DNS leak</a>, the <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/mDNSResponder.8.html">mDNSResponder manual page</a> and <a href="http://ipv6-test.com/">ipv6-test.com</a>.</p>
- <h2>Captive portal</h2>
- <p>When macOS connects to new networks, it <strong>probes</strong> the network and launches a Captive Portal assistant utility if connectivity can't be determined.</p>
- <p>An attacker could trigger the utility and direct a Mac to a site with malware without user interaction, so it's best to disable this feature and log in to captive portals using your regular Web browser, provided you have first disable any custom dns and/or proxy settings.</p>
- <pre><code>$ sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.captive.control Active -bool false
- </code></pre>
- <p>See also <a href="https://www.securestate.com/blog/2011/10/07/apple-os-x-lion-captive-portal-hijacking-attack">Apple OS X Lion Security: Captive Portal Hijacking Attack</a>, <a href="http://blog.erratasec.com/2010/09/apples-secret-wispr-request.html">Apple's secret "wispr" request</a>, <a href="https://web.archive.org/web/20130407200745/http://www.divertednetworks.net/apple-captiveportal.html">How to disable the captive portal window in Mac OS Lion</a>, and <a href="https://grpugh.wordpress.com/2014/10/29/an-undocumented-change-to-captive-network-assistant-settings-in-os-x-10-10-yosemite/">An undocumented change to Captive Network Assistant settings in OS X 10.10 Yosemite</a>.</p>
- <h2>Certificate authorities</h2>
- <p>macOS comes with <a href="https://support.apple.com/en-us/HT202858">over 200</a> root authority certificates installed from for-profit corporations like Apple, Verisign, Thawte, Digicert and government agencies from China, Japan, Netherlands, U.S., and more! These Certificate Authorities (CAs) are capable of issuing SSL/TLS certificates for any domain, code signing certificates, etc.</p>
- <p>For more information, see <a href="https://github.com/kirei/catt">Certification Authority Trust Tracker</a>, <a href="http://conferences.sigcomm.org/imc/2013/papers/imc257-durumericAemb.pdf">Analysis of the HTTPS certificate ecosystem</a> (pdf), and <a href="http://www.ifca.ai/fc14/papers/fc14_submission_100.pdf">You Won’t Be Needing These Any More: On Removing Unused Certificates From Trust Stores</a> (pdf).</p>
- <p>You can inspect system root certificates in <strong>Keychain Access</strong>, under the <strong>System Roots</strong> tab or by using the <code>security</code> command line tool and <code>/System/Library/Keychains/SystemRootCertificates.keychain</code> file.</p>
- <p>You can disable certificate authorities through Keychain Access by marking them as <strong>Never Trust</strong> and closing the window:</p>
- <p><img width="450" alt="A certificate authority certificate" src="https://cloud.githubusercontent.com/assets/12475110/19222972/6b7aabac-8e32-11e6-8efe-5d3219575a98.png"></p>
- <p>The risk of a <a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack">man in the middle</a> attack in which a coerced or compromised certificate authority trusted by your system issues a fake/rogue SSL certificate is quite low, but still <a href="https://en.wikipedia.org/wiki/DigiNotar#Issuance_of_fraudulent_certificates">possible</a>.</p>
- <h2>OpenSSL</h2>
- <p>The version of OpenSSL in Sierra is <code>0.9.8zh</code> which is <a href="https://apple.stackexchange.com/questions/200582/why-is-apple-using-an-older-version-of-openssl">not current</a>. It doesn't support TLS 1.1 or newer, elliptic curve ciphers, and <a href="https://stackoverflow.com/questions/27502215/difference-between-openssl-09-8z-and-1-0-1">more</a>.</p>
- <p>Apple declares OpenSSL <strong>deprecated</strong> in their <a href="https://developer.apple.com/library/mac/documentation/Security/Conceptual/cryptoservices/GeneralPurposeCrypto/GeneralPurposeCrypto.html">Cryptographic Services Guide</a> document. Their version also has patches which may <a href="https://hynek.me/articles/apple-openssl-verification-surprises/">surprise you</a>.</p>
- <p>If you're going to use OpenSSL on your Mac, download and install a recent version of OpenSSL with <code>brew install openssl</code>. Note, linking brew to be used in favor of <code>/usr/bin/openssl</code> may interfere with building software. See <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/39">issue #39</a>.</p>
- <p>Compare the TLS protocol and cipher between the homebrew version and the system version of OpenSSL:</p>
- <p>```
- $ ~/homebrew/bin/openssl version; echo | ~/homebrew/bin openssl s_client -connect github.com:443 2>&1 | grep -A2 SSL-Session
- OpenSSL 1.0.2j 26 Sep 2016
- SSL-Session:
- Protocol : TLSv1.2
- Cipher : ECDHE-RSA-AES128-GCM-SHA256</p>
- <p>$ /usr/bin/openssl version; echo | /usr/bin/openssl s_client -connect github.com:443 2>&1 | grep -A2 SSL-Session
- OpenSSL 0.9.8zh 14 Jan 2016
- SSL-Session:
- Protocol : TLSv1
- Cipher : AES128-SHA
- ```</p>
- <p>See also <a href="https://en.wikipedia.org/wiki/Comparison_of_TLS_implementations">Comparison of TLS implementations</a>, <a href="https://www.howsmyssl.com/">How's My SSL</a>, <a href="https://www.ssllabs.com/projects/">Qualys SSL Labs Tools</a> and for detailed explanations and with latest vulnerabilities tests <a href="http://ssl-checker.online-domain-tools.com">ssl-checker.online-domain-tools.com</a>.</p>
- <h2>Curl</h2>
- <p>The version of Curl which comes with macOS uses <a href="https://developer.apple.com/library/mac/documentation/Security/Reference/secureTransportRef/">Secure Transport</a> for SSL/TLS validation.</p>
- <p>If you prefer to use OpenSSL, install with <code>brew install curl --with-openssl</code> and ensure it's the default with <code>brew link --force curl</code></p>
- <p>Here are several recommended <a href="http://curl.haxx.se/docs/manpage.html">options</a> to add to <code>~/.curlrc</code> (see <code>man curl</code> for more):</p>
- <p><code>user-agent = "Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0"
- referer = ";auto"
- connect-timeout = 10
- progress-bar
- max-time = 90
- verbose
- show-error
- remote-time
- ipv4</code></p>
- <h2>Web</h2>
- <h3>Privoxy</h3>
- <p>Consider using <a href="http://www.privoxy.org/">Privoxy</a> as a local proxy to filter Web browsing traffic.</p>
- <p>A signed installation package for privoxy can be downloaded from <a href="http://silvester.org.uk/privoxy/OSX/">silvester.org.uk</a> or <a href="http://sourceforge.net/projects/ijbswa/files/Macintosh%20%28OS%20X%29/">Sourceforge</a>. The signed package is <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/65">more secure</a> than the Homebrew version, and attracts full support from the Privoxy project.</p>
- <p>Alternatively, install and start privoxy using Homebrew:</p>
- <pre><code>$ brew install privoxy
-
- $ brew services start privoxy
- </code></pre>
- <p>By default, privoxy listens on local TCP port 8118.</p>
- <p>Set the system <strong>http</strong> proxy for your active network interface <code>127.0.0.1</code> and <code>8118</code> (This can be done through <strong>System Preferences > Network > Advanced > Proxies</strong>):</p>
- <pre><code>$ sudo networksetup -setwebproxy "Wi-Fi" 127.0.0.1 8118
- </code></pre>
- <p><strong>(Optional)</strong> Set the system <strong>https</strong> proxy, which still allows for domain name filtering, with:</p>
- <pre><code>$ sudo networksetup -setsecurewebproxy "Wi-Fi" 127.0.0.1 8118
- </code></pre>
- <p>Confirm the proxy is set:</p>
- <p><code>$ scutil --proxy
- <dictionary> {
- ExceptionsList : <array> {
- 0 : *.local
- 1 : 169.254/16
- }
- FTPPassive : 1
- HTTPEnable : 1
- HTTPPort : 8118
- HTTPProxy : 127.0.0.1
- }</code></p>
- <p>Visit <a href="http://p.p/">http://p.p/</a> in a browser, or with Curl:</p>
- <p><code>$ ALL_PROXY=127.0.0.1:8118 curl -I http://p.p/
- HTTP/1.1 200 OK
- Content-Length: 2401
- Content-Type: text/html
- Cache-Control: no-cache</code></p>
- <p>Privoxy already comes with many good rules, however you can also write your own.</p>
- <p>Edit <code>~/homebrew/etc/privoxy/user.action</code> to filter elements by domain or with regular expressions.</p>
- <p>Here are some examples:</p>
- <p>```
- { +block{social networking} }
- www.facebook.com/(extern|plugins)/(login_status|like(box)?|activity|fan).php
- .facebook.com</p>
- <p>{ +block{unwanted images} +handle-as-image }
- .com/ads/
- /.<em>1x1.gif
- /.</em>fb-icon.[jpg|gif|png]
- /assets/social-.<em>
- /cleardot.gif
- /img/social.</em>
- ads.<em>.co.</em>/
- ads.*.com/</p>
- <p>{ +redirect{s@http://@https://@} }
- .google.com
- .wikipedia.org
- code.jquery.com
- imgur.com
- ```</p>
- <p>Verify Privoxy is blocking and redirecting:</p>
- <p>```
- $ ALL_PROXY=127.0.0.1:8118 curl ads.foo.com/ -IL
- HTTP/1.1 403 Request blocked by Privoxy
- Content-Type: image/gif
- Content-Length: 64
- Cache-Control: no-cache</p>
- <p>$ ALL_PROXY=127.0.0.1:8118 curl imgur.com/ -IL
- HTTP/1.1 302 Local Redirect from Privoxy
- Location: https://imgur.com/
- Content-Length: 0
- Date: Sun, 09 Oct 2016 18:48:19 GMT</p>
- <p>HTTP/1.1 200 OK
- Content-Type: text/html; charset=utf-8
- ```</p>
- <p>You can replace ad images with pictures of kittens, for example, by starting the a local Web server and <a href="https://www.privoxy.org/user-manual/actions-file.html#SET-IMAGE-BLOCKER">redirecting blocked requests</a> to localhost.</p>
- <h3>Browser</h3>
- <p>The Web browser poses the largest security and privacy risk, as its fundamental job is to download and execute untrusted code from the Internet.</p>
- <p>Use <a href="https://www.google.com/chrome/browser/desktop/">Google Chrome</a> for most of your browsing. It offers <a href="https://www.chromium.org/user-experience/multi-profiles">separate profiles</a>, <a href="https://www.chromium.org/developers/design-documents/sandbox">good sandboxing</a>, <a href="http://googlechromereleases.blogspot.com/">frequent updates</a> (including Flash, although you should disable it - see below), and carries <a href="https://www.chromium.org/Home/chromium-security/brag-sheet">impressive credentials</a>.</p>
- <p>Chrome also comes with a great <a href="http://0xdabbad00.com/2013/01/13/most-secure-pdf-viewer-chrome-pdf-viewer/">PDF viewer</a>.</p>
- <p>If you don't want to use Chrome, <a href="https://www.mozilla.org/en-US/firefox/new/">Firefox</a> is an excellent browser as well. Or simply use both. See discussion in issues <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/2">#2</a>, <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/90">#90</a>.</p>
- <p>If using Firefox, see <a href="https://github.com/TheCreeper/PrivacyFox">TheCreeper/PrivacyFox</a> for recommended privacy preferences. Also be sure to check out <a href="https://noscript.net/">NoScript</a> for Mozilla-based browsers, which allows whitelist-based, pre-emptive script blocking.</p>
- <p>Create at least three profiles, one for browsing <strong>trusted</strong> Web sites (email, banking), another for <strong>mostly trusted</strong> Web sites (link aggregators, news sites), and a third for a completely <strong>cookie-less</strong> and <strong>script-less</strong> experience.</p>
- <ul>
- <li>
- <p>One profile <strong>without cookies or Javascript</strong> enabled (e.g., turned off in <code>chrome://settings/content</code>) which should be the preferred profile to visiting untrusted Web sites. However, many pages will not load at all without Javascript enabled.</p>
- </li>
- <li>
- <p>One profile with <a href="https://github.com/gorhill/uMatrix">uMatrix</a> or <a href="https://github.com/gorhill/uBlock">uBlock Origin</a> (or both). Use this profile for visiting <strong>mostly trusted</strong> Web sites. Take time to learn how these firewall extensions work. Other frequently recommended extensions are <a href="https://www.eff.org/privacybadger">Privacy Badger</a>, <a href="https://www.eff.org/https-everywhere">HTTPSEverywhere</a> and <a href="http://patrol.psyced.org/">CertPatrol</a> (Firefox only).</p>
- </li>
- <li>
- <p>One or more profile(s) for secure and trusted browsing needs, such as banking and email only.</p>
- </li>
- </ul>
- <p>The idea is to separate and compartmentalize data, so that an exploit or privacy violation in one "session" does not necessarily affect data in another.</p>
- <p>In each profile, visit <code>chrome://plugins/</code> and disable <strong>Adobe Flash Player</strong>. If you must use Flash, visit <code>chrome://settings/contents</code> to enable <strong>Let me choose when to run plugin content</strong>, under the Plugins section (also known as <em>click-to-play</em>).</p>
- <p>Take some time to read through <a href="https://www.chromium.org/Home/chromium-security">Chromium Security</a> and <a href="https://www.chromium.org/Home/chromium-privacy">Chromium Privacy</a>.</p>
- <p>For example you may wish to disable <a href="https://www.chromium.org/developers/design-documents/dns-prefetching">DNS prefetching</a> (see also <a href="https://www.usenix.org/legacy/event/leet10/tech/full_papers/Krishnan.pdf">DNS Prefetching and Its Privacy Implications</a> (pdf)).</p>
- <p>Also be aware of <a href="https://en.wikipedia.org/wiki/WebRTC#Concerns">WebRTC</a>, which may reveal your local or public (if connected to VPN) IP address(es). This can be disabled with extensions such as <a href="https://github.com/gorhill/uBlock/wiki/Prevent-WebRTC-from-leaking-local-IP-address">uBlock Origin</a> and <a href="https://github.com/rentamob/WebRTC-Leak-Prevent">rentamob/WebRTC-Leak-Prevent</a>.</p>
- <p>Many Chromium-derived browsers are not recommended. They are usually <a href="http://yro.slashdot.org/comments.pl?sid=4176879&cid=44774943">closed source</a>, <a href="https://plus.google.com/+JustinSchuh/posts/69qw9wZVH8z">poorly maintained</a>, <a href="https://code.google.com/p/google-security-research/issues/detail?id=679">have bugs</a>, and make dubious claims to protect privacy. See <a href="http://thesimplecomputer.info/the-private-life-of-chromium-browsers">The Private Life of Chromium Browsers</a>.</p>
- <p>Safari is not recommended. The code is a mess and <a href="https://nakedsecurity.sophos.com/2014/02/24/anatomy-of-a-goto-fail-apples-ssl-bug-explained-plus-an-unofficial-patch/">security</a> <a href="https://vimeo.com/144872861">vulnerabilities</a> are frequent, and slower to patch (see <a href="https://news.ycombinator.com/item?id=10150038">discussion on Hacker News</a>). Security does <a href="https://discussions.apple.com/thread/5128209">not appear</a> to be a priority for Safari. If you do use it, at least <a href="https://thoughtsviewsopinions.wordpress.com/2013/04/26/how-to-stop-downloaded-files-opening-automatically/">disable</a> the <strong>Open "safe" files after downloading</strong> option in Preferences, and be aware of other <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/93">privacy nuances</a>.</p>
- <p>Other miscellaneous browsers, such as <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/94">Brave</a>, are not evaluated in this guide, so are neither recommended nor actively discouraged from use.</p>
- <p>For more information about security conscious browsing, see <a href="https://gist.github.com/atcuno/3425484ac5cce5298932">HowTo: Privacy & Security Conscious Browsing</a>, <a href="https://www.browserleaks.com/">browserleaks.com</a> and <a href="https://panopticlick.eff.org/">EFF Panopticlick</a>.</p>
- <h3>Plugins</h3>
- <p><strong>Adobe Flash</strong>, <strong>Oracle Java</strong>, <strong>Adobe Reader</strong>, <strong>Microsoft Silverlight</strong> (Netflix now works with <a href="https://help.netflix.com/en/node/23742">HTML5</a>) and other plugins are <a href="https://news.ycombinator.com/item?id=9901480">security risks</a> and should not be installed.</p>
- <p>If they are necessary, only use them in a disposable virtual machine and subscribe to security announcements to make sure you're always patched.</p>
- <p>See <a href="http://blog.trendmicro.com/trendlabs-security-intelligence/hacking-team-flash-zero-day-integrated-into-exploit-kits/">Hacking Team Flash Zero-Day</a>, <a href="https://en.wikipedia.org/wiki/Trojan_BackDoor.Flashback">Java Trojan BackDoor.Flashback</a>, <a href="http://www.cvedetails.com/vulnerability-list/vendor_id-53/product_id-497/Adobe-Acrobat-Reader.html">Acrobat Reader: Security Vulnerabilities</a>, and <a href="https://blogs.cisco.com/security/angling-for-silverlight-exploits">Angling for Silverlight Exploits</a>, for example.</p>
- <h2>PGP/GPG</h2>
- <p>PGP is a standard for encrypting email end to end. That means only the chosen recipients can decrypt a message, unlike regular email which is read and forever archived by providers.</p>
- <p><strong>GPG</strong>, or <strong>GNU Privacy Guard</strong>, is a GPL licensed program compliant with the standard.</p>
- <p><strong>GPG</strong> is used to verify signatures of software you download and install, as well as <a href="https://en.wikipedia.org/wiki/Symmetric-key_algorithm">symmetrically</a> or <a href="https://en.wikipedia.org/wiki/Public-key_cryptography">asymmetrically</a> encrypt files and text.</p>
- <p>Install from Homebrew with <code>brew install gnupg2</code>.</p>
- <p>If you prefer a graphical application, download and install <a href="https://gpgtools.org/">GPG Suite</a>.</p>
- <p>Here are several <a href="https://github.com/drduh/config/blob/master/gpg.conf">recommended options</a> to add to <code>~/.gnupg/gpg.conf</code>:</p>
- <p><code>auto-key-locate keyserver
- keyserver hkps://hkps.pool.sks-keyservers.net
- keyserver-options no-honor-keyserver-url
- keyserver-options ca-cert-file=/etc/sks-keyservers.netCA.pem
- keyserver-options no-honor-keyserver-url
- keyserver-options debug
- keyserver-options verbose
- personal-cipher-preferences AES256 AES192 AES CAST5
- personal-digest-preferences SHA512 SHA384 SHA256 SHA224
- default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
- cert-digest-algo SHA512
- s2k-digest-algo SHA512
- s2k-cipher-algo AES256
- charset utf-8
- fixed-list-mode
- no-comments
- no-emit-version
- keyid-format 0xlong
- list-options show-uid-validity
- verify-options show-uid-validity
- with-fingerprint</code></p>
- <p>Install the keyservers <a href="https://sks-keyservers.net/verify_tls.php">CA certificate</a>:</p>
- <pre><code>$ curl -O https://sks-keyservers.net/sks-keyservers.netCA.pem
-
- $ sudo mv sks-keyservers.netCA.pem /etc
- </code></pre>
- <p>These settings will configure GnuPG to use SSL when fetching new keys and prefer strong cryptographic primitives.</p>
- <p>See also <a href="https://github.com/ioerror/duraconf/blob/master/configs/gnupg/gpg.conf">ioerror/duraconf/configs/gnupg/gpg.conf</a>. You should also take some time to read <a href="https://help.riseup.net/en/security/message-security/openpgp/best-practices">OpenPGP Best Practices</a>.</p>
- <p>If you don't already have a keypair, create one using <code>gpg --gen-key</code>. Also see <a href="https://github.com/drduh/YubiKey-Guide">drduh/YubiKey-Guide</a>.</p>
- <p>Read <a href="https://alexcabal.com/creating-the-perfect-gpg-keypair/">online</a> <a href="https://security.stackexchange.com/questions/31594/what-is-a-good-general-purpose-gnupg-key-setup">guides</a> and practice encrypting and decrypting email to yourself and your friends. Get them interested in this stuff!</p>
- <h2>OTR</h2>
- <p>OTR stands for <strong>off-the-record</strong> and is a cryptographic protocol for encrypting and authenticating conversations over instant messaging.</p>
- <p>You can use OTR on top of any existing <a href="https://xmpp.org/about">XMPP</a> chat service, even Google Hangouts (which only encrypts conversations between users and the server using TLS).</p>
- <p>The first time you start a conversation with someone new, you'll be asked to verify their public key fingerprint. Make sure to do this in person or by some other secure means (e.g. GPG encrypted mail).</p>
- <p>A popular macOS GUI client for XMPP and other chat protocols is <a href="https://adium.im/">Adium</a></p>
- <p>Consider downloading the <a href="https://beta.adium.im/">beta version</a> which uses OAuth2, making logging in to Google accounts <a href="https://adium.im/blog/2015/04/">more</a> <a href="https://trac.adium.im/ticket/16161">secure</a>.</p>
- <p><code>Adium_1.5.11b3.dmg
- SHA-256: 999e1931a52dc327b3a6e8492ffa9df724a837c88ad9637a501be2e3b6710078
- SHA-1: ca804389412f9aeb7971ade6812f33ac739140e6</code></p>
- <p>Remember to <a href="https://trac.adium.im/ticket/15722">disable logging</a> for OTR chats with Adium.</p>
- <p>A good console-based XMPP client is <a href="http://www.profanity.im/">profanity</a>, which can be installed with <code>brew install profanity</code></p>
- <p>For improved anonymity, check out <a href="https://blog.torproject.org/blog/tor-messenger-beta-chat-over-tor-easily">Tor Messenger</a>, although it is still in beta, as well as <a href="https://ricochet.im/">Ricochet</a> (which has recently received a thorough <a href="https://ricochet.im/files/ricochet-ncc-audit-2016-01.pdf">security audit</a> (pdf)), which both use the Tor network rather than relying on messaging servers.</p>
- <p>If you want to know how OTR works, read the paper <a href="https://otr.cypherpunks.ca/otr-wpes.pdf">Off-the-Record Communication, or, Why Not To Use PGP</a> (pdf)</p>
- <h2>Tor</h2>
- <p>Tor is an anonymizing proxy which can be used for browsing the Web.</p>
- <p>Download Tor Browser from the <a href="https://www.torproject.org/projects/torbrowser.html">offical Tor Project Web site</a>.</p>
- <p>Do <strong>not</strong> attempt to configure other browsers or applications to use Tor as you will likely make a mistake which will compromise your anonymity.</p>
- <p>Download both the <code>dmg</code> and <code>asc</code> signature files, then verify the disk image has been signed by Tor developers:</p>
- <p>```
- $ cd Downloads</p>
- <p>$ file Tor*
- TorBrowser-6.0.5-osx64_en-US.dmg: bzip2 compressed data, block size = 900k
- TorBrowser-6.0.5-osx64_en-US.dmg.asc: PGP signature Signature (old)</p>
- <p>$ gpg Tor*asc
- gpg: assuming signed data in `TorBrowser-6.0.5-osx64_en-US.dmg'
- gpg: Signature made Fri Sep 16 07:51:52 2016 EDT using RSA key ID D40814E0
- gpg: Can't check signature: public key not found</p>
- <p>$ gpg --recv 0xD40814E0
- gpg: requesting key D40814E0 from hkp server keys.gnupg.net
- gpg: key 93298290: public key "Tor Browser Developers (signing key) <a href="mailto:torbrowser@torproject.org">torbrowser@torproject.org</a>" imported
- gpg: no ultimately trusted keys found
- gpg: Total number processed: 1
- gpg: imported: 1 (RSA: 1)</p>
- <p>$ gpg Tor*asc
- gpg: assuming signed data in 'TorBrowser-6.0.5-osx64_en-US.dmg'
- gpg: Signature made Fri Sep 16 07:51:52 2016 EDT using RSA key ID D40814E0
- gpg: Good signature from "Tor Browser Developers (signing key) <a href="mailto:torbrowser@torproject.org">torbrowser@torproject.org</a>" [unknown]
- gpg: WARNING: This key is not certified with a trusted signature!
- gpg: There is no indication that the signature belongs to the owner.
- Primary key fingerprint: EF6E 286D DA85 EA2A 4BA7 DE68 4E2C 6E87 9329 8290
- Subkey fingerprint: BA1E E421 BBB4 5263 180E 1FC7 2E1A C68E D408 14E0
- ```</p>
- <p>Make sure <code>Good signature from "Tor Browser Developers (signing key) <torbrowser@torproject.org>"</code> appears in the output. The warning about the key not being certified is benign, as it has not yet been manually assigned trust.</p>
- <p>See <a href="https://www.torproject.org/docs/verifying-signatures.html">How to verify signatures for packages</a> for more information.</p>
- <p>To finish installing Tor Browser, open the disk image and drag the it into the Applications folder, or with:</p>
- <p>```
- $ hdiutil mount TorBrowser-6.0.5-osx64_en-US.dmg</p>
- <p>$ cp -rv /Volumes/Tor\ Browser/TorBrowser.app /Applications
- ```</p>
- <p>It is also possible to verify the Tor application's code signature was made by with The Tor Project's Apple developer ID <strong>MADPSAYN6T</strong>:</p>
- <p><code>$ codesign -dvv /Applications/TorBrowser.app
- Executable=/Applications/TorBrowser.app/Contents/MacOS/firefox
- Identifier=org.mozilla.tor browser
- Format=app bundle with Mach-O thin (x86_64)
- CodeDirectory v=20200 size=247 flags=0x0(none) hashes=5+3 location=embedded
- Library validation warning=OS X SDK version before 10.9 does not support Library Validation
- Signature size=4247
- Authority=Developer ID Application: The Tor Project, Inc (MADPSAYN6T)
- Authority=Developer ID Certification Authority
- Authority=Apple Root CA
- Signed Time=Nov 30, 2016, 10:40:34 AM
- Info.plist entries=21
- TeamIdentifier=MADPSAYN6T
- Sealed Resources version=2 rules=12 files=130
- Internal requirements count=1 size=184</code></p>
- <p>To view certificate details, extract it with <code>codesign</code> and decode it with <code>openssl</code>:</p>
- <p>```
- $ codesign -d --extract-certificates /Applications/TorBrowser.app
- Executable=/Applications/TorBrowser.app/Contents/MacOS/firefox</p>
- <p>$ file codesign*
- codesign0: data
- codesign1: data
- codesign2: data</p>
- <p>$ openssl x509 -inform der -in codesign0 -subject -issuer -startdate -enddate -noout
- subject= /UID=MADPSAYN6T/CN=Developer ID Application: The Tor Project, Inc (MADPSAYN6T)/OU=MADPSAYN6T/O=The Tor Project, Inc/C=US
- issuer= /CN=Developer ID Certification Authority/OU=Apple Certification Authority/O=Apple Inc./C=US
- notBefore=Apr 12 22:40:13 2016 GMT
- notAfter=Apr 13 22:40:13 2021 GMT</p>
- <p>$ openssl x509 -inform der -in codesign0 -fingerprint -noout
- SHA1 Fingerprint=95:80:54:F1:54:66:F3:9C:C2:D8:27:7A:29:21:D9:61:11:93:B3:E8</p>
- <p>$ openssl x509 -inform der -in codesign0 -fingerprint -sha256 -noout
- SHA256 Fingerprint=B5:0D:47:F0:3E:CB:42:B6:68:1C:6F:38:06:2B:C2:9F:41:FA:D6:54:F1:29:D3:E4:DD:9C:C7:49:35:FF:F5:D9
- ```</p>
- <p>Tor traffic is <strong>encrypted</strong> to the <a href="https://en.wikipedia.org/wiki/Tor_(anonymity_network)#Exit_node_eavesdropping">exit node</a> (i.e., cannot be read by a passive network eavesdropper), but Tor use <strong>can</strong> be identified - for example, TLS handshake "hostnames" will show up in plaintext:</p>
- <p><code>$ sudo tcpdump -An "tcp" | grep "www"
- listening on pktap, link-type PKTAP (Apple DLT_PKTAP), capture size 262144 bytes
- .............". ...www.odezz26nvv7jeqz1xghzs.com.........
- .............#.!...www.bxbko3qi7vacgwyk4ggulh.com.........
- .6....m.....>...:.........|../* Z....W....X=..6...C../....................................0...0..0.......'....F./0.. *.H........0%1#0!..U....www.b6zazzahl3h3faf4x2.com0...160402000000Z..170317000000Z0'1%0#..U....www.tm3ddrghe22wgqna5u8g.net0..0..</code></p>
- <p>See <a href="https://gitweb.torproject.org/torspec.git/tree/tor-spec.txt">Tor Protocol Specification</a> and <a href="https://trac.torproject.org/projects/tor/wiki/org/projects/Tor/TLSHistory">Tor/TLSHistory</a> for more information.</p>
- <p>You may wish to additionally obfuscate Tor traffic using a <a href="https://www.torproject.org/docs/pluggable-transports.html">pluggable transport</a>, such as <a href="https://github.com/Yawning/obfs4">Yawning/obfs4proxy</a> or <a href="https://github.com/SRI-CSL/stegotorus">SRI-CSL/stegotorus</a>.</p>
- <p>This can be done by setting up your own <a href="https://www.torproject.org/docs/tor-relay-debian.html">Tor relay</a> or finding an existing private or public <a href="https://www.torproject.org/docs/bridges.html.en#RunningABridge">bridge</a> to serve as an obfuscating entry node.</p>
- <p>For extra security, use Tor inside a <a href="https://www.virtualbox.org/wiki/Downloads">VirtualBox</a> or <a href="https://www.vmware.com/products/fusion">VMware</a> virtualized <a href="http://www.brianlinkletter.com/installing-debian-linux-in-a-virtualbox-virtual-machine/">GNU/Linux</a> or <a href="http://www.openbsd.org/faq/faq4.html">BSD</a> machine.</p>
- <p>Finally, remember the Tor network provides <a href="https://www.privateinternetaccess.com/blog/2013/10/how-does-privacy-differ-from-anonymity-and-why-are-both-important/">anonymity</a>, which is not necessarily synonymous with privacy. The Tor network does not guarantee protection against a global observer capable of traffic analysis and <a href="https://blog.torproject.org/category/tags/traffic-correlation">correlation</a>. See also <a href="http://bford.info/pub/net/panopticon-cacm.pdf">Seeking Anonymity in an Internet Panopticon</a> (pdf) and <a href="http://www.ohmygodel.com/publications/usersrouted-ccs13.pdf">Traffic Correlation on Tor by Realistic Adversaries</a> (pdf).</p>
- <p>Also see <a href="https://geti2p.net/en/about/intro">Invisible Internet Project (I2P)</a> and its <a href="https://geti2p.net/en/comparison/tor">Tor comparison</a>.</p>
- <h2>VPN</h2>
- <p>If you use your Mac on untrusted networks - airports, cafes, etc. - your network traffic is being monitored and possibly tampered with.</p>
- <p>It is a good idea to use a VPN which encrypts <strong>all</strong> outgoing network traffic (i.e., not <strong>split tunnel</strong>) with a provider you trust. For an example of how to set up and host your own VPN, see <a href="https://github.com/drduh/Debian-Privacy-Server-Guide">drduh/Debian-Privacy-Server-Guide</a>.</p>
- <p>Don't just blindly sign up for a VPN service without understanding the full implications and how your traffic will be routed. If you don't understand how the VPN works or are not familiar with the software used, you are probably better off without it.</p>
- <p>When choosing a VPN service or setting up your own, be sure to research the protocols, key exchange algorithms, authentication mechanisms, and type of encryption being used. Some protocols, such as <a href="https://en.wikipedia.org/wiki/Point-to-Point_Tunneling_Protocol#Security">PPTP</a>, should be avoided in favor of <a href="https://en.wikipedia.org/wiki/OpenVPN">OpenVPN</a>, for example.</p>
- <p>Some clients may send traffic over the next available interface when VPN is interrupted or disconnected. See <a href="https://gist.github.com/scy/8122924">scy/8122924</a> for an example on how to allow traffic only over VPN.</p>
- <p>Another set of scripts to lock down your system so it will only access the internet via a VPN can be found as part of the Voodoo Privacy project - <a href="https://github.com/sarfata/voodooprivacy">sarfata/voodooprivacy</a> and there is an updated guide to setting up an IPSec VPN on a virtual machine (<a href="https://github.com/hwdsl2/setup-ipsec-vpn">hwdsl2/setup-ipsec-vpn</a>) or a docker container (<a href="https://github.com/hwdsl2/docker-ipsec-vpn-server">hwdsl2/docker-ipsec-vpn-server</a>).</p>
- <h2>Viruses and malware</h2>
- <p>There is an <a href="https://www.documentcloud.org/documents/2459197-bit9-carbon-black-threat-research-report-2015.html">ever-increasing</a> amount of Mac malware in the wild. Macs aren't immune from viruses and malicious software!</p>
- <p>Some malware comes bundled with both legitimate software, such as the <a href="http://www.zdnet.com/article/oracle-extends-its-adware-bundling-to-include-java-for-macs/">Java bundling Ask Toolbar</a>, and some with illegitimate software, such as <a href="https://docs.google.com/document/d/1YOfXRUQJgMjJSLBSoLiUaSZfiaS_vU3aG4Bvjmz6Dxs/edit?pli=1">Mac.BackDoor.iWorm</a> bundled with pirated programs. <a href="https://www.malwarebytes.com/antimalware/mac/">Malwarebytes Anti-Malware for Mac</a> is an excellent program for ridding oneself of "garden-variety" malware and other "crapware".</p>
- <p>See <a href="https://www.virusbtn.com/pdf/conference/vb2014/VB2014-Wardle.pdf">Methods of malware persistence on Mac OS X</a> (pdf) and <a href="https://www.rsaconference.com/events/us15/agenda/sessions/1591/malware-persistence-on-os-x-yosemite">Malware Persistence on OS X Yosemite</a> to learn about how garden-variety malware functions.</p>
- <p>You could periodically run a tool like <a href="https://github.com/synack/knockknock">Knock Knock</a> to examine persistent applications (e.g. scripts, binaries). But by then, it is probably too late. Maybe applications such as <a href="https://objective-see.com/products/blockblock.html">Block Block</a> and <a href="https://objective-see.com/products/ostiarius.html">Ostiarius</a> will help. See warnings and caveats in <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/90">issue #90</a> first, however. Using an application such as <a href="https://www.littleflocker.com/">Little Flocker</a> can also protect parts of the filesystem from unauthorized writes similar to how Little Snitch protects the network (note, however, the software is still in beta and should be <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/pull/128">used with caution</a>).</p>
- <p><strong>Anti-virus</strong> programs are a double-edged sword -- not useful for <strong>advanced</strong> users and will likely increase attack surface against sophisticated threats, however possibly useful for catching "garden variety" malware on <strong>novice</strong> users' Macs. There is also the additional processing overhead to consider.</p>
- <p>See <a href="https://lock.cmpxchg8b.com/sophailv2.pdf">Sophail: Applied attacks against Antivirus</a> (pdf), <a href="http://googleprojectzero.blogspot.ro/2015/06/analysis-and-exploitation-of-eset.html">Analysis and Exploitation of an ESET Vulnerability</a>, <a href="https://code.google.com/p/google-security-research/issues/detail?id=546">a trivial Avast RCE</a>, <a href="https://theintercept.com/2015/06/22/nsa-gchq-targeted-kaspersky/">Popular Security Software Came Under Relentless NSA and GCHQ Attacks</a>, and <a href="https://code.google.com/p/google-security-research/issues/detail?id=675">AVG: "Web TuneUP" extension multiple critical vulnerabilities</a>.</p>
- <p>Therefore, the best anti-virus is <strong>Common Sense 2016</strong>. See more discussion in <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/44">issue #44</a>.</p>
- <p>Local privilege escalation bugs are plenty on macOS, so always be careful when downloading and running untrusted programs or trusted programs from third party websites or downloaded over HTTP (<a href="http://arstechnica.com/security/2015/08/0-day-bug-in-fully-patched-os-x-comes-under-active-exploit-to-hijack-macs/">example</a>).</p>
- <p>Have a look at <a href="http://www.thesafemac.com/">The Safe Mac</a> for past and current Mac security news.</p>
- <p>Also check out <a href="https://www.schneier.com/blog/archives/2015/07/hacking_team_is.html">Hacking Team</a> malware for Mac OS: <a href="https://github.com/hackedteam/vector-macos-root">root installation for MacOS</a>, <a href="https://github.com/hackedteam/driver-macos">Support driver for Mac Agent</a> and <a href="https://github.com/hackedteam/core-macos">RCS Agent for Mac</a>, which is a good example of advanced malware with capabilities to hide from <strong>userland</strong> (e.g., <code>ps</code>, <code>ls</code>), for example. For more, see <a href="https://objective-see.com/blog/blog_0x0D.html">A Brief Analysis of an RCS Implant Installer</a> and <a href="https://reverse.put.as/2016/02/29/the-italian-morons-are-back-what-are-they-up-to-this-time/">reverse.put.as</a></p>
- <h2>System Integrity Protection</h2>
- <p><a href="https://support.apple.com/en-us/HT204899">System Integrity Protection</a> (SIP) is a security feature since OS X 10.11 "El Capitan". It is enabled by default, but <a href="https://derflounder.wordpress.com/2015/10/01/system-integrity-protection-adding-another-layer-to-apples-security-model/">can be disabled</a>, which may be necessary to change some system settings, such as deleting root certificate authorities or unloading certain launch daemons. Keep this feature on, as it is by default.</p>
- <p>From <a href="https://developer.apple.com/library/prerelease/mac/releasenotes/MacOSX/WhatsNewInOSX/Articles/MacOSX10_11.html">What's New in OS X 10.11</a>:</p>
- <blockquote>
- <p>A new security policy that applies to every running process, including privileged code and code that runs out of the sandbox. The policy extends additional protections to components on disk and at run-time, only allowing system binaries to be modified by the system installer and software updates. Code injection and runtime attachments to system binaries are no longer permitted.</p>
- </blockquote>
- <p>Also see <a href="https://apple.stackexchange.com/questions/193368/what-is-the-rootless-feature-in-el-capitan-really">What is the “rootless” feature in El Capitan, really?</a></p>
- <p>Some MacBook hardware has shipped with <a href="http://appleinsider.com/articles/16/11/17/system-integrity-protection-disabled-by-default-on-some-touch-bar-macbook-pros">SIP disabled</a>. To verify SIP is enabled, use the command <code>csrutil status</code>, which should return: <code>System Integrity Protection status: enabled.</code> Otherwise, <a href="https://developer.apple.com/library/content/documentation/Security/Conceptual/System_Integrity_Protection_Guide/ConfiguringSystemIntegrityProtection/ConfiguringSystemIntegrityProtection.html">enable SIP</a> through Recovery Mode.</p>
- <h2>Gatekeeper and XProtect</h2>
- <p><strong>Gatekeeper</strong> and the <strong>quarantine</strong> system try to prevent unsigned or "bad" programs and files from running and opening.</p>
- <p><strong>XProtect</strong> prevents the execution of known bad files and outdated plugin versions, but does nothing to cleanup or stop existing malware.</p>
- <p>Both offer trivial protection against common risks and are fine at default settings.</p>
- <p>See also <a href="http://www.thesafemac.com/mmg-builtin/">Mac Malware Guide : How does Mac OS X protect me?</a> and <a href="http://ilostmynotes.blogspot.com/2012/06/gatekeeper-xprotect-and-quarantine.html">Gatekeeper, XProtect and the Quarantine attribute</a>.</p>
- <p><strong>Note</strong> Quarantine stores information about downloaded files in <code>~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2</code>, which may pose a privacy risk. To examine the file, simply use <code>strings</code> or the following command:</p>
- <pre><code>$ echo 'SELECT datetime(LSQuarantineTimeStamp + 978307200, "unixepoch") as LSQuarantineTimeStamp, LSQuarantineAgentName, LSQuarantineOriginURLString, LSQuarantineDataURLString from LSQuarantineEvent;' | sqlite3 /Users/$USER/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2
- </code></pre>
- <p>See <a href="http://www.zoharbabin.com/hey-mac-i-dont-appreciate-you-spying-on-me-hidden-downloads-log-in-os-x/">here</a> for more information.</p>
- <p>To permanently disable this feature, <a href="https://superuser.com/questions/90008/how-to-clear-the-contents-of-a-file-from-the-command-line">clear the file</a> and <a href="http://hints.macworld.com/article.php?story=20031017061722471">make it immutable</a>:</p>
- <pre><code>$ :>~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2
- $ sudo chflags schg ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV2
- </code></pre>
- <p>Furthermore, macOS attaches metadata (<a href="https://en.wikipedia.org/wiki/Extended_file_attributes#OS_X">HFS+ extended attributes</a>) to downloaded files:</p>
- <p>```
- $ ls -l@ ~/Downloads/TorBrowser-6.0.5-osx64_en-US.dmg
- -rw-r--r--@ 1 drduh staff 59322237 Oct 9 15:20 TorBrowser-6.0.5-osx64_en-US.dmg
- com.apple.metadata:kMDItemWhereFroms 186
- com.apple.quarantine 68</p>
- <p>$ xattr -l ~/Downloads/TorBrowser-6.0.5-osx64_en-US.dmg
- com.apple.metadata:kMDItemWhereFroms:
- 00000000 62 70 6C 69 73 74 30 30 A2 01 02 5F 10 4D 68 74 |bplist00...<em>.Mht|
- 00000010 74 70 73 3A 2F 2F 64 69 73 74 2E 74 6F 72 70 72 |tps://dist.torpr|
- 00000020 6F 6A 65 63 74 2E 6F 72 67 2F 74 6F 72 62 72 6F |oject.org/torbro|
- 00000030 77 73 65 72 2F 36 2E 30 2E 35 2F 54 6F 72 42 72 |wser/6.0.5/TorBr|
- 00000040 6F 77 73 65 72 2D 36 2E 30 2E 35 2D 6F 73 78 36 |owser-6.0.5-osx6|
- 00000050 34 5F 65 6E 2D 55 53 2E 64 6D 67 5F 10 39 68 74 |4_en-US.dmg</em>.9ht|
- 00000060 74 70 73 3A 2F 2F 77 77 77 2E 74 6F 72 70 72 6F |tps://www.torpro|
- 00000070 6A 65 63 74 2E 6F 72 67 2F 64 6F 77 6E 6C 6F 61 |ject.org/downloa|
- 00000080 64 2F 64 6F 77 6E 6C 6F 61 64 2D 65 61 73 79 2E |d/download-easy.|
- 00000090 68 74 6D 6C 2E 65 6E 08 0B 5B 00 00 00 00 00 00 |html.en..[......|
- 000000A0 01 01 00 00 00 00 00 00 00 03 00 00 00 00 00 00 |................|
- 000000B0 00 00 00 00 00 00 00 00 00 97 |..........|
- 000000ba
- com.apple.quarantine: 0081;52fb9173;Google Chrome.app;3AB6D46E-4AC5-3C3E-B427-32C7F804AAA3</p>
- <p>$ xattr -d com.apple.metadata:kMDItemWhereFroms ~/Downloads/TorBrowser-6.0.5-osx64_en-US.dmg</p>
- <p>$ xattr -d com.apple.quarantine ~/Downloads/TorBrowser-6.0.5-osx64_en-US.dmg</p>
- <p>$ xattr -l ~/Downloads/TorBrowser-6.0.5-osx64_en-US.dmg
- [No output after removal.]
- ```</p>
- <h2>Passwords</h2>
- <p>You can generate strong passwords with OpenSSL:</p>
- <pre><code>$ openssl rand -base64 30
- LK9xkjUEAemc1gV2Ux5xqku+PDmMmCbSTmwfiMRI
- </code></pre>
- <p>Or GPG:</p>
- <pre><code>$ gpg --gen-random -a 0 30
- 4/bGZL+yUEe8fOqQhF5V01HpGwFSpUPwFcU3aOWQ
- </code></pre>
- <p>Or <code>/dev/urandom</code> output:</p>
- <pre><code>$ dd if=/dev/urandom bs=1 count=30 2>/dev/null | base64
- CbRGKASFI4eTa96NMrgyamj8dLZdFYBaqtWUSxKe
- </code></pre>
- <p>With control over character sets:</p>
- <pre><code>$ LANG=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 40 | head -n 1
- jm0iKn7ngQST8I0mMMCbbi6SKPcoUWwCb5lWEjxK
-
- $ LANG=C tr -dc 'DrDuh0-9' < /dev/urandom | fold -w 40 | head -n 1
- 686672u2Dh7r754209uD312hhh23uD7u41h3875D
- </code></pre>
- <p>You can also generate passwords, even memorable ones, using <strong>Keychain Access</strong> password assistant, or a command line equivalent like <a href="https://github.com/anders/pwgen">anders/pwgen</a>.</p>
- <p>Keychains are encrypted with a <a href="https://en.wikipedia.org/wiki/PBKDF2">PBKDF2 derived key</a> and are a <em>pretty safe</em> place to store credentials. See also <a href="http://juusosalonen.com/post/30923743427/breaking-into-the-os-x-keychain">Breaking into the OS X keychain</a>. Also be aware that Keychain <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide/issues/118">does not encrypt</a> the names corresponding to password entries.</p>
- <p>Alternatively, you can manage an encrypted passwords file yourself with GnuPG (shameless plug for my <a href="https://github.com/drduh/pwd.sh">drduh/pwd.sh</a> password manager script).</p>
- <p>In addition to passwords, ensure eligible online accounts, such as GitHub, Google accounts, banking, have <a href="https://en.wikipedia.org/wiki/Two-factor_authentication">two factor authentication</a> enabled.</p>
- <p>Look to <a href="https://www.yubico.com/products/yubikey-hardware/yubikey-neo/">Yubikey</a> for a two factor and private key (e.g., ssh, gpg) hardware token. See <a href="https://github.com/drduh/YubiKey-Guide">drduh/YubiKey-Guide</a> and <a href="https://trmm.net/Yubikey">trmm.net/Yubikey</a>. One of two Yubikey's slots can also be programmed to emit a long, static password (which can be used in combination with a short, memorized password, for example).</p>
- <h2>Backup</h2>
- <p>Always encrypt files locally before backing them up to external media or online services.</p>
- <p>One way is to use a symmetric cipher with GPG and a password of your choosing.</p>
- <p>To encrypt a directory:</p>
- <pre><code>$ tar zcvf - ~/Downloads | gpg -c > ~/Desktop/backup-$(date +%F-%H%M).tar.gz.gpg
- </code></pre>
- <p>To decrypt an archive:</p>
- <pre><code>$ gpg -o ~/Desktop/decrypted-backup.tar.gz -d ~/Desktop/backup-2015-01-01-0000.tar.gz.gpg && \
- tar zxvf ~/Desktop/decrypted-backup.tar.gz
- </code></pre>
- <p>You may also create encrypted volumes using <strong>Disk Utility</strong> or <code>hdiutil</code>:</p>
- <pre><code>$ hdiutil create ~/Desktop/encrypted.dmg -encryption -size 1g -volname "Name" -fs JHFS+
- </code></pre>
- <p>Also see the following applications and services: <a href="https://spideroak.com/">SpiderOak</a>, <a href="https://www.arqbackup.com/">Arq</a>, <a href="https://www.espionageapp.com/">Espionage</a>, and <a href="https://restic.github.io/">restic</a>.</p>
- <h2>Wi-Fi</h2>
- <p>macOS remembers access points it has connected to. Like all wireless devices, the Mac will broadcast all access point names it remembers (e.g., <em>MyHomeNetwork</em>) each time it looks for a network, such as when waking from sleep.</p>
- <p>This is a privacy risk, so remove networks from the list in <strong>System Preferences</strong> > <strong>Network</strong> > <strong>Advanced</strong> when they're no longer needed.</p>
- <p>Also see <a href="http://conferences.sigcomm.org/imc/2013/papers/imc148-barberaSP106.pdf">Signals from the Crowd: Uncovering Social Relationships through Smartphone Probes</a> (pdf) and <a href="http://confiance-numerique.clermont-universite.fr/Slides/M-Cunche-2014.pdf">Wi-Fi told me everything about you</a> (pdf).</p>
- <p>Saved Wi-Fi information (SSID, last connection, etc.) can be found in <code>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist</code></p>
- <p>You may wish to <a href="https://en.wikipedia.org/wiki/MAC_spoofing">spoof the MAC address</a> of your network card before connecting to new and untrusted wireless networks to mitigate passive fingerprinting:</p>
- <pre><code>$ sudo ifconfig en0 ether $(openssl rand -hex 6 | sed 's%\(..\)%\1:%g; s%.$%%')
- </code></pre>
- <p><strong>Note</strong> MAC addresses will reset to hardware defaults on each boot.</p>
- <p>Also see <a href="https://github.com/feross/SpoofMAC">feross/SpoofMAC</a>.</p>
- <p>Finally, WEP protection on wireless networks is <a href="http://www.howtogeek.com/167783/htg-explains-the-difference-between-wep-wpa-and-wpa2-wireless-encryption-and-why-it-matters/">not secure</a> and you should favor connecting to <strong>WPA2</strong> protected networks only to mitigate the risk of passive eavesdroppers.</p>
- <h2>SSH</h2>
- <p>For outgoing ssh connections, use hardware- or password-protected keys, <a href="http://nerderati.com/2011/03/17/simplify-your-life-with-an-ssh-config-file/">set up</a> remote hosts and consider <a href="http://nms.csail.mit.edu/projects/ssh/">hashing</a> them for added privacy.</p>
- <p>Here are several recommended <a href="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">options</a> to add to <code>~/.ssh/config</code>:</p>
- <pre><code>Host *
- PasswordAuthentication no
- ChallengeResponseAuthentication no
- HashKnownHosts yes
- </code></pre>
- <p><strong>Note</strong> <a href="https://openradar.appspot.com/28394826">macOS Sierra permanently remembers SSH key passphrases by default</a>. Append the option <code>UseKeyChain no</code> to turn this feature off.</p>
- <p>You can also use ssh to create an <a href="http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html">encrypted tunnel</a> to send your traffic through, which is similar to a VPN.</p>
- <p>For example, to use Privoxy on a remote host:</p>
- <pre><code>$ ssh -C -L 5555:127.0.0.1:8118 you@remote-host.tld
-
- $ sudo networksetup -setwebproxy "Wi-Fi" 127.0.0.1 5555
-
- $ sudo networksetup -setsecurewebproxy "Wi-Fi" 127.0.0.1 5555
- </code></pre>
- <p>Or to use an ssh connection as a <a href="https://www.mikeash.com/ssh_socks.html">SOCKS proxy</a>:</p>
- <pre><code>$ ssh -NCD 3000 you@remote-host.tld
- </code></pre>
- <p>By default, macOS does <strong>not</strong> have sshd or <em>Remote Login</em> enabled.</p>
- <p>To enable sshd and allow incoming ssh connections:</p>
- <pre><code>$ sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
- </code></pre>
- <p>Or use the <strong>System Preferences</strong> > <strong>Sharing</strong> menu.</p>
- <p>If you are going to enable sshd, at least disable password authentication and consider further <a href="https://stribika.github.io/2015/01/04/secure-secure-shell.html">hardening</a> your configuration.</p>
- <p>To <code>/etc/sshd_config</code>, add:</p>
- <p><code>PasswordAuthentication no
- ChallengeResponseAuthentication no
- UsePAM no</code></p>
- <p>Confirm whether sshd is enabled or disabled:</p>
- <pre><code>$ sudo lsof -Pni TCP:22
- </code></pre>
- <h2>Physical access</h2>
- <p>Keep your Mac physically secure at all times. Don't leave it unattended in hotels and such.</p>
- <p>A skilled attacker with unsupervised physical access to your computer can infect the boot ROM to install a keylogger and steal your password - see <a href="https://trmm.net/Thunderstrike">Thunderstrike</a>, for example.</p>
- <p>A helpful tool is <a href="https://github.com/hephaest0s/usbkill">usbkill</a>, which is <em>"an anti-forensic kill-switch that waits for a change on your USB ports and then immediately shuts down your computer"</em>.</p>
- <p>Consider purchasing a <a href="https://www.amazon.com/s/ref=nb_sb_noss_2?url=node%3D15782001&field-keywords=macbook">privacy filter</a> for your screen to thwart shoulder surfers.</p>
- <h2>System monitoring</h2>
- <h4>OpenBSM audit</h4>
- <p>macOS has a powerful OpenBSM auditing capability. You can use it to monitor process execution, network activity, and much more.</p>
- <p>To tail audit logs, use the <code>praudit</code> utility:</p>
- <p><code>$ sudo praudit -l /dev/auditpipe
- header,201,11,execve(2),0,Thu Sep 1 12:00:00 2015, + 195 msec,exec arg,/Applications/.evilapp/rootkit,path,/Applications/.evilapp/rootkit,path,/Applications/.evilapp/rootkit,attribute,100755,root,wheel,16777220,986535,0,subject,drduh,root,wheel,root,wheel,412,100005,50511731,0.0.0.0,return,success,0,trailer,201,
- header,88,11,connect(2),0,Thu Sep 1 12:00:00 2015, + 238 msec,argument,1,0x5,fd,socket-inet,2,443,173.194.74.104,subject,drduh,root,wheel,root,wheel,326,100005,50331650,0.0.0.0,return,failure : Operation now in progress,4354967105,trailer,88
- header,111,11,OpenSSH login,0,Thu Sep 1 12:00:00 2015, + 16 msec,subject_ex,drduh,drduh,staff,drduh,staff,404,404,49271,::1,text,successful login drduh,return,success,0,trailer,111,</code></p>
- <p>See the manual pages for <code>audit</code>, <code>praudit</code>, <code>audit_control</code> and other files in <code>/etc/security</code></p>
- <p><strong>Note</strong> although <code>man audit</code> says the <code>-s</code> flag will synchronize the audit configuration, it appears necessary to reboot for changes to take effect.</p>
- <p>See articles on <a href="http://ilostmynotes.blogspot.com/2013/10/openbsm-auditd-on-os-x-these-are-logs.html">ilostmynotes.blogspot.com</a> and <a href="https://derflounder.wordpress.com/2012/01/30/openbsm-auditing-on-mac-os-x/">derflounder.wordpress.com</a> for more information.</p>
- <h4>DTrace</h4>
- <p><code>iosnoop</code> monitors disk I/O</p>
- <p><code>opensnoop</code> monitors file opens</p>
- <p><code>execsnoop</code> monitors execution of processes</p>
- <p><code>errinfo</code> monitors failed system calls</p>
- <p><code>dtruss</code> monitors all system calls</p>
- <p>See <code>man -k dtrace</code> for more information.</p>
- <p><strong>Note</strong> <a href="https://github.com/drduh/OS-X-Security-and-Privacy-Guide#system-integrity-protection">System Integrity Protection</a> <a href="http://internals.exposed/blog/dtrace-vs-sip.html">interferes</a> with DTrace, so it may no longer be possible to use these tools.</p>
- <h4>Execution</h4>
- <p><code>ps -ef</code> lists information about all running processes.</p>
- <p>You can also view processes with <strong>Activity Monitor</strong>.</p>
- <p><code>launchctl list</code> and <code>sudo launchctl list</code> list loaded and running user and system launch daemons and agents.</p>
- <h4>Network</h4>
- <p>List open network files:</p>
- <pre><code>$ sudo lsof -Pni
- </code></pre>
- <p>List contents of various network-related data structures:</p>
- <pre><code>$ sudo netstat -atln
- </code></pre>
- <p>You can also use <a href="https://www.wireshark.org/">Wireshark</a> from the command line.</p>
- <p>Monitor DNS queries and replies:</p>
- <p><code>$ tshark -Y "dns.flags.response == 1" -Tfields \
- -e frame.time_delta \
- -e dns.qry.name \
- -e dns.a \
- -Eseparator=,</code></p>
- <p>Monitor HTTP requests and responses:</p>
- <p><code>$ tshark -Y "http.request or http.response" -Tfields \
- -e ip.dst \
- -e http.request.full_uri \
- -e http.request.method \
- -e http.response.code \
- -e http.response.phrase \
- -Eseparator=/s</code></p>
- <p>Monitor x509 certificates:</p>
- <p><code>$ tshark -Y "ssl.handshake.certificate" -Tfields \
- -e ip.src \
- -e x509sat.uTF8String \
- -e x509sat.printableString \
- -e x509sat.universalString \
- -e x509sat.IA5String \
- -e x509sat.teletexString \
- -Eseparator=/s -Equote=d</code></p>
- <p>Also see the simple networking monitoring application <a href="https://github.com/BonzaiThePenguin/Loading">BonzaiThePenguin/Loading</a>.</p>
- <h2>Binary Whitelisting</h2>
- <p><a href="https://github.com/google/santa/">google/santa</a> is a security software developed for Google's corporate Macintosh fleet and open sourced.</p>
- <blockquote>
- <p>Santa is a binary whitelisting/blacklisting system for macOS. It consists of a kernel extension that monitors for executions, a userland daemon that makes execution decisions based on the contents of a SQLite database, a GUI agent that notifies the user in case of a block decision and a command-line utility for managing the system and synchronizing the database with a server.</p>
- </blockquote>
- <p>Santa uses the <a href="https://developer.apple.com/library/content/technotes/tn2127/_index.html">Kernel Authorization API</a> to monitor and allow/disallow binaries from executing in the kernel. Binaries can be white- or black-listed by unique hash or signing developer certificate. Santa can be used to only allow trusted code execution, or to blacklist known malware from executing on a Mac, similar to Bit9 software for Windows.</p>
- <p><strong>Note</strong> Santa does not currently have a graphical user interface for managing rules. The following instructions are for advanced users only!</p>
- <p>To install Santa, visit the <a href="https://github.com/google/santa/releases">Releases</a> page and download the latest disk image, the mount it and install the contained package:</p>
- <p>```
- $ hdiutil mount ~/Downloads/santa-0.9.14.dmg</p>
- <p>$ sudo installer -pkg /Volumes/santa-0.9.14/santa-0.9.14.pkg -tgt /
- ```</p>
- <p>By default, Santa installs in "Monitor" mode (meaning, nothing gets blocked, only logged) and comes with two rules: one for Apple binaries and another for Santa software itself.</p>
- <p>Verify Santa is running and its kernel module is loaded:</p>
- <p>```
- $ santactl status</p>
- <blockquote>
- <blockquote>
- <blockquote>
- <p>Daemon Info
- Mode | Monitor
- File Logging | No
- Watchdog CPU Events | 0 (Peak: 0.00%)
- Watchdog RAM Events | 0 (Peak: 0.00MB)
- Kernel Info
- Kernel cache count | 0
- Database Info
- Binary Rules | 0
- Certificate Rules | 2
- Events Pending Upload | 0</p>
- </blockquote>
- </blockquote>
- </blockquote>
- <p>$ ps -ef | grep "[s]anta"
- 0 786 1 0 10:01AM ?? 0:00.39 /Library/Extensions/santa-driver.kext/Contents/MacOS/santad --syslog</p>
- <p>$ kextstat | grep santa
- 119 0 0xffffff7f822ff000 0x6000 0x6000 com.google.santa-driver (0.9.14) 693D8E4D-3161-30E0-B83D-66A273CAE026 <5 4 3 1>
- ```</p>
- <p>Create a blacklist rule to prevent iTunes from executing:</p>
- <pre><code>$ sudo santactl rule --blacklist --path /Applications/iTunes.app/
- Added rule for SHA-256: e1365b51d2cb2c8562e7f1de36bfb3d5248de586f40b23a2ed641af2072225b3.
- </code></pre>
- <p>Try to launch iTunes - it will be blocked.</p>
- <pre><code>$ open /Applications/iTunes.app/
- LSOpenURLsWithRole() failed with error -10810 for the file /Applications/iTunes.app.
- </code></pre>
- <p><img width="450" alt="Santa block dialog when attempting to run a blacklisted program" src="https://cloud.githubusercontent.com/assets/12475110/21062284/14ddde88-be1e-11e6-8e9b-32f8a44c0cf6.png"></p>
- <p>To remove the rule:</p>
- <pre><code>$ sudo santactl rule --remove --path /Applications/iTunes.app/
- Removed rule for SHA-256: e1365b51d2cb2c8562e7f1de36bfb3d5248de586f40b23a2ed641af2072225b3.
- </code></pre>
- <p>Open iTunes:</p>
- <pre><code>$ open /Applications/iTunes.app/
- [iTunes will open successfully]
- </code></pre>
- <p>Create a new, example C program:</p>
- <p>```
- $ cat <<EOF > foo.c</p>
- <blockquote>
- <h1>include <stdio.h></h1>
- <p>main() { printf("Hello World\n”); }
- EOF
- ```</p>
- </blockquote>
- <p>Compile the program with GCC (requires installation of Xcode or command-line tools):</p>
- <p>```
- $ gcc -o foo foo.c</p>
- <p>$ file foo
- foo: Mach-O 64-bit executable x86_64</p>
- <p>$ codesign -d foo
- foo: code object is not signed at all
- ```</p>
- <p>Run it:</p>
- <p><code>$ ./foo
- Hello World</code></p>
- <p>Toggle Santa into “Lockdown” mode, which only allows whitelisted binaries to run:</p>
- <pre><code>$ sudo defaults write /var/db/santa/config.plist ClientMode -int 2
- </code></pre>
- <p>Try to run the unsigned binary:</p>
- <p>```
- $ ./foo
- bash: ./foo: Operation not permitted</p>
- <p>Santa</p>
- <p>The following application has been blocked from executing
- because its trustworthiness cannot be determined.</p>
- <p>Path: /Users/demouser/foo
- Identifier: 4e11da26feb48231d6e90b10c169b0f8ae1080f36c168ffe53b1616f7505baed
- Parent: bash (701)
- ```
- To whitelist a specific binary, determine its SHA-256 sum:</p>
- <p><code>$ santactl fileinfo /Users/demouser/foo
- Path : /Users/demouser/foo
- SHA-256 : 4e11da26feb48231d6e90b10c169b0f8ae1080f36c168ffe53b1616f7505baed
- SHA-1 : 4506f3a8c0a5abe4cacb98e6267549a4d8734d82
- Type : Executable (x86-64)
- Code-signed : No
- Rule : Blacklisted (Unknown)</code></p>
- <p>Add a whitelist rule:</p>
- <pre><code>$ sudo santactl rule --whitelist --sha256 4e11da26feb48231d6e90b10c169b0f8ae1080f36c168ffe53b1616f7505baed
- Added rule for SHA-256: 4e11da26feb48231d6e90b10c169b0f8ae1080f36c168ffe53b1616f7505baed.
- </code></pre>
- <p>Run it:</p>
- <p><code>$ ./foo
- Hello World</code></p>
- <p>It's allowed and works!</p>
- <p>Applications can also be whitelisted by developer certificate (so that new binary versions will not need to be manually whitelisted on each update). For example, download and run Google Chrome - it will be blocked by Santa in "Lockdown" mode:</p>
- <p>```
- $ curl -sO https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg</p>
- <p>$ hdiutil mount googlechrome.dmg</p>
- <p>$ cp -r /Volumes/Google\ Chrome/Google\ Chrome.app /Applications/</p>
- <p>$ open /Applications/Google\ Chrome.app/
- LSOpenURLsWithRole() failed with error -10810 for the file /Applications/Google Chrome.app.
- ```</p>
- <p>Whitelist the application by its developer certificate (first item in the Signing Chain):</p>
- <p>```
- $ santactl fileinfo /Applications/Google\ Chrome.app/
- Path : /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
- SHA-256 : 0eb08224d427fb1d87d2276d911bbb6c4326ec9f74448a4d9a3cfce0c3413810
- SHA-1 : 9213cbc7dfaaf7580f3936a915faa56d40479f6a
- Bundle Name : Google Chrome
- Bundle Version : 2883.87
- Bundle Version Str : 55.0.2883.87
- Type : Executable (x86-64)
- Code-signed : Yes
- Rule : Blacklisted (Unknown)
- Signing Chain:
- 1. SHA-256 : 15b8ce88e10f04c88a5542234fbdfc1487e9c2f64058a05027c7c34fc4201153
- SHA-1 : 85cee8254216185620ddc8851c7a9fc4dfe120ef
- Common Name : Developer ID Application: Google Inc.
- Organization : Google Inc.
- Organizational Unit : EQHXZ8M8AV
- Valid From : 2012/04/26 07:10:10 -0700
- Valid Until : 2017/04/27 07:10:10 -0700</p>
- <pre><code> 2. SHA-256 : 7afc9d01a62f03a2de9637936d4afe68090d2de18d03f29c88cfb0b1ba63587f
- SHA-1 : 3b166c3b7dc4b751c9fe2afab9135641e388e186
- Common Name : Developer ID Certification Authority
- Organization : Apple Inc.
- Organizational Unit : Apple Certification Authority
- Valid From : 2012/02/01 14:12:15 -0800
- Valid Until : 2027/02/01 14:12:15 -0800
-
- 3. SHA-256 : b0b1730ecbc7ff4505142c49f1295e6eda6bcaed7e2c68c5be91b5a11001f024
- SHA-1 : 611e5b662c593a08ff58d14ae22452d198df6c60
- Common Name : Apple Root CA
- Organization : Apple Inc.
- Organizational Unit : Apple Certification Authority
- Valid From : 2006/04/25 14:40:36 -0700
- Valid Until : 2035/02/09 13:40:36 -0800
- </code></pre>
- <p>```</p>
- <p>In this case, <code>15b8ce88e10f04c88a5542234fbdfc1487e9c2f64058a05027c7c34fc4201153</code> is the SHA-256 of Google’s Apple developer certificate (team ID EQHXZ8M8AV). To whitelist it:</p>
- <p><code>$ sudo santactl rule --whitelist --certificate --sha256 15b8ce88e10f04c88a5542234fbdfc1487e9c2f64058a05027c7c34fc4201153
- Added rule for SHA-256: 15b8ce88e10f04c88a5542234fbdfc1487e9c2f64058a05027c7c34fc4201153.</code></p>
- <p>Google Chrome should now launch, and subsequent updates to the application will continue to work as long as the code signing certificate doesn’t change or expire.</p>
- <p>To disable “Lockdown” mode:</p>
- <pre><code>$ sudo defaults delete /var/db/santa/config.plist ClientMode
- </code></pre>
- <p>See <code>/var/log/santa.log</code> to monitor ALLOW and DENY execution decisions.</p>
- <p><strong>Note</strong> Python, Bash and other interpreters are whitelisted (since they are signed by Apple's developer certificate), so Santa will not be able to block such scripts from executing. Thus, a potential non-binary program which disables Santa is a weakness (not vulnerability, since it is so by design) to take note of.</p>
- <h2>Miscellaneous</h2>
- <p>If you wish, disable <a href="https://github.com/fix-macosx/fix-macosx/wiki/Diagnostics-&-Usage-Data">Diagnostics & Usage Data</a>.</p>
- <p>If you want to play <strong>music</strong> or watch <strong>videos</strong>, use <a href="https://www.videolan.org/vlc/index.html">VLC media player</a> which is free and open source.</p>
- <p>If you want to use <strong>torrents</strong>, use <a href="http://www.transmissionbt.com/download/">Transmission</a> which is free and open source (note: like all software, even open source projects, <a href="http://researchcenter.paloaltonetworks.com/2016/03/new-os-x-ransomware-keranger-infected-transmission-bittorrent-client-installer/">malware may still find its way in</a>). You may also wish to use a block list to avoid peering with known bad hosts - see <a href="https://giuliomac.wordpress.com/2014/02/19/best-blocklist-for-transmission/">Which is the best blocklist for Transmission</a> and <a href="https://gist.github.com/johntyree/3331662">johntyree/3331662</a>.</p>
- <p>Manage default file handlers with <a href="http://duti.org/">duti</a>, which can be installed with <code>brew install duti</code>. One reason to manage extensions is to prevent auto-mounting of remote filesystems in Finder (see <a href="https://www.taoeffect.com/blog/2016/02/apologies-sky-kinda-falling-protecting-yourself-from-sparklegate/">Protecting Yourself From Sparklegate</a>). Here are several recommended handlers to manage:</p>
- <p>```
- $ duti -s com.apple.Safari afp</p>
- <p>$ duti -s com.apple.Safari ftp</p>
- <p>$ duti -s com.apple.Safari nfs</p>
- <p>$ duti -s com.apple.Safari smb
- ```</p>
- <p>Monitor system logs with the <strong>Console</strong> application or <code>syslog -w</code> or <code>log stream</code> commands.</p>
- <p>In systems prior to macOS Sierra (10.12), enable the <a href="https://derflounder.wordpress.com/2016/09/21/tty_tickets-option-now-on-by-default-for-macos-sierras-sudo-tool/">tty_tickets flag</a> in <code>/etc/sudoers</code> to restrict the sudo session to the Terminal window/tab that started it. To do so, use <code>sudo visudo</code> and add the line <code>Defaults tty_tickets</code>.</p>
- <p>Set your screen to lock as soon as the screensaver starts:</p>
- <pre><code>$ defaults write com.apple.screensaver askForPassword -int 1
-
- $ defaults write com.apple.screensaver askForPasswordDelay -int 0
- </code></pre>
- <p>Expose hidden files and Library folder in Finder:</p>
- <pre><code>$ defaults write com.apple.finder AppleShowAllFiles -bool true
-
- $ chflags nohidden ~/Library
- </code></pre>
- <p>Show all filename extensions (so that "Evil.jpg.app" cannot masquerade easily).</p>
- <pre><code>$ defaults write NSGlobalDomain AppleShowAllExtensions -bool true
- </code></pre>
- <p>Don't default to saving documents to iCloud:</p>
- <pre><code>$ defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
- </code></pre>
- <p>Enable <a href="https://security.stackexchange.com/questions/47749/how-secure-is-secure-keyboard-entry-in-mac-os-xs-terminal">Secure Keyboard Entry</a> in Terminal (unless you use <a href="https://mig5.net/content/secure-keyboard-entry-os-x-blocks-interaction-yubikeys">YubiKey</a> or applications such as <a href="https://smilesoftware.com/textexpander/secureinput">TextExpander</a>).</p>
- <p>Disable crash reporter (the dialog which appears after an application crashes and prompts to report the problem to Apple):</p>
- <pre><code>$ defaults write com.apple.CrashReporter DialogType none
- </code></pre>
- <p>Disable Bonjour <a href="https://www.trustwave.com/Resources/SpiderLabs-Blog/mDNS---Telling-the-world-about-you-(and-your-device)/">multicast advertisements</a>:</p>
- <pre><code>$ sudo defaults write /Library/Preferences/com.apple.mDNSResponder.plist NoMulticastAdvertisements -bool YES
- </code></pre>
- <p><a href="https://apple.stackexchange.com/questions/151481/why-is-my-macbook-visibile-on-bluetooth-after-yosemite-install">Disable Handoff</a> and Bluetooth features, if they aren't necessary.</p>
- <p>Consider <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sandbox-exec.1.html">sandboxing</a> your applications. See <a href="https://reverse.put.as/wp-content/uploads/2011/09/Apple-Sandbox-Guide-v0.1.pdf">fG! Sandbox Guide</a> (pdf) and <a href="https://github.com/s7ephen/OSX-Sandbox--Seatbelt--Profiles">s7ephen/OSX-Sandbox--Seatbelt--Profiles</a>.</p>
- <p>Did you know Apple has not shipped a computer with TPM since <a href="http://osxbook.com/book/bonus/chapter10/tpm/">2006</a>?</p>
- <h2>Related software</h2>
- <p><a href="https://github.com/google/santa/">Santa</a> - A binary whitelisting/blacklisting system for macOS.</p>
- <p><a href="https://github.com/kristovatlas/osx-config-check">kristovatlas/osx-config-check</a> - checks your OSX machine against various hardened configuration settings.</p>
- <p><a href="https://objective-see.com/products/lockdown.html">Lockdown</a> - audits and remediates security configuration settings.</p>
- <p><a href="https://objective-see.com/products/dhs.html">Dylib Hijack Scanner</a> - scan for applications that are either susceptible to dylib hijacking or have been hijacked.</p>
- <p><a href="https://www.littleflocker.com/">Little Flocker</a> - "Little Snitch for files"; prevents applications from accessing files.</p>
- <p><a href="https://github.com/facebook/osquery">facebook/osquery</a> - can be used to retrieve low level system information. Users can write SQL queries to retrieve system information.</p>
- <p><a href="https://github.com/google/grr">google/grr</a> - incident response framework focused on remote live forensics.</p>
- <p><a href="https://github.com/yelp/osxcollector">yelp/osxcollector</a> - forensic evidence collection & analysis toolkit for OS X.</p>
- <p><a href="https://github.com/jipegit/OSXAuditor">jipegit/OSXAuditor</a> - analyzes artifacts on a running system, such as quarantined files, Safari, Chrome and Firefox history, downloads, HTML5 databases and localstore, social media and email accounts, and Wi-Fi access point names.</p>
- <p><a href="https://github.com/libyal/libfvde">libyal/libfvde</a> - library to access FileVault Drive Encryption (FVDE) (or FileVault2) encrypted volumes.</p>
- <p><a href="https://github.com/CISOfy/lynis">CISOfy/lynis</a> - cross-platform security auditing tool and assists with compliance testing and system hardening.</p>
- <h2>Additional resources</h2>
- <p><em>In no particular order</em></p>
- <p><a href="http://newosxbook.com/files/moxii3/AppendixA.pdf">MacOS Hardening Guide - Appendix of *OS Internals: Volume III - Security & Insecurity Internals</a></p>
- <p><a href="https://developer.apple.com/library/mac/documentation/Security/Conceptual/SecureCodingGuide/Introduction.html">Mac Developer Library: Secure Coding Guide</a></p>
- <p><a href="https://www.apple.com/osx/all-features/pdf/osx_elcapitan_core_technologies_overview.pdf">OS X Core Technologies Overview White Paper</a></p>
- <p><a href="https://reverse.put.as/">Reverse Engineering Mac OS X blog</a></p>
- <p><a href="http://samdmarshall.com/re.html">Reverse Engineering Resources</a></p>
- <p><a href="https://objective-see.com/blog.html">Patrick Wardle's Objective-See blog</a></p>
- <p><a href="https://www.usenix.org/conference/lisa13/managing-macs-google-scale">Managing Macs at Google Scale (LISA '13)</a></p>
- <p><a href="https://www.usenix.org/conference/lisa13/os-x-hardening-securing-large-global-mac-fleet">OS X Hardening: Securing a Large Global Mac Fleet (LISA '13)</a></p>
- <p><a href="http://iase.disa.mil/stigs/os/mac/Pages/mac-os.aspx">DoD Security Technical Implementation Guides for Mac OS</a></p>
- <p><a href="http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html">The EFI boot process</a></p>
- <p><a href="http://refit.sourceforge.net/info/boot_process.html">The Intel Mac boot process</a></p>
- <p><a href="https://archive.org/details/joshpitts_shmoocon2015">Userland Persistence on Mac OS X</a></p>
- <p><a href="http://phrack.org/issues/66/16.html#article">Developing Mac OSX kernel rootkits</a></p>
- <p><a href="https://code.google.com/p/google-security-research/issues/detail?id=135">IOKit kernel code execution exploit</a></p>
- <p><a href="https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/">Hidden backdoor API to root privileges in Apple OS X</a></p>
- <p><a href="http://www.insinuator.net/2015/02/ipv6-hardening-guide-for-os-x/">IPv6 Hardening Guide for OS X</a></p>
- <p><a href="http://docs.hardentheworld.org/OS/OSX_10.11_El_Capitan/">Harden the World: Mac OSX 10.11 El Capitan</a></p>
- <p><a href="https://news.ycombinator.com/item?id=10148077">Hacker News discussion</a></p>
- <p><a href="https://news.ycombinator.com/item?id=13023823">Hacker News discussion 2</a></p>
- <p><a href="https://opensource.apple.com/">Apple Open Source</a></p>
- <p><a href="http://arstechnica.com/apple/2014/10/os-x-10-10/">OS X 10.10 Yosemite: The Ars Technica Review</a></p>
- <p><a href="https://benchmarks.cisecurity.org/tools2/osx/CIS_Apple_OSX_10.10_Benchmark_v1.1.0.pdf">CIS Apple OSX 10.10 Benchmark</a> (pdf)</p>
- <p><a href="https://taoofmac.com/space/HOWTO/Switch">How to Switch to the Mac</a></p>
- <p><a href="http://www.apple.com/support/security/guides/docs/SnowLeopard_Security_Config_v10.6.pdf">Security Configuration For Mac OS X Version 10.6 Snow Leopard</a> (pdf)</p>
- <p><a href="https://ssd.eff.org/">EFF Surveillance Self-Defense Guide</a></p>
- <p><a href="https://macadmins.herokuapp.com/">MacAdmins on Slack</a></p>
- <p><a href="http://support.apple.com/kb/HT4865">iCloud security and privacy overview</a></p>
- <p><a href="http://newosxbook.com/DMG.html">Demystifying the DMG File Format</a></p>
- <p><a href="https://vulnsec.com/2016/osx-apps-vulnerabilities/">There's a lot of vulnerable OS X applications out there (Sparkle Framework RCE)</a></p>
- <p><a href="https://jscholarship.library.jhu.edu/handle/1774.2/36569">iSeeYou: Disabling the MacBook Webcam Indicator LED</a></p>
- <p><a href="https://www.ma.rhul.ac.uk/static/techrep/2015/RHUL-MA-2015-8.pdf">Mac OS X Forensics - Technical Report</a> (pdf)</p>
- <p><a href="https://cet4861.pbworks.com/w/file/fetch/71245694/mac.forensics.craiger-burke.IFIP.06.pdf">Mac Forensics: Mac OS X and the HFS+ File System</a> (pdf)</p>
- <p><a href="https://tribalchicken.com.au/security/extracting-filevault-2-keys-with-volatility/">Extracting FileVault 2 Keys with Volatility</a></p>
- <p><a href="https://googleprojectzero.blogspot.com/2015/09/revisiting-apple-ipc-1-distributed_28.html">Auditing and Exploiting Apple IPC</a></p>
- <p><a href="https://www.amazon.com/Mac-OS-iOS-Internals-Apples/dp/1118057651">Mac OS X and iOS Internals: To the Apple's Core by Jonathan Levin</a></p>
- <p><a href="http://ramtin-amin.fr/#nvmepcie">Demystifying the i-Device NVMe NAND (New storage used by Apple)</a></p>
- </article>
- </section>
-
-
- <nav id="jumpto">
- <p>
- <a href="/david/blog/">Accueil du blog</a> |
- <a href="https://github.com/drduh/macOS-Security-and-Privacy-Guide">Source originale</a> |
- <a href="/david/stream/2019/">Accueil du flux</a>
- </p>
- </nav>
-
- <footer>
- <div>
- <img src="/static/david/david-larlet-avatar.jpg" loading="lazy" class="avatar" width="200" height="200">
- <p>
- Bonjour/Hi!
- Je suis <a href="/david/" title="Profil public">David Larlet</a>, je vis actuellement à Montréal et j’alimente cet espace depuis 15 ans. <br>
- Si tu as apprécié cette lecture, n’hésite pas à poursuivre ton exploration. Par exemple via les <a href="/david/blog/" title="Expériences bienveillantes">réflexions bimestrielles</a>, la <a href="/david/stream/2019/" title="Pensées (dés)articulées">veille hebdomadaire</a> ou en t’abonnant au <a href="/david/log/" title="S’abonner aux publications via RSS">flux RSS</a> (<a href="/david/blog/2019/flux-rss/" title="Tiens c’est quoi un flux RSS ?">so 2005</a>).
- </p>
- <p>
- Je m’intéresse à la place que je peux avoir dans ce monde. En tant qu’humain, en tant que membre d’une famille et en tant qu’associé d’une coopérative. De temps en temps, je fais aussi des <a href="https://github.com/davidbgk" title="Principalement sur Github mais aussi ailleurs">trucs techniques</a>. Et encore plus rarement, <a href="/david/talks/" title="En ce moment je laisse plutôt la place aux autres">j’en parle</a>.
- </p>
-
- <p>
- Voici quelques articles choisis :
- <a href="/david/blog/2019/faire-equipe/" title="Accéder à l’article complet">Faire équipe</a>,
- <a href="/david/blog/2018/bivouac-automnal/" title="Accéder à l’article complet">Bivouac automnal</a>,
- <a href="/david/blog/2018/commodite-effondrement/" title="Accéder à l’article complet">Commodité et effondrement</a>,
- <a href="/david/blog/2017/donnees-communs/" title="Accéder à l’article complet">Des données aux communs</a>,
- <a href="/david/blog/2016/accompagner-enfant/" title="Accéder à l’article complet">Accompagner un enfant</a>,
- <a href="/david/blog/2016/senior-developer/" title="Accéder à l’article complet">Senior developer</a>,
- <a href="/david/blog/2016/illusion-sociale/" title="Accéder à l’article complet">L’illusion sociale</a>,
- <a href="/david/blog/2016/instantane-scopyleft/" title="Accéder à l’article complet">Instantané Scopyleft</a>,
- <a href="/david/blog/2016/enseigner-web/" title="Accéder à l’article complet">Enseigner le Web</a>,
- <a href="/david/blog/2016/simplicite-defaut/" title="Accéder à l’article complet">Simplicité par défaut</a>,
- <a href="/david/blog/2016/minimalisme-esthetique/" title="Accéder à l’article complet">Minimalisme et esthétique</a>,
- <a href="/david/blog/2014/un-web-omni-present/" title="Accéder à l’article complet">Un web omni-présent</a>,
- <a href="/david/blog/2014/manifeste-developpeur/" title="Accéder à l’article complet">Manifeste de développeur</a>,
- <a href="/david/blog/2013/confort-convivialite/" title="Accéder à l’article complet">Confort et convivialité</a>,
- <a href="/david/blog/2013/testament-numerique/" title="Accéder à l’article complet">Testament numérique</a>,
- et <a href="/david/blog/" title="Accéder aux archives">bien d’autres…</a>
- </p>
- <p>
- On peut <a href="mailto:david%40larlet.fr" title="Envoyer un courriel">échanger par courriel</a>. Si éventuellement tu souhaites que l’on travaille ensemble, tu devrais commencer par consulter le <a href="http://larlet.com">profil dédié à mon activité professionnelle</a> et/ou contacter directement <a href="http://scopyleft.fr/">scopyleft</a>, la <abbr title="Société coopérative et participative">SCOP</abbr> dont je fais partie depuis six ans. Je recommande au préalable de lire <a href="/david/blog/2018/cout-site/" title="Attention ce qui va suivre peut vous choquer">combien coûte un site</a> et pourquoi je suis plutôt favorable à une <a href="/david/pro/devis/" title="Discutons-en !">non-demande de devis</a>.
- </p>
- <p>
- Je ne traque pas ta navigation mais mon
- <abbr title="Alwaysdata, 62 rue Tiquetonne 75002 Paris, +33.184162340">hébergeur</abbr>
- conserve des logs d’accès.
- </p>
- </div>
- </footer>
- <script type="text/javascript">
- ;(_ => {
- const jumper = document.getElementById('jumper')
- jumper.addEventListener('click', e => {
- e.preventDefault()
- const anchor = e.target.getAttribute('href')
- const targetEl = document.getElementById(anchor.substring(1))
- targetEl.scrollIntoView({behavior: 'smooth'})
- })
- })()
- </script>
|