All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC]Kernel Built-in IDS extension
@ 2005-06-17  9:16 horietk
  2005-06-17 10:33 ` Luke Kenneth Casson Leighton
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: horietk @ 2005-06-17  9:16 UTC (permalink / raw)
  To: selinux

Hi,

I'm glad to announce the release of experimental kernel extensions to 
SELinux access control, which enables intrusion detection and system 
protection functionalities.

The extensions have following features.
1. Detecting the access violation and can log that trial.
2. Operating booleans of 'Conditional Policy' when the access violation 
is detected.
3. Kernel built-in implementation. All the detections and the operations 
are performed within kernel.
4. To specify access contexts to be detected and boolean variables to be 
turned on, extended policy notation was introduced, which resembles the 
'allow' statement.

   trap <subject> <object>:<class> <permissions> <booleans> ;

Also, the AVC 'detected' log is recorded. (see below)

"Jun 13 10:05:47 molder kernel: audit(1118624747.611:0): avc:  detected  
{ execute } for  pid=4126 exe=/usr/sbin/in.ftpd name=sh dev=dm-0 
ino=3572008 scontext=scontext=system_u:system_r:ftpd_t 
tcontext=system_u:object_r:shell_exec_t tclass=file"

I believe that these features are useful in some cases.
For examaple, it is possible to detect harzardous access context which 
appears only when malicious operation is tried and to apply more 
restricted policy by means of turning on booleans automatically.

example) buffer overflow detection and system protection.
  bool etc_locked false ;
  bool bool_locked false ;
  trap ftpd_t shell_exec_t:file { execute } { etc_locked bool_locked } ;
  if (etc_locked) {
     /* read only, no one can change /etc files  */
     allow sysadm_t etc_t:file { r_file_perms }; 
  } else {
     /* sysadm can edit /etc files */
     allow sysadm_t etc_t:file { rw_file_perms }; 
  }
  if (!bool_locked) {
     /* sysadm can operate booleans */
     allow sysadm_t security_t:security setbool;
  }

If an unauthorized shell execution tried by ftpd is detected, kernel 
itself performs policy modification.

Of course, not only 'unconditional trap' but also 'conditional trap' can 
be used too.
  bool bool_a false ;
  bool bool_b false ;
  bool bool_c false ;
  if (bool_a) {
     trap xxx_t yyy_t:file { perms } { bool_b } ;
  } else {
     trap xxx_t yyy_t:file { perms } { bool_a bool_c } ;
  }
So, rather complicated boolean operations can be determined.

The patches and the documents are available at SourceForge site.
  http://sourceforge.net/projects/lk-ids

There are three patches.
[1] kernel patch (to version 2.6.11)
 - Member correspoding to 'trap' vector is added to avtab and policydb 
structures. (Mainly avc.h and avtab.h modifications)
 - Requested permission is compared with 'trap' vector, separate from 
SELinux's permission check. (Mainly avc.c modifications)
 - Internal boolean operation by kernel itself. (Mainly conditional.c 
and selinuxfs.c)
[2] checkpolicy patch (to version 1.22)
[3] libsetools patch (to version 1.4)
 - Policy parser, compiler and related library are extended to meet 
'trap' notation.

I hope I could have a lot of comments, suggestions and feedbacks.

Best regards,

-----
NTT DATA CORPORATION
Open Source Software Development Center
Takashi Horie
E-Mail: horie-t@users.sourceforge.net
E-Mail: horietk@nttdata.co.jp

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 9+ messages in thread
* RE: [RFC]Kernel Built-in IDS extension
@ 2005-06-21 10:24 horietk
  2005-06-21 12:32 ` Stephen Smalley
  0 siblings, 1 reply; 9+ messages in thread
From: horietk @ 2005-06-21 10:24 UTC (permalink / raw)
  To: sds, selinux

Thanks a lot.
I appreciate helpful comments, especially, about in-depth AVC 
implementations.

> -----Original Message-----
> 
> Did you consider a userspace implementation, e.g. extend 
> auditd to match
> against avc messages it receives from the kernel (likely using a
> libsepol function to perform the matching), and then having auditd
> adjust boolean settings in response to particular avc messages?

Certainly, I agree that the logging daemon based implementation is much 
simpler than kernel based one. But I think syslogd may not be reliable 
enough for this kind of purpose, i.e. printk() loses some of messages 
under very high load. So this is one of benefits which kernel based 
implementation gives.

> Also, it appears that your trap syntax only allows you to enable
> booleans upon events, whereas I could envision one wanting to disable
> booleans as well.  Otherwise, people have to contort their boolean
> definitions to correspond with this limitation.

I should have considered impacts on boolean definition. TRAP notation, 
as well as data structure, will be modified in next release, such like 
this,
example) 
   trap <subject> <object>:<class> <permissions> <bools_operations> ;

> A few quick comments based on a cursory read of the kernel patch:
> 
> - A transient memory failure could cause the trap information to be
> dropped from an AVC node in avc_node_populate(), with not even a log
> message warning about it - thus you could fail to properly trap an
> access under memory pressure.  In contrast, allocation failure for the
> node itself by avc_insert() does no harm - the existing
> avc_has_perm_noaudit() code just falls back to using the 
> temporary entry
> on the stack that was filled by security_compute_av() to finish the
> checking.

Current implementation resulted from booleans management data structure 
used by trap. It may be changed in next release and also some codes will 
be added to handle memory allocation failures properly.

> - avc_has_perm() cannot invoke any potentially blocking (sleeping)
> operations, because it can be called from irq or while locks 
> are held by
> the kernel.  Hence, your code (e.g. sel_set_booles_by_trap) likewise
> cannot invoke any potentially blocking operations, like down.  Of
> course, taking that particular semaphore and using the shared
> bool_pending_values is suspect anyway, and you already have a 
> kludge to
> avoid double locking in the load_policy case (and the setbool 
> case would
> also be a problem for you).  Why not just create and use your own
> temporary value array so that you don't have any locking issue there?

I checked out the issue you pointed out. load_policy problem seems 
resolved by changing blocking operation.

> - avc_detect_perm_noaudit() calls security_compute_av() and 
> avc_insert()
> after updating the booleans.  The boolean update will have flushed the
> cache entirely (which is necessary, as the booleans may have affected
> multiple entries), so you might as well just wait and let the cache
> re-fill in the usual manner upon subsequent permission 
> checks.  It also
> doesn't make sense for it to change avd because it is only used by
> avc_audit(), which has already been called, and you don't 
> want to adjust
> that result for the new booleans (because avc_has_perm made its
> decisions based on the old boolean settings).

I misread kernel codes related to avd handling. Of-course, it's 
unnecessary operation. Thanks for pointing out!

> Note that self:process execmem makes a good candidate for a trap, as
> that reflects an attempt to make anonymous memory executable, e.g. an
> attempt to make the stack executable.

I agree that execmem is more robust/generic target to detect suspicious 
operations. It's more difficult to choose appropriate access context to 
trap than configuring policy.


Currently, I have a plan for integrating IDS functionality with MLS 
instead of boolean. This implementation will make trap description more 
flexible and stateful. The following usage is intended.

example) Progressive access policy
By means of detecting symbolic access context which indicates transition 
to the next processing phase, the privileges of running daemon can be 
changed according to its progress. 

It provides similar functionality to domain trasition. But no execve() 
is needed. I think it's more secure way because the daemon's privileges 
can be configured such that the process is only allowed the privileges 
which are needed exactly at that point.

How about this plan?

Regards,

-----
NTT DATA CORPORATION
Open Source Software Development Center
Takashi Horie
E-Mail: horie-t@users.sourceforge.net
E-Mail: horietk@nttdata.co.jp

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-06-21 12:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-17  9:16 [RFC]Kernel Built-in IDS extension horietk
2005-06-17 10:33 ` Luke Kenneth Casson Leighton
2005-06-17 11:44 ` Lorenzo Hernández García-Hierro
2005-06-17 13:02 ` Stephen Smalley
2005-06-17 16:08   ` James Morris
2005-06-20  6:21     ` Russell Coker
2005-06-17 14:00 ` Stephen Smalley
  -- strict thread matches above, loose matches on Subject: below --
2005-06-21 10:24 horietk
2005-06-21 12:32 ` Stephen Smalley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.