Polper: Process-Aware Restriction of Over-Privileged Setuid Calls in Legacy Applications

Polper: Process-Aware Restriction of Over-Privileged Setuid Calls in Legacy Applications

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 ● Evaluation ● Conclusion 2 Motivation ● Setuid calls – Manage privileges – Key function for the principle of least privilege (PoLP) – Active target of attack Privilege App Kernel r = setuid(0) setuid Shell code, ROP attack, Non-control data attack 3 Motivation ● Previous solutions still have limitation Approaches Limitations CFI Data modification attack detection DFI High overhead System call Over approximated rule context check (only handle call and data contexts) Setuid semantic Control flow hijacking and data Inconsistency modification attack detection check CFI: control flow integrity DFI: data flow integrity 4 Outline ● Motivation ● Background ● PoLPer ● Evaluation ● Conclusion 5 Principle of Least Privilege (PoLP) ● Require minimal privileges – Minimized attack surface – Limited malware propagation – Better stability ● Login programs and daemon launchers – Switch their IDs from root to the user ID – Setuid calls are used for this change of IDs 6 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() 7 Outline ● Motivation ● Background ● PoLPer ● Evaluation ● Conclusion 8 PoLPer ● Focus on process contexts of a setuid call – Extracts accurate context information – Enforces precise least privileges ● We propose PoLPer – Identifies important process contexts – Implements automated context extractor – Implements run-time enforcer 9 PoLPer Overview Context Analyzer Process hierarchy Static Analysis Process Call Setuid(0) Contexts Stack Dynamic App Analysis Binary App Context Enforcer Context Success Process hierarchy Enforcer Allowed Process Call setuid Denied Setuid(0) Contexts Stack Failure Logged Binary App Kernel 10 Process Hierarchy Context ● Leverage different units of execution to decompose functionalities. P1 P1 Depth 0 (Root) P1 P1 P1 Depth 1 Program P1 P1 P1 P1 P1 Depth 2 11 Process Hierarchy Context SUDO SSHD static char *sudo_askpass() { pid_t subprocess() { static char buf[SUDO_MAX]; FILE *f; ... ... if ((pid = fork()) == -1) … switch ((pid = fork())) { if (pid == 0) { case 0: ... ... If(setgid(u_details.gid)) if(setresgid(pw->pw_gid,…)) {...} {...} ifi(setuid(u_details.uid)) if(setresuid(pw->pw_uid,…)) {...} {...} ... ... execl(askpass, ...); execve(av[0],...); ... _exit(127); & ... ... default: (void)sigaction(SIGPIPE,&sa,...); break; & ● Only child process can access setuid calls 12 Process Data Context ● Need to handle various parameter setting patterns Function Main int K = 1000; int K = 1000; int K = 1000; A(K); if (cond) Function A(K) K = 100; setuid(100); K = 200; else setuid(K); B(K); K = 200; Function B(K) setuid(K); setuid(K); Case (1) (2) (3) (4) Type Constant Variable Variable Variable Value 100 1000 100, 200 200 ● Use data-flow analysis ● Record together with the process hierarchy context 13 Process Call Context ● Identify code location to identify setuid call ● Dynamic analysis for high accuracy call context ● Record together with the process hierarchy context 14 Run-time Enforcement ● Use Kprobes, a kernel-based probing mechanism – 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 Extract Compare Call 010100010100 Hook Call 100101011110 Extraction ContextData Allowed 101011011010 Checker setuid of Process ContextProcess 0101011 Context CheckerHierarchy Denied Binary Context App Kernel 15 Outline ● Motivation ● Background ● PoLPer ● Evaluation ● Conclusion 16 More Accurate Rule Generation Process Process hierarchy hierarchy Programs context context Rule cut (%) disabled enabled Ping 1 1 0 Sudo 352 196 44 Xterm 576 296 49 Cron 2 2 0 Telnet 4 4 0 Telnet-Login 6 3 50 Login 4 2 50 SSH & SCP 182 88 52 WireShark 2 2 0 Apache 2 2 0 Nginx 2 2 0 17 Micro-benchmark 90 Data context count 1 80 ) Data context count 2 s µ 70 Data context count 5 ( e 60 Data context count 10 m i t 50 n 40 o i t a 30 c i f i 20 r e 10 V 0 1 4 16 64 128 192 256 512 1024 Call context number 18 End-to-end Benchmarks ● Show near zero overhead Setuid Programs Base (s) PoLPer (s) call Overhead (#) (%) Ping 9.0019 9.0039 1 0.02 Nginx 11.522 11.539 0 0.14 Apache 18.250 18.286 0 0.1 Telnet 1.001 1.004 6 0.29 SCP 0.1656 0.1665 28 0.54 19 Real-world Exploits Detected Setuid Exploit Vul. Program Exploit Syscall Pattern Name (EDB) Exploited PoLPer CFI NCI Modify Setuid Sudo (N/A) setuid √ X √ Parameters Wu_ftpd (N/A) seteuid √ X √ 37292-2015 setresuid, √ √ X Overlayfs setresgid 39230-2016 setresuid √ √ X Glibc 209-2000 setuid, setgid √ √ X Run setuid call Mkdir 20554-2001 setuid, setgid √ √ X to creat a root shell KApplication 19981-2000 setuid, setregid √ √ X Suid_dumpable 2006-2006 setuid, setgid √ √ X Execve/ptrace 20720-2001 setuid √ √ X Splitvt 20013-2000 setuid √ √ X OpernMovieeditor 2338-2006 setuid,setgid √ √ X CFI: control flow integrity NCI: non-control data integrity 20 Case Study: Sudo Depth 1 struct user { Priv. Op. setuid uid_t uid; (Profile) uid = getuid() ... Parameter (exploit) 0 }; # Offset File Function 0x32 + struct user ud; 21 0xb75f7b4 ../libc.so.6 - ud.uid = getuid(); 4 Call Stack 20 0x8053080 ../bin/sudo sudo_askpass //in sudo_debug() ... vfprintf (...); 1 0x8049dd1 ../bin/sudo - //in sudo_askpass() setuid (ud.uid); Sudo code example 21 Outline ● Motivation ● Background ● PoLPer ● Evaluation ● Conclusion 22 Conclusion ● Extracts only the required contexts of setuid calls ● Prevents setuid exploits with negligible overhead ● Enforces PoLP using a combination of different process contexts 23 THANK YOU! Q&A 24.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    24 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us