Dawn Song
Principle of Least Privilege
Computer Security Course. Dawn Song Computer Security Course. Dawn Song
Principle of Least Privilege Dawn Song Principle of least privilege - - PowerPoint PPT Presentation
Computer Security Course. Dawn Computer Security Course. Dawn Song Song Principle of Least Privilege Dawn Song Principle of least privilege Privilege Ability to access or modify a resource Principle of least privilege A
Dawn Song
Computer Security Course. Dawn Song Computer Security Course. Dawn Song
Dawn Song
– Ability to access or modify a resource
– A system module should only have the minimal privileges needed for intended purposes
– Separate the system into independent modules – Each module follows the principle of least privilege – Limit interaction between modules
Dawn Song
– Grants permission to user ids – Owner, group, other
– Inherit from creating process – Process can change id
– Special “root” id
File 1 File 2 … User 1 read write
write write
… User m Read write write
Dawn Song
grp
Dawn Song
– Root can do anything
– Even though they only need to perform a small number of priviledged operations
– Privileged programs are juicy targets for attackers – By fjnding a bug in parts of the program that do not need privilege, attacker can gain root
Dawn Song
– Solution? – Drop privilege right after binding the port
– Even if attacker fjnds a bug in later part of the code, can’t gain privilege any more
– Setuid/setgid programming in UNIX
Dawn Song
– Real user ID (RUID)
– Efgective user ID (EUID)
– fjle access and port binding
– Saved user ID (SUID)
Dawn Song
– ID=0 for superuser root; can access any fjle
– Inherit three IDs, except exec of fjle with setuid bit
– seteuid(newid) can set EUID to
– Several difgerent calls: setuid, seteuid, setreuid
Dawn Song
– Setuid – set EUID of process to ID of fjle owner – Setgid – set EGID of process to GID of fjle – Sticky
remove fjles, even if not owner
remove fjle in the directory
Dawn Song
Dawn Song
setresuid(newruid, neweuid, newsuid) (euid == 0) || (newruid in (ruid, euid, suid) && neweuid in (ruid, euid, suid) && newsuid in (ruid, euid, suid)) setuid(newuid) (euid == 0) || (newuid in (ruid, suid)) Cases (euid == 0) (ruid:=newuid, ⇒ euid:=newuid, suid:=newuid) (anything else) (euid:=newuid) ⇒ Note: all policies are for Linux, differs on FreeBSD seteuid(neweuid) (euid == 0) || (neweuid in (ruid, euid, suid)) Users choose any new UID to pass in to setuid(), but the OS checks them against certain rules and will raise an error, for example, if a normal user tries to call setuid(0).
Dawn Song
setresuid(newruid, neweuid, newsuid) (euid == 0) || (newruid in (ruid, euid, suid) && neweuid in (ruid, euid, suid) && newsuid in (ruid, euid, suid)) setuid(newuid) (euid == 0) || (newuid in (ruid, suid)) Cases (euid == 0) (ruid:=newuid, ⇒ euid:=newuid, suid:=newuid) (anything else) (euid:=newuid) ⇒ Note: all policies are for Linux, differs on FreeBSD seteuid(neweuid) (euid == 0) || (neweuid in (ruid, euid, suid))
Users choose any new UID to pass in to setuid(), but the OS checks them against certain rules and will raise an error, for example, if a normal user tries to call setuid(0).
Dawn Song
…; …; exec( ); RUID 25 SetUID program
…; …; i=getruid() setuid(i); …; …;
RUID 25 EUID 18 RUID 25 EUID 25
fjle
fjle Owner 18 Owner 25
read/write read/write
Owner 18
Dawn Song
Computer Security Course. Dawn Song Computer Security Course. Dawn Song
Slide credit: Anthony Joseph and John Mitchell
Dawn Song
Dawn Song
SERVER CLIENT
HTTP REQUEST: GET /account.html HTTP/1.1 Host: www.safebank.com HTTP REQUEST: GET /account.html HTTP/1.1 Host: www.safebank.com HTTP RESPONSE: HTTP/1.0 200 OK <HTML> . . . </HTML> HTTP RESPONSE: HTTP/1.0 200 OK <HTML> . . . </HTML>
(browser)
login password
SAFEBANK banking content
Accounts Bill Pay Mail T ransfers
Dawn Song
http://safebank.com:81/account?id=10#statement
– %0A = newline
Protocol Protocol Hostname Hostname Port Port Path Path Query Query Fragment Fragment
Dawn Song
GET /index.html HTTP/1.1 Accept: image/gif, image/x-bitmap, image/jpeg, */* Accept-Language: en Connection: Keep-Alive User-Agent: Chrome/21.0.1180.75 (Macintosh; Intel Mac OS X 10_7_4) Host: www.safebank.com Referer: http://www.google.com?q=dingbats GET /index.html HTTP/1.1 Accept: image/gif, image/x-bitmap, image/jpeg, */* Accept-Language: en Connection: Keep-Alive User-Agent: Chrome/21.0.1180.75 (Macintosh; Intel Mac OS X 10_7_4) Host: www.safebank.com Referer: http://www.google.com?q=dingbats
Method File HTTP version Headers Data – none for GET Blank line
HTTP/1.0 200 OK Date: Sun, 12 Aug 2012 02:20:42 GMT Server: Microsoft-Internet-Information- Server/5.0 Connection: keep-alive Content-Type: text/html Last-Modified: Thu, 9 Aug 2012 17:39:05 GMT Set-Cookie: … Content-Length: 2543 <HTML> This is web content formatted using html </HTML> HTTP/1.0 200 OK Date: Sun, 12 Aug 2012 02:20:42 GMT Server: Microsoft-Internet-Information- Server/5.0 Connection: keep-alive Content-Type: text/html Last-Modified: Thu, 9 Aug 2012 17:39:05 GMT Set-Cookie: … Content-Length: 2543 <HTML> This is web content formatted using html </HTML>
HTTP version Status code Reason phrase Headers Cookies Data
Dawn Song
Renderer UI Renderer UI uppose you are visiting http://safebank.com in a modern web browser. ChromeBar UI ChromeBar UI Browser Engine Browser Engine Networ k Stack Networ k Stack Renderer Engine Renderer Engine
display(UR I) isCached(URI) = false retrieveData(URI) pageData /*HTML, CSS, etc*/ renderBitmap(page Data)
(Renderer Process)
enters http://safeba nk.com and presses go.
(Browser Process)
Dawn Song
– Each browser window or frame
– Processes HTML and scripts to display page – May involve images, subframes, etc.
– User actions: OnClick, OnMouseover – Rendering: OnLoad, OnBeforeUnload – Timing: setTimeout(), clearTimeout()
Dawn Song
and write rendered pages – web page in HTML is structured data – DOM provides representation of this hierarchy
– Properties: document.alinkColor, document.URL, document.forms[ ], document.links[ ], document.anchors[ ] – Methods: document.write(document.referrer)
|-> Document |-> Element (<html>) |-> Element (<body>) |-> Element (<div>) |-> text node |-> Anchor |-> text node |-> Form |-> T ext-box |-> Radio Button |-> Check Box |-> Button
DOM Tree HTML
<html> <body> <div> foo <a>foo2</a> </div> <form> <input type="text” /> <input type=”radio” /> <input type=”checkbox” /> </form> </body> </html>
Dawn Song
pageData /*HTML*/
RENDERING ENGINE
pageData /*CSS*/
CSS Parser CSS Parser
Style Rules
HTML Parser HTML Parser DOM T ree Builder DOM T ree Builder
Render Tree
Painter Painter
pageBitma p
<HTML> … <HTML> element.style { height: 303px; … } 0x 42 4d 45 00 00 00 00 36 00 00 00 28 00 00 4f 45 d0 00 00 00 92 36 00 60 0b 28 4f 45 d0 00 d0 00 00 00 92 4f 4d 45 00 00 00 00 4f 45 d0 00 00 00 92 . . . HtmlElement BodyElement T ext DivElement ImageElement ParagraphElement
* JavaScript Engine JavaScript Engine
pageData /*JavaScript*/
function onload(){ … }
Original DOM DOM Modifjcations
Dawn Song
uppose you are visiting http://safebank.com in a modern web browser. ChromeBar UI ChromeBar UI Browser Engine Browser Engine Networ k Stack Networ k Stack Renderer Engine Renderer Engine
display(UR I) isCached(URI) = false retrieveData(URI) pageData /*HTML, CSS, etc*/ renderBitmap(page Data)
(Renderer Process)
enters http://safeba nk.com and presses go.
(Browser Process)
(displays pageBitmap)
Renderer UI Renderer UI
pageBitmap
login password
SAFEBANK banking content
Accounts Bill Pay Mail T ransfers
(cookies for www.safebank.com) (javascript for www.safebank.com) (other resources for www.safebank.com)
Dawn Song
Dawn Song
login password
SAFEBANK banking content
Accounts Bill Pay Mail T ransfers
cookies for www.safebank.com) javascript for www.safebank.com)
tab1 tab2
login password
catville
(cookies for www.catville.com) (javascript for www.catville.com) (other resources for www.catville.com)
information from tab1 (without user permission)
compromise the user’s computer or data
compromise the session in tab 1
Security Goals
Dawn Song
OS/Malware Attacker May control malicious fjles and applications on host User
System
THREAT MODELS:
OPERATING SYSTEM SECURITY NETWORK SECURITY WEB SECURITY
Dawn Song
Network Attacker Intercepts and controls network communication
login password
SAFEBANK banking content
Accounts Bill Pay Mail T ransfers
THREAT MODELS:
OPERATING SYSTEM SECURITY NETWORK SECURITY WEB SECURITY
User
(Network)
Dawn Song
Web Attacker Sets up malicious site visited by victim; no control
login password
catville
THREAT MODELS:
OPERATING SYSTEM SECURITY NETWORK SECURITY WEB SECURITY
User
(Network)
Dawn Song
Web attacker
Or: runs attacker’s Facebook app, site with attack ad, …
login password
catville
Network attacker
OS/Malware attacker
(Network)
Dawn Song
Dawn Song
uppose you are visiting http://safebank.com in a modern web browser. ChromeBar UI ChromeBar UI Browser Engine Browser Engine Networ k Stack Networ k Stack Renderer Engine Renderer Engine
display(UR I) isCached(URI) = false retrieveData(URI) pageData /*HTML, CSS, Javascript, etc*/ renderBitmap(page Data)
(Renderer Process)
enters http://safeba nk.com and presses go.
(Browser Process)
(displays pageBitmap)
Renderer UI Renderer UI
pageBitmap
login password
SAFEBANK banking content
Accounts Bill Pay Mail T ransfers
(cookies for www.safebank.com) (javascript for www.safebank.com) (other resources for www.safebank.com)
Dawn Song
Dawn Song
Dawn Song
Dawn Song
Dawn Song
– Bufger overfmow – Root exploit – Cross-site scripting – Cross-site request forgery – Cache history attacks – Processes – System calls – File system – Frames/iFrames – Content (including JavaScript, …) – Document object model, cookies, localStorage
Users
– Discretionary access control
“Origins”
– Mandatory access control
Vulnerabilities: Vulnerabilities: Primitives: Principals:
login passwordSAFEBANK
banking content
Accounts Bill Pay Mail T ransfersOperating system Operating system
Web Browser Web Browser
Dawn Song
Cookies Javascript DOM Imported in a page or frame:
Has the same origin as that page or frame Default origin is domain and path of setting URL
Each frame of a page:
Setting Cookies:
Origin is protocol://host:port
Embedded in a page or frame:
Has the same origin as that page or frame
Dawn Song
<script src=https://seal.verisign.com/getseal?host_name=safebank.com> </script>
login password
SAFEBANK banking content
Accounts Bill Pay Mail T ransfers
Dawn Song
Same protocol Same domain Same port
T wo documents have the same
(https, http, ftp, etc) (safebank.com, etc) (80, 23, 8080, etc)
Results of same-origin checks against “http://cards.safebank.com/c1/info.htm l” Same origin: “http://cards.safebank.com/c2/edit.html” “http://cards.safebank.com/” Difgerent origin: “http://www.cards.safebank.com” “http://catville.com” “https://cards.safebank.com” “http://cards.safebank:8080”