jail 8
play

jail(8) Hacking UNIX with FreeBSD jail(8), Secure Virtual Servers - PowerPoint PPT Presentation

jail(8) Hacking UNIX with FreeBSD jail(8), Secure Virtual Servers Presentation for DefCon 14, by Isaac Levy, (.ike) .ike Context I have used jails extensively for web application servers and software development purposes the methodology


  1. Poor Uses for jail(8) • kernel access (you don ’ t get a kernel) • limited network interface access • limited device driver access • when chroot(8) will simply do the job • some applications require particular low-level system calls: • Notably, PostgreSQL doesn ’ t run (securely) in jails based on SysV IPC

  2. How To jail(8) • DEFINITIVE instructions in jail man pages , 1. compile a FreeBSD userland from source somewhere on host machine, minor tweaks. 2. create an IP alias on a network interface 3. run the jail(8) call with the IP, and userland, to ‘ boot ’ the jail, (so to speak).

  3. Practical Comparison host:/path/to/jaildir/ 1 a d ed0 ed0 0 ed1 a 2 d d h 0 ed1 a tmp 2 d d h tmp mem mem var t n m m e var mnt m m e k m k dev dev null dev dev l l u n o t b o rc.d boot rc.d etc etc p r o c FreeBSD p r o c /dev/null b kernel l i kernel lib n i root b s sbin root n i b home n i b e m user user sbin o usr sbin h s r u user bin user bin local local sbin sbin s t r bin o s r c p s r t o bin src p

  4. making a jail

  5. Host Machine

  6. preflight (simple) 1. get source to build with (cvsup is great) 2. make somewhere for the jails to live (partitions, disk mounts, etc...) 3.make somewhere for jail-related start/mgmt scripts to live (starting jails from /etc/rc.d/jail can thrash violently in most contexts! Bad!)

  7. preflight- (man, definitive)

  8. preflight- (build from src)

  9. preflight- (build from src)

  10. preflight- (build from src)

  11. kernel lib n i b s n i b e m o sbin h usr u n s i b e r local sbin ports bin s r c jails

  12. preflight- (build from src)

  13. local sbin preflight ports bin s r c jails $D

  14. preflight- (build from src) compile!

  15. preflight- (build from src) compile!

  16. preflight host:/path/to/jaildir/ lib ports

  17. preflight host:/path/to/jaildir/ t m p v a r mnt etc lib n i b s bin home sbin s r u n i b local ports

  18. preflight- (mount /dev)

  19. preflight- (mount /dev)

  20. preflight- (null kernel)

  21. preflight- (null kernel)

  22. preflight host:/path/to/jaildir/ t m p v a r mnt etc lib n i b s bin home sbin s r u n i b local ports

  23. preflight host:/path/to/jaildir/ ed0 da1 0 ed1 a d t m p m e m v a r mnt kmem dev dev null etc lib n i b s bin home sbin s r u n i b local

  24. preflight • Common Question: • Why isn ’ t there an automated build system for this stage? • - Take care with the build procedure, it ’ s better to automate things later, once you have basics setup. • (network, users, packages, time, etc.)

  25. preflight- (config host) jailinghost:/etc/rc.conf (stock)

  26. preflight- (config host) jailinghost:/etc/rc.conf

  27. preflight- (master system) jailinghost:/etc/ssh/sshd_conf

  28. da1 ed0 0 ed1 a 2 d d h t m p m e m mnt v a r kmem dev dev o t b o rc.d etc ? proc FreeBSD kernel lib root n i b s bin home u s e sbin r r u s user n i b local sbin ports bin src s a i l j

  29. configure - call jailed sh (analagous to booting a machine in su mode) Text

  30. configure - call jailed sh (analagous to booting a machine in su mode) Text

  31. configure - call jailed sh (analagous to booting a machine in su mode) Text

  32. configure - call jailed sh configure the jail, inside the jail Text

  33. configure - call jailed sh configure the jail, inside the jail Text

  34. configure - call jailed sh sysctl, whee! Text

  35. configure - call jailed sh root pw Text

  36. configure - call jailed sh root pw Text

  37. configure - call jailed sh add users Text

  38. configure - call jailed sh add users Text

  39. configure - call jailed sh add users Text

  40. configure - call jailed sh set timezone Text

  41. configure - call jailed sh set timezone Text

  42. configure - call jailed sh set timezone Text

  43. configure - call jailed sh set timezone Text

  44. configure - call jailed sh set timezone Text

  45. configure - call jailed sh network options... Text

  46. configure - call jailed sh run ssh, important Text

  47. configure - call jailed sh check rc.conf in jail Text

  48. configure - call jailed sh check rc.conf in jail Text

Recommend


More recommend