オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Contents of /tags/htdocs/1.8/tutorial-6.html.en

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4048 - (show annotations) (download)
Thu Oct 7 07:10:07 2010 UTC (13 years, 7 months ago) by kumaneko
File size: 28138 byte(s)


1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html lang="en-US">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title>The world of TOMOYO Linux&nbsp;&nbsp;The sixth installment: "Let's eradicate illegal logins."</title>
7 <link rel="stylesheet" href="http://tomoyo.sourceforge.jp/tomoyo.css" media="all" type="text/css">
8 </head>
9 <body>
10 <p style="text-align:right;"><a href="tutorial-6.html.ja">Japanese Page</a></p>
11 <p style="text-align:right;">Last modified: $Date$</p>
12
13 <h1>The world of TOMOYO Linux<br>The sixth installment: "Let's eradicate illegal logins."</h1>
14
15 <h2>Contents of this installment.</h2>
16
17 <p>By using secure OS, you can forbid accessing to resources which are not needed for providing services. Therefore, you can reduce damages when control of process was hijacked by exploiting buffer overflow vulnerability.</p>
18
19 <p>Then, what about login sessions of users who passed proper procedure (login authentication)? Needless to say, proper administrators have to be able to administrate the system as they intend. Then, secure OS cannot reduce damage if intruder passed login authentication. Therefore, the question is, how to reinforce login authentication while allowing proper administrators to operate what they need to do.</p>
20
21 <p>In TOMOYO Linux, you can reduce damages even if intruder passed login authentication, by utilizing TOMOYO Linux's domain authentication. In this installment, I explain steps for deploying illegal login buster system at no fee and steps for splitting administrator's jobs.</p>
22
23 <h2>About illegal login buster system</h2>
24
25 <h3>I want to prevent my systems from being used as steppingstone!</h3>
26
27 <p>Illegal logins against SSH services by password brute force attacks are increasing. As a result of illegal logins, systems are used as phishing sites or are installed malicious programs for attacking other hosts.</p>
28
29 <p>It is possible to install and execute malicious programs without administrator's privileges. You cannot say that "I don't care illegal logins to this server because there is no secret information on this server" or "No problem unless logged in as "root" user". When you become a victim, servers connected to the Internet make you of the victimizer at the same time. Thus, it is important to take precautions.</p>
30
31 <h3>I want to protect sensitive information!</h3>
32
33 <p>All Linux/UNIX systems support login authentication. There are means to reinforce login authentication such as PAM ( Pluggable Authentication Modules ) or public key authentication, but the concept of login authentication are basically identical. It is a question that it is appropriate thing to apply same authentication for personal-use servers and enterprise-use servers.</p>
34
35 <p>Don't you wish that you can apply login authentication depending on the intended use with appropriate level for that use? Hopefully without paying additional fee? TOMOYO Linux will provide a solution.</p>
36
37 <h3>Is it possible to enforce login authentication for multiple times?</h3>
38
39 <p>Regarding conventional countermeasure for illegal logins assumed that "We can do login authentication for only once. Thus, give up if ran through." Therefore, to realize as-safe-as-possible login authentication in the only one chance, public key authentications and biometrics authentications are getting introduced. Secure OS cannot solve this limitation.</p>
40
41 <p>However, TOMOYO Linux can solve this limitation. TOMOYO Linux realizes "We can do login authentication for as many times as we want. Thus, no need to worry for being run through." Therefore, you can use conventional login authentication for preventing illegal logins.</p>
42
43 <h3>Why it is possible to enforce for multiple times?</h3>
44
45 <p>TOMOYO Linux is not equipped with dedicated login authentication mechanisms. But you can reinforce login authentication by utilizing mandatory access control based on domain transition tree which I explained by now in this series.</p>
46
47 <p>By using TOMOYO Linux, you can very easily limit operations after login authentication to only "execute a program which performs additional user authentication". What is wonderful with this approach is that there is no limitation for available algorithm for the program which performs additional user authentication and is no need to follow internationally authorized standards, for the program is running on SSH server and protocol is handled by SSH service.</p>
48
49 <p>The only requirement for the program which performs additional user authentication is that the program executes next program (usually a shell program) when all conditions are met. The program cannot be bypassed because access to resources which are not permitted by policy is forbidden by mandatory access control.</p>
50
51 <p>For example, you can use a simple script like Fig. 1. You might think that "It makes no sense to embed password into the script file because everyone can read the script file.", but by using mandatory access control, you can make the contents of the script file unreadable. (If you are still worried, you can cut password out to external files or write the program using C language.)</p>
52
53 <p>I explain using a script program listed in Fig.1 as an example of reinforcement. Save the program listed in Fig. 1 as /bin/auth1 and make it executable by "chmod 755 /bin/auth1". Note that this program is just an example. When you apply on the real systems, please make programs using your favorite algorithms. More alien authentication methods, more difficult to run through the protection.</p>
54
55 <table border="1" summary="fig">
56 <tr><td>
57 &diams; Fig. 1&nbsp;&nbsp;A sample script for additional authentication<br>
58 <pre>
59 #! /bin/sh -p
60 for i in 1 2 3
61 do
62 echo -n 'Password: '
63 read -r -s passwd
64 echo
65 [ "$passwd" = "SAKURA" ] &amp;&amp; exec $SHELL
66 done
67 echo 'Incorrect password.'
68 </pre>
69 </td></tr>
70 </table>
71
72 <h3>Let's install</h3>
73
74 <p>I explain how to protect servers which provide SSH logins as an example. I assume /bin/bash is specified as login shells.</p>
75
76 <h4>&diams;Preparation</h4>
77
78 <p>Apply mandatory access control on "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain (a domain for login shell logged in via /usr/sbin/sshd ) and make the domain to allow only execution of programs permitted by policy configuration. (Note that if you don't apply mandatory access control on "&lt;kernel&gt; /usr/sbin/sshd" domain (a domain for /usr/sbin/sshd ), this restriction will be bypassed by executing other programs (e.g. /bin/tcsh ) from /usr/sbin/sshd .)</p>
79
80 <p>Firstly, make sure that "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain is not specified using keep_domain keyword. ( keep_domain keyword is explained in the third installment of this series.) If "keep_domain &lt;kernel&gt; /usr/sbin/sshd /bin/bash" is specified, delete the entry using policy editor.</p>
81
82 <p>Also, if you don't apply mandatory access control on "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" domain (a domain for shell after passing additional authentication) and its descendent domains, you can add "keep_domain &lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" using policy editor because you don't need to transit domains. (Fig. 2)</p>
83
84 <table border="1" summary="fig">
85 <tr><td>
86 &diams; Fig. 2&nbsp;&nbsp;Domain transition tree for reinforcing authentication<br>
87 <img src="tutorial/fig-6-2.png" alt="fig-6-2.png" width="800" height="600">
88 </td></tr>
89 </table>
90
91 <h4>&diams;Learning</h4>
92
93 <p>In the second installment of this series, we defined profiles listed in Fig. 3. Thus, I use these profiles for this installment. Change domains for login shells logged via /usr/sbin/sshd to learning mode. Run commands listed in Fig. 4 from console.</p>
94
95 <table border="1" summary="fig">
96 <tr><td>
97 &diams; Fig. 3&nbsp;&nbsp;Profile for this installment<br>
98 <pre>
99 PROFILE_VERSION=20090903
100 0-CONFIG::file={ mode=disabled }
101 1-CONFIG::file={ mode=learning }
102 2-CONFIG::file={ mode=permissive }
103 3-CONFIG::file={ mode=enforcing }
104 </pre>
105 </td></tr>
106 </table>
107
108 <table border="1" summary="fig">
109 <tr><td>
110 &diams; Fig. 4&nbsp;&nbsp;Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain and its descendent domains to learning mode
111 <pre>
112 # /usr/sbin/ccs-setprofile -r 1 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash'
113 </pre>
114 </td></tr>
115 </table>
116
117 <p>Login via /usr/sbin/sshd and execute /bin/auth1 . You are prompted for a password. Thus, enter "SAKURA" and press "Enter" key. The authentication will succeed and /bin/bash (which is set to environment variable SHELL ) is executed. (Fig. 5)</p>
118
119 <table border="1" summary="fig">
120 <tr><td>
121 &diams; Fig. 5&nbsp;&nbsp;Let TOMOYO Linux learn /bin/bash is executed after passing authentication by /bin/auth1
122 <pre>
123 # /bin/auth1
124 Password: SAKURA
125 #
126 </pre>
127 </td></tr>
128 </table>
129
130 <p>Now, permissions for performing additional authentication were learned. Type "exit" for twice to logout from /usr/sbin/sshd .</p>
131
132 <h4>&diams;Verify and enforce</h4>
133
134 <p>Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain and its descendent domains to permissive mode, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" domain and its descendent domains to disabled mode. Run commands listed in Fig. 6 from console.</p>
135
136 <table border="1" summary="fig">
137 <tr><td>
138 &diams; Fig. 6&nbsp;&nbsp;Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain and its descendent domains to permissive mode, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" domain and its descendent domains to disabled mode
139 <pre>
140 # /usr/sbin/ccs-setprofile -r 2 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash'
141 # /usr/sbin/ccs-setprofile -r 0 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash'
142 </pre>
143 </td></tr>
144 </table>
145
146 <p>At this state, login via /usr/sbin/sshd and execute /bin/auth1 . Check that error messages are not printed. Then, change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain and its descendent domains to enforcing mode, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" domain and its descendent domains to disabled mode. Run commands listed in Fig. 7 from console.</p>
147
148 <table border="1" summary="fig">
149 <tr><td>
150 &diams; Fig. 7&nbsp;&nbsp;Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain and its descendent domains to enforcing mode, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" domain and its descendent domains to disabled mode
151 <pre>
152 # /usr/sbin/ccs-setprofile -r 3 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash'
153 # /usr/sbin/ccs-setprofile -r 0 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash'
154 </pre>
155 </td></tr>
156 </table>
157
158 <p>You've finished installation. Don't you think it is easy?</p>
159
160 <h4>&diams;Let's pretend an attacker</h4>
161
162 <p>Let's test the power of this system by assuming that an intruder succeeded to login by password brute force attack or without login authentication by attacking buffer overflow vulnerability. (Fig. 8)</p>
163
164 <table border="1" summary="fig">
165 <tr><td>
166 &diams; Fig. 8&nbsp;&nbsp;All commands except auth1 command are rejected
167 <pre>
168 Last login: Tue Feb 27 17:12:10 2007
169 # whoami
170 -bash: /usr/bin/whoami: Operation not permitted
171 # /bin/auth1
172 Password: password
173 Password: root
174 Password: guest
175 Incorrect password.
176 # exec 4&lt;/bin/auth1; while read -u 4; do echo $REPLY; done
177 -bash: /bin/auth1: Operation not permitted
178 -bash: read: 4: invalid file descriptor: Bad file descriptor
179 # exit
180 </pre>
181 </td></tr>
182 </table>
183
184 <p>The intruder succeeded to login via /usr/sbin/sshd , but the intruder does not know what operations are permitted (because the intruder cannot execute commands for reading the policy configuration). Any commands the intruder attempted to execute randomly are denied, except the auth1 command. If the intruder did not know about secure OS, the intruder will be surprised.</p>
185
186 <p>The intruder after all goes away. Even if the intruder found that the intruder can execute /bin/auth1 command, the intruder cannot know what the /bin/auth1 is doing because the intruder cannot read the script. (WARNING: Note that regarding shell script programs, if environment variable "SHELLOPS" is set to "verbose:noexec", the contents of the script file will be printed by executing /bin/auth1 command. Thus, when you install this system on real systems, I recommend you to write programs using programming languages that won't be affected by environment variables.) Therefore, the intruder has to go away.</p>
187
188 <p>The legal user knows what operations are permitted. Thus, the legal user immediately executes /bin/auth1 command and proceeds by entering correct password. (Fig. 9)</p>
189
190 <table border="1" summary="fig">
191 <tr><td>
192 &diams; Fig. 9&nbsp;&nbsp;Execute /bin/auth1 and enter correct password
193 <pre>
194 Last login: Tue Feb 27 17:14:10 2007
195 # /bin/auth1
196 Password: SAKURA
197 # whoami
198 root
199 # exec 4&lt;/bin/auth1; while read -u 4; do echo $REPLY; done
200 #! /bin/sh
201 for i in 1 2 3
202 do
203 echo -n 'Password: '
204 read -r -s passwd
205 echo
206 [ "$passwd" = "SAKURA" ] &amp;&amp; exec $SHELL
207 done
208 echo 'Incorrect password.'
209 #
210 </pre>
211 </td></tr>
212 </table>
213
214 <p>If you think it is insufficient to use only /bin/auth1 , you can create /bin/auth2 and /bin/auth3 , and install these programs in serial direction. And you can assign a profile for disabled mode to "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash /bin/auth2 /bin/bash /bin/auth3 /bin/bash" domain. TOMOYO Linux's domain transition is useful when describing hierarchical processing procedure.</p>
215
216 <h3>Cases where this approach cannot be applied</h3>
217
218 <p>The protection I explained above are applicable for cases like SSH login or Telnet login (where mapping of process and user is persistent and a shell program which allows execution of arbitrary commands are provided). The protection is not applicable for cases like HTTP login (where TCP connections are disconnected every time) or FTP login (where a shell program is not provided).</p>
219
220 <p>To apply this approach to the programs which are directly executed from login shell (e.g. scp command and sftp command), you can use execute_handler feature which TOMOYO Linux provides. (I explain about execute_handler at the bottom of this installment.) Also, you can restrict accessible resources by these programs by using mandatory access control which secure OS provides. For example, you can allow these programs to access files under "scp" directory of user's home directory. Since scp command and sftp command are directly executed from login shells, domains for these programs will be "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /usr/bin/scp" and "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /usr/libexec/openssh/sftp-server". The roughly written policy configuration for these domains will look like Fig. 10. (Files like library files are omitted in Fig. 10.)</p>
221
222 <table border="1" summary="fig">
223 <tr><td>
224 &diams; Fig. 10&nbsp;&nbsp;Policy configuration for scp command<br>
225 <pre>
226 &lt;kernel&gt; /usr/sbin/sshd /bin/bash /usr/bin/scp
227 use_profile 3
228 file create /home/\*/scp/\* 0-0666
229 file create /home/\*/scp/\{\*\}/\* 0-0666
230 file unlink /home/\*/scp/\*
231 file unlink /home/\*/scp/\{\*\}/\*
232 file read/write /home/\*/scp/\*
233 file read/write /home/\*/scp/\{\*\}/\*
234 </pre>
235 </td></tr>
236 </table>
237
238 <p>By defining pathname groups using "path_group" keyword in exception policy like Fig. 11, you can simply describe in domain policy like Fig. 12.</p>
239
240 <table border="1" summary="fig">
241 <tr><td>
242 &diams; Fig. 11&nbsp;&nbsp;Grouping files for scp command<br>
243 <pre>
244 path_group SCP_FILE /home/\*/scp/\*
245 path_group SCP_FILE /home/\*/scp/\{\*\}/\*
246 </pre>
247 </td></tr>
248 </table>
249
250 <table border="1" summary="fig">
251 <tr><td>
252 &diams; Fig. 12&nbsp;&nbsp;Policy configuration using Fig. 11<br>
253 <pre>
254 &lt;kernel&gt; /usr/sbin/sshd /bin/bash /usr/bin/scp
255 use_profile 3
256 file create @SCP_FILE 0-0666
257 file unlink @SCP_FILE
258 file read/write @SCP_FILE
259 </pre>
260 </td></tr>
261 </table>
262
263 <p>You can add conditions like path1.uid=task.uid as needed.</p>
264
265 <p>SSH encrypts data on communication channel, but SSH does not encrypt files on filesystems. For more security, by encrypting files to be transferred via scp command or sftp command using gpg command, you can protect files on directories accessed by scp command or sftp command even if SSH login authentication was run through.</p>
266
267 <h2>About dividing administrator's privileges</h2>
268
269 <h3>Conventional approach</h3>
270
271 <p>Conventional approach is implemented in the application layer (e.g. restricting commands to be executed using sudo command). But implementation on application layer has been annoying administrators because sometimes bypassed by e.g. OS command injection vulnerability.</p>
272
273 <h3>New approach based on secure OS</h3>
274
275 <p>Many of secure OSes are equipped with RBAC ( Role Based Access Control ) functionality. By using RBAC, you can restrict execution of programs and read/write of files based on the role. RBAC is a useful feature for actual operations.</p>
276
277 <h3>Dividing privileges using TOMOYO Linux</h3>
278
279 <p>TOMOYO Linux is not equipped with dedicated RBAC mechanisms. But you can do access control similar to RBAC by utilizing mandatory access control based on domain transition tree.</p>
280
281 <p>In SELinux, roles are defined by grouping multiple domains and users are assigned roles. When a user needs to transit to different domain which is not included in the current role, the user changes roles which contain domains which the user wants to belong to.</p>
282
283 <p>TOMOYO Linux does not have the concept of "role". However, the "domain" itself corresponds with "role" of the moment. (Thus, you don't need to aware "role" in TOMOYO Linux.) Assigning a domain means assigning a role at the same time.</p>
284
285 <h3>Let's install</h3>
286
287 <p>I explain how to delegate only management of WWW servers (e.g. restarting WWW server and updating WWW contents) to somebody else as an example. I assume /bin/bash is specified as login shells.</p>
288
289 <p>Steps for actually installing are already explained by now. Regarding illegal login buster system, you enforce additional authentication in serial direction. (Fig. 13) Regarding dividing administrator's privileges, you enforce additional authentication in parallel direction. (Fig. 14)</p>
290
291 <table border="1" summary="fig">
292 <tr><td>
293 &diams; Fig. 13&nbsp;&nbsp;Domain transition tree before dividing administrator's privileges<br>
294 <img src="tutorial/fig-6-13-en.png" alt="fig-6-13-en.png" width="800" height="600">
295 </td></tr>
296 </table>
297
298 <table border="1" summary="fig">
299 <tr><td>
300 &diams; Fig. 14&nbsp;&nbsp;Domain transition tree after dividing administrator's privileges<br>
301 <img src="tutorial/fig-6-14-en.png" alt="fig-6-14-en.png" width="800" height="600">
302 </td></tr>
303 </table>
304
305 <p>Note that you need to assign a profile for enforcing mode (in this series, profile 3) to domains after additional authentication. If a user once reached a domain where a profile for non-enforcing mode is assigned, you can no longer restrict the user (i.e. you can no longer divide administrator's privileges).</p>
306
307 <h4>&diams;Preparation</h4>
308
309 <p>First, make sure that "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain is not specified using "keep_domain" keyword. Also, specify "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" domain (a domain after passing additional authentication by /bin/auth1 ) and "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash" domain (a domain after passing additional authentication by /bin/auth2 ) using "keep_domain" keyword.</p>
310
311 <p>I assume /bin/auth1 for being used for authenticating yourself with full privileges and /bin/auth2 for being used for authenticating someone with only privileges for managing WWW servers.</p>
312
313 <h4>&diams;Learning</h4>
314
315 <p>Steps for learning are the same with illegal login buster system.</p>
316
317 <p>Run commands listed in Fig. 15 from console.</p>
318
319 <table border="1" summary="fig">
320 <tr><td>
321 &diams; Fig. 15&nbsp;&nbsp;Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" and its descendent domains to learning mode
322 <pre>
323 # /usr/sbin/ccs-setprofile -r 1 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash'
324 </pre>
325 </td></tr>
326 </table>
327
328 <p>At this state, login via /usr/sbin/sshd and execute /bin/auth1 and /bin/auth2 respectively. When you pass the authentication, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" domain and "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash" are created and necessary permissions are learned.</p>
329
330 <p>Then, change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain and its descendent domains to enforcing mode, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" domain and its descendent domains to disabled mode, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash" domain and its descendent domains to learning mode. Run commands listed in Fig. 16 from console.</p>
331
332 <table border="1" summary="fig">
333 <tr><td>
334 &diams; Fig. 16&nbsp;&nbsp;Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" and its descendent domains to enforcing mode, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash" and its descendent domains to disabled mode, "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash" and its descendent domains to learning mode
335 <pre>
336 # /usr/sbin/ccs-setprofile -r 3 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash'
337 # /usr/sbin/ccs-setprofile -r 0 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth1 /bin/bash'
338 # /usr/sbin/ccs-setprofile -r 1 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash'
339 </pre>
340 </td></tr>
341 </table>
342
343 <p>At this state, login via /usr/sbin/sshd and execute /bin/auth2 . When you pass the authentication, you will reach "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash" domain. This domain does not create descendent domains because this domain is specified using "keep_domain" keyword.</p>
344
345 <p>Now, let TOMOYO Linux learn permissions needed for restarting WWW server. (Fig. 17)</p>
346
347 <table border="1" summary="fig">
348 <tr><td>
349 &diams; Fig. 17&nbsp;&nbsp;Let TOMOYO Linux learn permissions for restarting WWW server
350 <pre>
351 # service httpd start
352 # service httpd stop
353 # service httpd restart
354 </pre>
355 </td></tr>
356 </table>
357
358 <p>You may want to extract WWW contents uploaded using scp command or sftp command to under /var/www/html/ directory. Let TOMOYO Linux learn permissions for that operation. (Fig. 18)</p>
359
360 <table border="1" summary="fig">
361 <tr><td>
362 &diams; Fig. 18&nbsp;&nbsp;Let TOMOYO Linux learn permissions for extracting uploaded contents
363 <pre>
364 # cd /var/www/html/
365 # tar -zxf /home/demo/scp/web-contents.tar.gz
366 </pre>
367 </td></tr>
368 </table>
369
370 <p>You may want to execute text editor for updating WWW contents. Let TOMOYO Linux learn permissions for editor programs. (Fig. 19)</p>
371
372 <table border="1" summary="fig">
373 <tr><td>
374 &diams; Fig. 19&nbsp;&nbsp;Execute editor and let TOMOYO Linux learn the permissions
375 <pre>
376 # emacs
377 </pre>
378 </td></tr>
379 </table>
380
381 <p>You may want more. Also, you may want to patternize pathnames. Steps for patternizing pathnames are explained in the second installment of this series.</p>
382
383 <h4>&diams;Verify and enforce</h4>
384
385 <p>Make sure that you have enough permission for doing operations you want to allow. Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash" domain to permissive mode. Run commands listed in Fig. 20 from console.</p>
386
387 <table border="1" summary="fig">
388 <tr><td>
389 &diams; Fig. 20&nbsp;&nbsp;Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash" and its descendent domains to permissive mode
390 <pre>
391 # /usr/sbin/ccs-setprofile -r 2 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash'
392 </pre>
393 </td></tr>
394 </table>
395
396 <p>After you verified that all necessary permissions are given, change to enforcing mode. Run commands listed in Fig. 21 from console. You've finished installation. Although you need to let TOMOYO Linux learn permissions needed for operations, it does not need so much time. It is powerful.</p>
397
398 <table border="1" summary="fig">
399 <tr><td>
400 &diams; Fig. 21&nbsp;&nbsp;Change "&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash" and its descendent domains to enforcing mode
401 <pre>
402 # /usr/sbin/ccs-setprofile -r 3 '&lt;kernel&gt; /usr/sbin/sshd /bin/bash /bin/auth2 /bin/bash'
403 </pre>
404 </td></tr>
405 </table>
406
407 <h2>Advanced usage</h2>
408
409 <p>In the last of this installment, I introduce some Tips.</p>
410
411 <h3>Login shell</h3>
412
413 <p>Shell programs which are used as login shell (e.g. /bin/bash ) have a plenty set of built-in commands. For example, administrator can do evil things like forcibly terminating arbitrary processes using built-in "kill" command (if you don't enable restriction by CONFIG::ipc::signal , I explain CONFIG::ipc::signal in the next installment).</p>
414
415 <p>To prevent administrator from doing evil things, you can use falsh command which in included in TOMOYO Linux's tools package for login shells. (Fig. 22)</p>
416
417 <table border="1" summary="fig">
418 <tr><td>
419 &diams; Fig. 22&nbsp;&nbsp;Move falsh command to under /bin/ directory
420 <pre>
421 # mv /usr/lib/ccs/misc/falsh /bin/
422 </pre>
423 </td></tr>
424 </table>
425
426 <p>To change login shell to /bin/falsh , run commands listed in Fig. 23.</p>
427
428 <table border="1" summary="fig">
429 <tr><td>
430 &diams; Fig. 23&nbsp;&nbsp;Changing login shell to /bin/falsh
431 <pre>
432 # usermod -s /bin/falsh root
433 </pre>
434 </td></tr>
435 </table>
436
437 <h3>Restricting networking for server process</h3>
438
439 <p>/usr/sbin/sshd has an ability to relay TCP connections (e.g. port forwarding). By enabling restriction by CONFIG::network (which I explain in the next installment) to "&lt;kernel&gt; /usr/sbin/sshd" domain (a domain for /usr/sbin/sshd program), you can do stronger protection.</p>
440
441 <p>If a server program need not to establish TCP connections from server to client, by enabling restriction by CONFIG::network , you can prevent such program from being abused by worms and viruses as steppingstone for attacking other servers.</p>
442
443 <p>If you are sure that specific functionality is not needed for specific service, it worth to explicitly deny use of such functionality using mandatory access control's policy configuration.</p>
444
445 <h3>Batched processing using public key authentication</h3>
446
447 <p>If you are using batched processing which will automatically login via /usr/sbin/sshd using public key authentication, the approach I explained in this installment is useful.</p>
448
449 <p>You can divide domains like "&lt;kernel&gt; /usr/sbin/sshd /bin/bash" domain and "&lt;kernel&gt; /usr/sbin/sshd /bin/tcsh" domain by simply assigning different login shells for the account for batched processing (for example, /bin/tcsh ) and the account for interactive processing (in this series, /bin/bash ). (Fig. 24)</p>
450
451 <table border="1" summary="fig">
452 <tr><td>
453 &diams; Fig. 24&nbsp;&nbsp;Dividing domains<br>
454 <img src="tutorial/fig-6-24-en.png" alt="fig-6-24-en.png" width="800" height="340">
455 </td></tr>
456 </table>
457
458 <h2>Reference information</h2>
459
460 <p>For more information, please read below paper.</p>
461
462 <p><a href="http://sourceforge.jp/projects/tomoyo/docs/winf2005-en.pdf">Chained Enforceable Re-authentication Barrier Ensures Really Unbreakable Security</a></p>
463
464 <p>See below tutorials for examples of execute_handler usage.</p>
465
466 <ul>
467 <li><a href="ssh-split-administrative-tasks.html.en">Restricting administrative operations in SSH service.</a></li>
468 <li><a href="ssh-protection-using-environment.html.en">Anti SSH brute force attacks using environment variables.</a></li>
469 <li><a href="sftp-protection-using-environment-variable.html.en">Providing download-only / uploadable SFTP service with single user account using environment variable.</a></li>
470 <li><a href="ssh-recording-cmdline.html.en">Recording commandline for shell sessions.</a></li>
471 </ul>
472
473 <h2>Trailer</h2>
474
475 <p>In the next installment, I explain access control other than files.</p>
476
477 <p><a href="tutorial-5.html.en">Go back to the fifth installment.</a>&nbsp;&nbsp;<a href="tutorial-7.html.en">Proceed to the seventh installment.</a></p>
478
479 <hr>
480
481 <p><a href="index.html.en#tutorial">Return to index page.</a></p>
482 <p><a href="http://sourceforge.jp/"><img src="http://sourceforge.jp/sflogo.php?group_id=1973" width="96" height="31" alt="SourceForge.jp"></a></p>
483 </body>
484 </html>

Properties

Name Value
svn:keywords Date

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26