25
Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

  • View
    221

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks

Massimo BernaschiEmanuele Gabrielli

Luigi V. Mancini

Page 2: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Outline Introduction Problem analysis The Access Control Database The reference functions Performance Conclusion

Page 3: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Introduction Approach

Require minimal additions to the kernel code

Neither changes to the syntax and semantics

Neither modifications of existing kernel data structures and algorithm

No change in source code No special compiling procedure is

required

Page 4: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Introduction (Cont.) Access Control Database (ACD)

To reduce the cost of the checks A detailed analysis of privileged

applications and system calls is carried out.

Buffer Overflow Execute fake instruction

Protection against buffer overflow

Page 5: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Problem analysis Privileged Process System calls analysis

Page 6: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Privileged processes Interactive

Real user identifer ( UID ) Effective user identifer ( EUID ) System Administrator = ( both UID and E

UID == 0 ) Prevent privileged process from migratin

g to this category

Page 7: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Privileged processes ( Cont. ) Background

Like daemon or cron daemon !((proc)->euid) && ((proc)->tty==NULL) First check if euid == 0 Second check if tty == NULL, because dae

mon need not control terminal Block any attempt made by there proces

ses to re-acquire a control terminal

Page 8: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Privileged processes ( Cont. ) Setuid

The effective UID of the process is set equal to the UID of the program file owner

!((proc)->euid)&&(proc)->uid A process can be identified as setuid to ro

ot ( EUID == 0 )

Page 9: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

System calls analysis

Page 10: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

System calls analysis ( Cont. )

Page 11: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

System calls analysis ( Cont. )

Page 12: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

The Access Control Database

Page 13: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

The Access Control Database

Page 14: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

The Access Control Database execve_acd is composed by two array

of eflst_t structures: admitted:只有列在此 list 中的特權程式才可被執行

failure:keeps a log of unauthorized attempts of invoking execve by any setuid process.

Page 15: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

The Access Control Database

Page 16: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

The Access Control Database Add a new system call sys_setuid_aclm for r

eading and modifying the information kept in the ACD

Through a command aclmng to manage information kept in the ACD -l list the contents of ACD kept in kernel space -L load in kernel space the ACD from file -w writes the ACD from kernel space into file default with no options, -l is assumed

Page 17: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

The reference functions execve setuid chmod

Page 18: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Execve

Page 19: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Execve ( Cont. ) check_rootproc() return EXENA or EF

NA EXENA: 表示這個行程中所執行的程式並沒有列在 ACD 當中

EFNA: 表示檔案無法通過 ACD的認證 , 如檔案修改日期時間沒有符合

Page 20: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Check_rootproc()

Page 21: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Setuid If setuid(0), then enforce to type corre

ct root password kept in ACD If no match, invocation is denial

Page 22: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

chmod chmod +s –p /program1 /program2 fo

o Allows the setuid program foo to exec

ute program1 and program2. Check filename is kept in ACD

Page 23: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Performance Pentium II 128MB Ram Linux Kernel 2.2.12 Repeat 40 times Sendmail Lpr Rsync X server

Page 24: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Performance ( Cont )

Page 25: Enhancements to the Linux Kernel for Blocking Buffer Overflow Based Attacks Massimo Bernaschi Emanuele Gabrielli Luigi V. Mancini

Conclusion 優點

多一層防護 , 比較安全 Kernel 做 , 執行速度佳

缺點 更改 kernel, 但是 kernel 的版本會一直改

變 機制不夠健全 ( 感覺上 , 未實際去想例子 )