PoLPer: Process-Aware Restriction of Over-Privileged Setuid Calls in Legacy Applications
Yuseok Jeon Junghwan Rhee Chung Hwan Kim Zhichun Li Mathias Payer Byoungyoung Lee Zhenyu Wu
PoLPer: Process-Aware Restriction of Over-Privileged Setuid Calls - - PowerPoint PPT Presentation
PoLPer: Process-Aware Restriction of Over-Privileged Setuid Calls in Legacy Applications Yuseok Jeon Junghwan Rhee Chung Hwan Kim Zhichun Li Mathias Payer Byoungyoung Lee Zhenyu Wu Outline Motivation Background PoLPer
PoLPer: Process-Aware Restriction of Over-Privileged Setuid Calls in Legacy Applications
Yuseok Jeon Junghwan Rhee Chung Hwan Kim Zhichun Li Mathias Payer Byoungyoung Lee Zhenyu Wu
2
Outline
3
Motivation
– Manage privileges – Key function for the principle of least privilege (PoLP) – Active target of attack
setuid setuid
r = setuid(0)
App
KernelPrivilege
Shell code, ROP attack, Non-control data attack
4
Motivation
Approaches Limitations CFI Data modification attack detection DFI High overhead System call context check Over approximated rule (only handle call and data contexts) Setuid semantic Inconsistency check Control flow hijacking and data modification attack detection
CFI: control flow integrity DFI: data flow integrity
5
Outline
6
Principle of Least Privilege (PoLP)
– Minimized attack surface – Limited malware propagation – Better stability
– Switch their IDs from root to the user ID – Setuid calls are used for this change of IDs
7
Setuid Family System Calls
Use three user IDs as parameters
– Real user ID (real uid, or ruid) – Effective user ID (effective uid, or euid) – Saved user ID (saved uid, or suid)
User ID (4 types)
setuid() seteuid() setreuid() setresuid()
Group ID (4 types)
setgid() setegid() setregid() setresgid()
8
Outline
9
PoLPer
– Extracts accurate context information – Enforces precise least privileges
– Identifies important process contexts – Implements automated context extractor – Implements run-time enforcer
10
PoLPer Overview
Process Contexts Process Contexts Static Analysis Static Analysis Dynamic Analysis Dynamic Analysis Setuid(0) BinaryApp
Process hierarchy Call Stack setuid setuid Allowed Denied Logged Success Failure Context Enforcer Process Contexts Process ContextsApp Kernel
Setuid(0) Binary Process hierarchy Call StackApp
Context Analyzer Context Enforcer
11
Process Hierarchy Context
decompose functionalities.
P1 P1 P1 P1 P1 P1 P1 P1 P1 Program P1 Depth 2 Depth 1 Depth 0 (Root)12
Process Hierarchy Context
s t a t i c c h a r * s u ds t a t i c c h a r b u f [ S U D O _ M A X ] ;
. . . i f ( ( p i d = fSUDO
p i d _ t s u b p rSSHD
13
Process Data Context
Case (1) (2) (3) (4) Type Constant Variable Variable Variable Value 100 1000 100, 200 200
K = 2 ; B ( K ) ; i n t K = 1 ; A ( K ) ; s e t u i d ( K ) ; Functjon Main Function A(K) Function B(K)14
Process Call Context
15
Run-time Enforcement
– Hooks on the entry points of setuid calls – Extracts process hierarchy, data, and call contexts – Compares with the profile that was previously
extracted
Run-time Enforcer
Call Context Checker Call Context Checker Data Context Checker Data Context Checker 010100010100 100101011110 101011011010 0101011 Allowed Denied BinaryApp Kernel
Process Hierarchy Context Process Hierarchy Context setuid setuid Compare Extraction16
Outline
17
More Accurate Rule Generation
Programs Process hierarchy context disabled Process hierarchy context enabled Rule cut (%) Ping 1 1 Sudo 352 196 44 Xterm 576 296 49 Cron 2 2 Telnet 4 4 Telnet-Login 6 3 50 Login 4 2 50 SSH & SCP 182 88 52 WireShark 2 2 Apache 2 2 Nginx 2 2
18
Micro-benchmark
1 4 16 64 128 192 256 512 1024 10 20 30 40 50 60 70 80 90 Data context count 1 Data context count 2 Data context count 5 Data context count 10
Call context number Verification time (µs)
19
End-to-end Benchmarks
Programs Base (s) PoLPer (s) Setuid call (#) Overhead (%) Ping 9.0019 9.0039 1 0.02 Nginx 11.522 11.539 0.14 Apache 18.250 18.286 0.1 Telnet 1.001 1.004 6 0.29 SCP 0.1656 0.1665 28 0.54
20
Real-world Exploits
Exploit PatternCFI: control flow integrity NCI: non-control data integrity
21
Case Study: Sudo
s t r u c t u s e r { u i d _ t u i d ; . . . } ; s t r u c t u s e r u d ; u d . u i d = g e t u i d ( ) ; / / i n s u d
d e b u g ( ) v f p r i n t f ( . . . ) ; / / i n s u d
a s k p a s s ( ) s e t u i d ( u d . u i d ) ;
Depth
1
setuid
Parameter
(Profile) uid = getuid() (exploit) 0
Call Stack # Offset File Function
21 0x32 + 0xb75f7b4 4 ../libc.so.622
Outline
23
Conclusion
process contexts
24
THANK YOU!