[{"data":1,"prerenderedAt":577},["ShallowReactive",2],{"article-20130930-hidepid-process-hiding":3},{"article":4,"surround":566},{"id":5,"title":6,"authorKey":7,"body":8,"codeLinks":509,"createdAt":510,"description":511,"excerpt":512,"extension":554,"image":555,"meta":556,"navigation":184,"path":557,"published":558,"readingTime":181,"revisedAt":509,"seo":559,"stem":560,"tags":561,"__hash__":565},"articles\u002Farticles\u002F20130930-hidepid-process-hiding.md","Process hiding - hidepid capabilities of procfs","philip",{"type":9,"value":10,"toc":507},"minimark",[11,34,40,54,89,98,119,125,240,247,255,258,310,323,326,452,455,470,473,503],[12,13,14,15,22,23,22,28,33],"p",{},"Five years ago I wrote about kernel based process hiding in Linux (see my old blog posts: ",[16,17,21],"a",{"href":18,"rel":19},"https:\u002F\u002Fold.iezzi.ch\u002Fsimple-process-hiding-kernel-patch\u002F",[20],"nofollow","Simple process hiding kernel patch",", ",[16,24,27],{"href":25,"rel":26},"https:\u002F\u002Fold.iezzi.ch\u002Fprocess-hiding-kernel-patch\u002F",[20],"Process hiding Kernel patch for 2.6.24.x",[16,29,32],{"href":30,"rel":31},"https:\u002F\u002Fold.iezzi.ch\u002Frsbac-kernel-based-process-hiding\u002F",[20],"RSBAC – Kernel based process hiding","). It got time to continue the story and finally present you a real solution without the hassle of a self-compiled kernel.",[12,35,36],{},[37,38,39],"strong",{},"How can I prevent users from seeing processes that do not belong to them?",[12,41,42,43,48,49,53],{},"In January 2012, Vasiliy Kulikov came up with a ",[16,44,47],{"href":45,"rel":46},"https:\u002F\u002Fgit.kernel.org\u002Fcgit\u002Flinux\u002Fkernel\u002Fgit\u002Ftorvalds\u002Flinux.git\u002Fcommit\u002F?id=0499680a42141d86417a8fbaa8c8db806bea1201",[20],"kernel patch"," that solved the problem nicely by adding a ",[50,51,52],"code",{},"hidepid"," mount option for procfs. The patch landed in Linux kernel 3.3.",[12,55,56,57,60,61,66,67,70,71,76,77,80,81,84,85,88],{},"In the meantime, this patch luckily also landed in the 3.2 kernel of ",[37,58,59],{},"Debian Wheezy"," (see backport request in ",[16,62,65],{"href":63,"rel":64},"http:\u002F\u002Fbugs.debian.org\u002Fcgi-bin\u002Fbugreport.cgi?bug=669028",[20],"Debian bug report #669028","). This feature has been also pushed back into the kernel of ",[37,68,69],{},"Red Hat Enterprise Linux 6.3"," (see ",[16,72,75],{"href":73,"rel":74},"https:\u002F\u002Faccess.redhat.com\u002Fsite\u002Fdocumentation\u002Fen-US\u002FRed_Hat_Enterprise_Linux\u002F6\u002Fhtml\u002F6.3_Release_Notes\u002Fkernel.html",[20],"RHEL 6.3 Release Notes","), and from there to ",[37,78,79],{},"CentOS 6.3"," and ",[37,82,83],{},"Scientific Linux 6.3",". Recently, this feature was even backported to the 2.6.18 kernel in ",[37,86,87],{},"RHEL 5.9",".",[12,90,91,92,97],{},"As ",[16,93,96],{"href":94,"rel":95},"https:\u002F\u002Fproxmox.com\u002Fen\u002Fproxmox-ve",[20],"Proxmox VE"," currently runs on a RHEL based 2.6.32 kernel, it's also supported in my favorite OpenVZ\u002FKVM virtualization platform. Great!",[99,100,101,107,113],"blockquote",{},[12,102,103,106],{},[50,104,105],{},"hidepid=0"," (default) means the current behaviour - anybody may read all\nworld-readable \u002Fproc\u002FPID\u002F* files.",[12,108,109,112],{},[50,110,111],{},"hidepid=1"," means users may not access any \u002Fproc\u002FPID\u002F directories, but their\nown. Sensitive files like cmdline, io, sched*, status, wchan are now\nprotected against other users. As permission checking done in\nproc_pid_permission() and files' permissions are left untouched,\nprograms expecting specific files' permissions are not confused.",[12,114,115,118],{},[50,116,117],{},"hidepid=2"," means hidepid=1 plus all \u002Fproc\u002FPID\u002F will be invisible to\nother users. It doesn't mean that it hides a fact whether a process\nexists (it can be learned by other means, e.g. by sending signals), but\nit hides process' euid and egid. It greatly compicates intruder's task of\ngathering info about running processes, whether some daemon runs with\nelevated privileges, whether other user runs some sensitive program,\nwhether other users run any program at all, etc.",[12,120,121,122,124],{},"On a shared server I strongly recommend to enable the ",[50,123,117],{}," procfs mount option. This can be done at runtime by remounting procfs:",[126,127,132],"pre",{"className":128,"code":129,"language":130,"meta":131,"style":131},"language-bash shiki shiki-themes github-light-default github-light-default github-dark-default","$ mount | grep ^proc\nproc on \u002Fproc type proc (rw,relatime)\n\n$ mount -o remount,hidepid=2 \u002Fproc\n\n$ mount | grep ^proc\nproc on \u002Fproc type proc (rw,relatime,hidepid=2)\n","bash","",[50,133,134,157,179,186,206,211,224],{"__ignoreMap":131},[135,136,139,143,147,151,154],"span",{"class":137,"line":138},"line",1,[135,140,142],{"class":141},"sQJ0q","$",[135,144,146],{"class":145},"s-BGO"," mount",[135,148,150],{"class":149},"s5nWI"," |",[135,152,153],{"class":141}," grep",[135,155,156],{"class":145}," ^proc\n",[135,158,160,163,166,169,172,175],{"class":137,"line":159},2,[135,161,162],{"class":141},"proc",[135,164,165],{"class":145}," on",[135,167,168],{"class":145}," \u002Fproc",[135,170,171],{"class":145}," type",[135,173,174],{"class":145}," proc",[135,176,178],{"class":177},"s_bOF"," (rw,relatime)\n",[135,180,182],{"class":137,"line":181},3,[135,183,185],{"emptyLinePlaceholder":184},true,"\n",[135,187,189,191,193,197,200,203],{"class":137,"line":188},4,[135,190,142],{"class":141},[135,192,146],{"class":145},[135,194,196],{"class":195},"sDkKp"," -o",[135,198,199],{"class":145}," remount,hidepid=",[135,201,202],{"class":195},"2",[135,204,205],{"class":145}," \u002Fproc\n",[135,207,209],{"class":137,"line":208},5,[135,210,185],{"emptyLinePlaceholder":184},[135,212,214,216,218,220,222],{"class":137,"line":213},6,[135,215,142],{"class":141},[135,217,146],{"class":145},[135,219,150],{"class":149},[135,221,153],{"class":141},[135,223,156],{"class":145},[135,225,227,229,231,233,235,237],{"class":137,"line":226},7,[135,228,162],{"class":141},[135,230,165],{"class":145},[135,232,168],{"class":145},[135,234,171],{"class":145},[135,236,174],{"class":145},[135,238,239],{"class":177}," (rw,relatime,hidepid=2)\n",[12,241,242,243,246],{},"You may also add this mount option directly to ",[50,244,245],{},"\u002Fetc\u002Ffstab"," in order to make it persistent:",[126,248,253],{"className":249,"code":251,"language":252},[250],"language-text","proc            \u002Fproc           proc    defaults,hidepid=2        0       0\n","text",[50,254,251],{"__ignoreMap":131},[12,256,257],{},"A regular system user will then only see his own processes, e.g.:",[126,259,261],{"className":128,"code":260,"language":130,"meta":131,"style":131},"testuser@web:~$ ps\n  PID TTY          TIME CMD\n17486 pts\u002F0    00:00:00 bash\n24806 pts\u002F0    00:00:00 ps\n",[50,262,263,271,285,299],{"__ignoreMap":131},[135,264,265,268],{"class":137,"line":138},[135,266,267],{"class":141},"testuser@web:~$",[135,269,270],{"class":145}," ps\n",[135,272,273,276,279,282],{"class":137,"line":159},[135,274,275],{"class":141},"  PID",[135,277,278],{"class":145}," TTY",[135,280,281],{"class":145},"          TIME",[135,283,284],{"class":145}," CMD\n",[135,286,287,290,293,296],{"class":137,"line":181},[135,288,289],{"class":141},"17486",[135,291,292],{"class":145}," pts\u002F0",[135,294,295],{"class":145},"    00:00:00",[135,297,298],{"class":145}," bash\n",[135,300,301,304,306,308],{"class":137,"line":188},[135,302,303],{"class":141},"24806",[135,305,292],{"class":145},[135,307,295],{"class":145},[135,309,270],{"class":145},[12,311,312,313,22,316,22,319,322],{},"This also works for other commands like ",[37,314,315],{},"pstree",[37,317,318],{},"top",[37,320,321],{},"htop",",...",[12,324,325],{},"To get process hiding working inside a Proxmox VE container, simply remount procfs inside the VE, e.g. by the following init script ''\u002Fetc\u002Finit.d\u002Fsystem-hardening'':",[126,327,329],{"className":128,"code":328,"language":130,"meta":131,"style":131},"#!\u002Fbin\u002Fbash\n\n### BEGIN INIT INFO\n# Provides:          system-hardening\n# Required-Start:    $all\n# Required-Stop:     $local_fs $remote_fs $syslog $named $network\n# Should-Start:\n# Should-Stop:\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Run system-hardening startup actions\n# Description:       Run system-hardening startup actions\n### END INIT INFO\n\n. \u002Flib\u002Flsb\u002Finit-functions\n\nlog_daemon_msg \"Added proc mount option (hidepid=2)\"\nmount -o remount,hidepid=2 \u002Fproc\nlog_end_msg $?\n",[50,330,331,337,341,346,351,356,361,366,372,378,384,390,396,402,407,415,420,429,443],{"__ignoreMap":131},[135,332,333],{"class":137,"line":138},[135,334,336],{"class":335},"s9BHP","#!\u002Fbin\u002Fbash\n",[135,338,339],{"class":137,"line":159},[135,340,185],{"emptyLinePlaceholder":184},[135,342,343],{"class":137,"line":181},[135,344,345],{"class":335},"### BEGIN INIT INFO\n",[135,347,348],{"class":137,"line":188},[135,349,350],{"class":335},"# Provides:          system-hardening\n",[135,352,353],{"class":137,"line":208},[135,354,355],{"class":335},"# Required-Start:    $all\n",[135,357,358],{"class":137,"line":213},[135,359,360],{"class":335},"# Required-Stop:     $local_fs $remote_fs $syslog $named $network\n",[135,362,363],{"class":137,"line":226},[135,364,365],{"class":335},"# Should-Start:\n",[135,367,369],{"class":137,"line":368},8,[135,370,371],{"class":335},"# Should-Stop:\n",[135,373,375],{"class":137,"line":374},9,[135,376,377],{"class":335},"# Default-Start:     2 3 4 5\n",[135,379,381],{"class":137,"line":380},10,[135,382,383],{"class":335},"# Default-Stop:      0 1 6\n",[135,385,387],{"class":137,"line":386},11,[135,388,389],{"class":335},"# Short-Description: Run system-hardening startup actions\n",[135,391,393],{"class":137,"line":392},12,[135,394,395],{"class":335},"# Description:       Run system-hardening startup actions\n",[135,397,399],{"class":137,"line":398},13,[135,400,401],{"class":335},"### END INIT INFO\n",[135,403,405],{"class":137,"line":404},14,[135,406,185],{"emptyLinePlaceholder":184},[135,408,410,412],{"class":137,"line":409},15,[135,411,88],{"class":195},[135,413,414],{"class":145}," \u002Flib\u002Flsb\u002Finit-functions\n",[135,416,418],{"class":137,"line":417},16,[135,419,185],{"emptyLinePlaceholder":184},[135,421,423,426],{"class":137,"line":422},17,[135,424,425],{"class":141},"log_daemon_msg",[135,427,428],{"class":145}," \"Added proc mount option (hidepid=2)\"\n",[135,430,432,435,437,439,441],{"class":137,"line":431},18,[135,433,434],{"class":141},"mount",[135,436,196],{"class":195},[135,438,199],{"class":145},[135,440,202],{"class":195},[135,442,205],{"class":145},[135,444,446,449],{"class":137,"line":445},19,[135,447,448],{"class":141},"log_end_msg",[135,450,451],{"class":195}," $?\n",[12,453,454],{},"Install the init script:",[126,456,458],{"className":128,"code":457,"language":130,"meta":131,"style":131},"$ insserv system-hardening\n",[50,459,460],{"__ignoreMap":131},[135,461,462,464,467],{"class":137,"line":138},[135,463,142],{"class":141},[135,465,466],{"class":145}," insserv",[135,468,469],{"class":145}," system-hardening\n",[12,471,472],{},"links\u002Fcredits to:",[474,475,476,484,490,496],"ul",{},[477,478,479],"li",{},[16,480,483],{"href":481,"rel":482},"http:\u002F\u002Fdebblog.philkern.de\u002F2012\u002F05\u002Flazyweb-question-how-to-avoid-leaking.html",[20],"Lazyweb question: How to avoid leaking process info? (by Philip Kern)",[477,485,486],{},[16,487,489],{"href":63,"rel":488},[20],"Debian bug report #669028: backport new procfs hidepid option into 3.2",[477,491,492],{},[16,493,495],{"href":45,"rel":494},[20],"kernel patch by Vasiliy Kulikov",[477,497,498],{},[16,499,502],{"href":500,"rel":501},"http:\u002F\u002Fblog.witalis.net\u002F?p=882",[20],"hidepid capabilities of procfs (by Witold Duranek)",[504,505,506],"style",{},"html pre.shiki code .sQJ0q, html code.shiki .sQJ0q{--shiki-light:#953800;--shiki-default:#953800;--shiki-dark:#FFA657}html pre.shiki code .s-BGO, html code.shiki .s-BGO{--shiki-light:#0A3069;--shiki-default:#0A3069;--shiki-dark:#A5D6FF}html pre.shiki code .s5nWI, html code.shiki .s5nWI{--shiki-light:#CF222E;--shiki-default:#CF222E;--shiki-dark:#FF7B72}html pre.shiki code .s_bOF, html code.shiki .s_bOF{--shiki-light:#1F2328;--shiki-default:#1F2328;--shiki-dark:#E6EDF3}html pre.shiki code .sDkKp, html code.shiki .sDkKp{--shiki-light:#0550AE;--shiki-default:#0550AE;--shiki-dark:#79C0FF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s9BHP, html code.shiki .s9BHP{--shiki-light:#6E7781;--shiki-default:#6E7781;--shiki-dark:#8B949E}",{"title":131,"searchDepth":159,"depth":181,"links":508},[],null,"2013-09-30","Hiding processes for other users using hidepid capabilities of procfs.",{"type":9,"value":513},[514,525,529,536],[12,515,14,516,22,519,22,522,33],{},[16,517,21],{"href":18,"rel":518},[20],[16,520,27],{"href":25,"rel":521},[20],[16,523,32],{"href":30,"rel":524},[20],[12,526,527],{},[37,528,39],{},[12,530,42,531,48,534,53],{},[16,532,47],{"href":45,"rel":533},[20],[50,535,52],{},[12,537,56,538,60,540,66,543,70,545,76,548,80,550,84,552,88],{},[37,539,59],{},[16,541,65],{"href":63,"rel":542},[20],[37,544,69],{},[16,546,75],{"href":73,"rel":547},[20],[37,549,79],{},[37,551,83],{},[37,553,87],{},"md","\u002Fimages\u002Fcovers\u002Fhtop-hidepid.jpg",{},"\u002Farticles\u002F20130930-hidepid-process-hiding",false,{"title":6,"description":511},"articles\u002F20130930-hidepid-process-hiding",[562,563,564],"sysadmin","linux","security","6k2ELokPFSzrXu4Ah5tGDDGgpR6H7AarK1sU6t4GWEM",[567,572],{"title":568,"path":569,"stem":570,"createdAt":571,"children":-1},"Proxmox VE Restricting Web UI access","\u002Farticles\u002F20130918-pve-restrict-webui-access","articles\u002F20130918-pve-restrict-webui-access","2013-09-18",{"title":573,"path":574,"stem":575,"createdAt":576,"children":-1},"Webapp-Scanner","\u002Farticles\u002F20140323-webapp-scanner","articles\u002F20140323-webapp-scanner","2014-03-23",1794961391566]