2013년 4월 21일 일요일

SEA

SEAndorid

Security-Enhanced Android
정책의 이해


? 이 문서는 누구나 문서만으로 SEAndroid의 정책 관련 사항을 이해하고 활용할 수 있도록 만들어진 문서이다.

SEAndorid란?

? NSA(국제보안기구)에서 시작한 SELINUX 프로젝트를 Android에 맞게 만들어서 포팅한 것.
? SELINUX와 완전히 다르지는 않기 때문에 SELINUX의 자료들을 통하여 정책을 이해하려고 하면 편리함.

리눅스 보안 모듈 구조체(Linux Security Modules(LSM) framework)를 이용하여 커널에 의무 접근 제어(Mandatory Access Control - MAC)를 구현하는 것이다. SELinux에서 출발하였다. 기본적인 표준 리눅스 보안(Standard Linux Security)은 자유재량 접근 제어(Discretionary Access Control ? DAC) 모델이다. DAC 모델에서, 파일과 자원에 대한 결정권은 오직 해당 객체(objects)의 사용자(user id)에게 있고 소유권(ownership)에 따라 이뤄진다. 각 사용자와 그 사용자에 의해 실행된 프로그램은 자기에게 할당된 객체에 대해 전적으로 자유재량권을 갖는다. 이러한 상황에서는, 악의 있는 일반 혹은 루트 사용자(예로, setuid와 setgid)가 실행시킨 결함이 있는 소프트웨어를 통해 주어진 객체로 원하는 어떠한 일을 해도 막아낼 방법이 없다.

MAC 시스템은 위와 같은 빠져있는 요소들을 제공한다. 첫 째, 보안 정책을 모든 프로세스나 객체에 대하여 관리차원으로 규정 지을 수 있다. 둘 째, 커널에 SEAndorid를 구현하면, 모든 프로세스와 객체를 제어할 수 있다. 셋 째, 결정은 단지 인증된 사용자(user identity)에 의해서가 아니라 이용 가능한(available) 모든 보안 관련 정보에 근거하여 이뤄진다.

? DAC에서는 “chmod 777 file_name”과 같이 read write execute 권한이 사용자에게 귀속되어 있기 때문에 모든 것을 할 수 있는 root 권한을 획득하게 되면 시스템을 장악할 수 있다. 그러나 MAC에서는 그렇게 하지 못한다.

SEAndorid하에서 MAC는 모든 주체(subjects ? 사용자, 프로그램, 프로세스)와 객체(파일, 디바이스)에 대해서 국부적으로 허가(granular permissions)해 줄 수 있다. 응용프로그램에서 불필요한 부분은 제외하고 오직 필요한 기능에 대해서만 사용 권한을 안전하게 부여한다.

SEAndorid 구현은 역할과 유형 시행(Type Enforcement - TE)에 기초하여 추상적 사용자 수준 제어(abstracted user-level control)를 제공하는 역할 기반 접근 제어(role-based access control ? RBAC)를 사용한다. TE는 접근 제어를 처리하기 위해서 테이블(매트릭스)을 이용한다. 주체는 영역(domain)을 갖고 객체는 유형을 갖으므로, 매트릭스에서 교차조회하여 이들의 상호작용을 규정한다. 이는 리눅스 시스템에 있는 모든 동작자(actor)에 대하여 극단적으로 국부 제어를 가능케 한다.

? .TE 의 확장자를 가지는 정책 파일이 존재함.

SEAndorid 정책이란?
SEAndorid 정책은 사용자, 프로그램, 프로세스 그리고 이들의 동작 대상인 파일과 디바이스를 포함한 시스템 전체, 즉, 모든 주체와 객체에 대한 접근 허가(access permissions)를 기술한다

정책 소스는 최소 설치(ultra-minimal installations)에 포함되지 않는다. 유형과 영역에 대한 정책은 주체와 객체에 대한 보안 문맥과 구분해서 별도로 설정된다.

SEAndorid 목표 정책(SEAndorid targeted policy)이란?
처음 SEAndorid가 Android 에 포함됐을 때, NSA의 엄격한 정책이 시행됐었다. 시험 목적으로, 이는 그 엄격한 정책을 통해서 수백가지 문제점을 찾아낼 수 있었다. 뿐만 아니라, Android 사용자들의 다양한 환경에 단 하나의 엄격한 정책을 적용한다는 것은 실효성이 없다는 것이 명백히 드러났다. 기본 설치 이외의 것에 대해서 단일 엄격한 정책을 적용하는 것은 현지 일반 사용자에게 전문 지식(기술)을 요구하는 것이었다.
? SEAndroid는 포팅은 CTS(Compatibility Test Suite)를 만족하기 위하여 진행되고 있다. CTS는 구글에서 하는 테스트로 http://source.android.com/compatibility/index.html 에서 자세한 내요을 볼 수 있다.
? 전문 지식을 갖추었을 때 비로소 제대로된 시큐리티 정책을 만들 수 있음.

목표 정책 하에서, 대부분의 프로세스는 unconfined_t domain(무제한 영역)에서 가동된다. 그 이름이 의미하는 바와 같이, 이 프로세스들은 거의 SEAndorid 정책에 의한 제한을 받지 안는다.

특정 네트워크 데몬들은 전용 정책을 갖고 있어, 응용프로그램이 시작될 때, 무제한 정책(unconfined_t policy)이 전용 정책으로 전이된다. 예를 들면, 시스템 부팅시, init는 무제한 정책하에서 가동하지만, named가 시작할 때, named 영역으로 전이되고 적시에 적절한 정책에 의해 맞춰진다.


파일 문맥이란?
파일 문맥은 파일이나 디레토리의 보안 문맥을 기술하는 항구적 라벨(꼬리표)(persistent labels)을 만들기 위해 setfiles 명령에 의해 사용된다.

파일, 사용자, 프로세스의 보안 문맥을 확인하는 방법은?
새 옵션 ?Z는 주체나 객체의 문맥을 표시하기 위한 손쉬운 방법이다:

ls -alZ file.foo
id -Z
ps -eZ

? SELINUX, SEANDROID 모두 사용 가능

영역과 유형은 어떻게 다른가?
비록 영역이 프로세스의 유형으로 자주 언급될 지라도, 영역과 유형 사이에는 차이점이 없다. 이렇게 볼 때, 영역의 사용은 영역과 유형을 구분하는 전통적 TE 모델에 기인한다.



SEAndorid 제어하기

사용중인 정책을 교체하는 방법은? (아직 적용안됨)

한 가지 방법은 system-config-securitylevel을 사용하여 정책을 바꾸고 재명명(relabel)하도록 파일 시스템을 설정하는 것이다.

수작업 절차는 다음과 같다:

1. /etc/SEAndorid/config을 편집하고 SEANDORIDTYPE=policyname으로 정책 유형을 바꾼다.
2. 재부팅하여 돌아올 수 있는 지 확인하기위해, SEANDORID=permissive모드로 설정한다. 이렇게 하면, SEAndorid는 정확한 정책하에서 가동될 것이지만, 만일 부정확한 파일 문맥 명명( labeling)과 같은 문제가 있으면 로그인하도록 할 것이다.
3. sysadm_r 역할을 갖춘 root로 파일 시스템을 재명명한다(relabel):

id -Z
root:sysadm_r:sysadm_t
fixfiles relabel

옵션 -l /path/to/logfile을 사용하여 표준 출력으로 로그를 볼 수 있고, 옵션 -o /path/to/file을 사용하여 검토(checked)되거나 재명명(relabel ed)된 모든 파일 리스트를 저장할 수 있다.

4. 시스템을 재부팅한다. 새 정책하에서의 재시작은 모든 시스템 프로세 스가 적절한 문맥에서 시작되고 정책 변경으로 인한 모든 문제가 드 러나게 한다.
5. sestatus ?v 명령으로 발효된 변경사항을 확인한다. Permissive 모드로 가 동된 새 시스템에서, avc: denied 메시지를 /var/log/messages에서 확인한 다. 이들은 새 정책하에 문제없이 시스템이 가동되도록 해결해 야 할 문제들을 표시해 준다.(리눅스에서만 확인가능)

6. 새 정책하에서 시스템이 만족스럽게 돌아갈 때, SEANDORID=enforcing 으로 바꿔 실행 권한을 부여한다. 실시간에 enforcing을 활성화 시키기 위 해 재부팅하거나 setenforce 1 을 실행한다.

? 'selinux-utils'를 설치한 경우 enforce 모두로 변경 가능하다.
? Android의 경우 SEAndroid manager를 통해서 변경 가능하다.
(업데이트 필요)

? 리눅스의 경우 /etc/selinux/config 파일이 있어서 조정이 가능함

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
# default - equivalent to the old strict and targeted policies
# mls - Multi-Level Security (for military and educational use)
# src - Custom policy built from source
SELINUXTYPE=default

# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0



https://android-review.googlesource.com/#/q/sds%2540tycho.nsa.gov,n,001de09e0000795a

워픈 쏠쓰~

If3a65407 Extend forkAndSpecialize to take further input arguments. (Merged) Stephen Smalley platform/libcore master Jun 22
I22d38e3e Modify installd to set the SELinux security context on package directories. (Merged) Stephen Smalley platform/frameworks/base master Jun 9
Ifcc68cb0 Add JNI bindings for some of the libselinux interfaces. (Merged) Stephen Smalley platform/frameworks/base master Jun 9
I77c39b2c Fixes to make_ext4fs when compiled with HAVE_SELINUX. (Merged) Kenny Root platform/system/extras master Jun 1
Ic8635898 Extend mkyaffs2image to support setting SELinux security contexts in yaffs2 ... (Merged) Stephen Smalley platform/external/yaffs2 master Apr 7, 2012
Ica5fb73d Change the format command to always take the mount point as an argument. (Merged) Stephen Smalley platform/bootable/recovery master Apr 7, 2012
I5a63fd61 Support the setting of file security contexts in OTA and update packages. (Merged) Stephen Smalley platform/build master Apr 7, 2012
I7c6f59fe Pass the file_contexts configuration to mkyaffs2image and make_ext4fs. (Merged) Stephen Smalley platform/build master Apr 7, 2012
I4f6755fe Extend make_ext4fs() interface to allow callers to pass selabel_handle. (Merged) Stephen Smalley platform/system/extras master Mar 31, 2012
Ied379f26 Extend recovery and updater to support setting file security contexts. (Merged) Stephen Smalley platform/bootable/recovery master Mar 31, 2012
I09fb9d56 Add libselinux to LOCAL_STATIC_LIBRARIES wherever libext4_utils is used. (Merged) Stephen Smalley platform/bootable/recovery master Mar 31, 2012
Ief9c44ee Extend make_ext4fs to support setting SELinux security contexts in ext4 images. (Merged) Stephen Smalley platform/system/extras master Mar 31, 2012
I3907dd9a bionic: fix atfork hanlder_mutex deadlock (Merged) Jack Ren platform/bionic master Mar 27, 2012
Ia20941be Extend toolbox with SE Android support. (Merged) Stephen Smalley platform/system/core master Feb 25, 2012
I98ed752c Extend init and ueventd for SE Android. (Merged) Stephen Smalley platform/system/core master Feb 25, 2012
Ied54ffab Move variable declaration on its own line (Merged) Jean-Baptiste Queru platform/bionic master (cleanup) Jan 21, 2012
I9752a4f6 Use the AT_SECURE auxv flag to determine whether to enable secure mode. (Merged) Stephen Smalley platform/bionic master Jan 21, 2012
I78f5eb3d Add extended attribute (xattr) system call wrappers to bionic. (Merged) Stephen Smalley platform/bionic master Jan 21, 2012
Ibd586603 Add the files installed from external/sepolicy to the legacy prebuilts. (Abandoned) Stephen Smalley platform/build master Jan 19, 2012
Ib04d37b9 Add libselinux/include to SRC_HEADERS. (Abandoned) Stephen Smalley platform/build master Jan 19, 2012
I97479aec Add support for reloading policy from /data/system. (Merged) Stephen Smalley platform/system/core master Aug 14
If6af6c48 Set the SELinux security label on new directories. (Merged) Stephen Smalley platform/system/core master Aug 9
I25b53730 restorecon tombstone directory. (Merged) Robert Craig platform/system/core master Aug 9
I69529fb7 Add support for SE Android to the Settings app. (Merged) Stephen Smalley platform/packages/apps/Settings master Aug 9
I166ffc26 Modify init.rc and init.goldfish.rc for SE Android. (Merged) Stephen Smalley platform/system/core master Aug 2
I81070ea3 Add support for -R (recurse) to init chown builtin. (Abandoned) Stephen Smalley platform/system/core master Jul 30
Idfc0116f Fix for build error no support ARM mode `smc #0' (Abandoned) William Roberts kernel/omap android-omap-tuna-3.0 Jul 26
I61d34a9f Add support for MMAC install checks. (Abandoned) Robert Craig platform/frameworks/base master Jul 24
I9294592d Change selabel_open and label backends to take a const struct selinux_opt ... (Abandoned) Matthew Finifter platform/external/libselinux master Jul 24
I5e126b27 Introduce selinux_android_setfilecon2 to support passing seinfo argument. (Abandoned) Matthew Finifter platform/external/libselinux master Jul 24
I1ef40de2 Fix handling of app id 0. (Abandoned) Matthew Finifter platform/external/libselinux master Jul 24
Id9181190 Add support for the new username mapping in JB, and backward compatibility. (Abandoned) Matthew Finifter platform/external/libselinux master Jul 24
I3025ae27 Skip the ro. prefix before any MAC permission checks. (Abandoned) Matthew Finifter platform/system/core master Jul 24
I2bb78418 Implement SELinux/MAC permission checks for the init property service. (Abandoned) Matthew Finifter platform/system/core master Jul 24
I504dbcf3 Revise chown -R support. (Abandoned) Matthew Finifter platform/system/core master Jul 24
I0023a6e0 Code cleanups based on AOSP review of 36321. (Abandoned) Matthew Finifter platform/system/core master Jul 24
Idf37e083 Add support for -R to chown builtin. Fix restorecon fts flags. (Abandoned) Matthew Finifter platform/system/core master Jul 24
I62658858 s/LOG/ALOG/ in HAVE_SELINUX blocks (Merged) Joshua Brindle platform/frameworks/base master Jul 20
If39df42b Modiy mkyaffsimage for SELinux. (Merged) Robert Craig platform/external/yaffs2 master Jul 19
I9bd2c3fc Add property_contexts to SELINUX_DEPENDS. (Merged) Robert Craig platform/build master Jul 19
I2695c602 Fix SELinux labeling for system.img (Merged) Robert Craig platform/system/extras master Jul 19
If64c6bee s/LOGE/ALOGE/ in HAVE_SELINUX blocks (Merged) Joshua Brindle platform/dalvik master Jul 13
Idc8dff02 This property is set when HAVE_SELINUX:=true during build. (Merged) William Roberts platform/build master Jul 4
I2611671a Extend forkAndSpecialize to take additional inputs and to set the SELinux ... (Merged) Stephen Smalley platform/dalvik master Jun 29
I66045ffd Pass additional inputs when spawning apps via the Zygote and add SELinux ... (Merged) Stephen Smalley platform/frameworks/base master Jun 22

댓글 없음:

댓글 쓰기

국정원의 댓글 공작을 지탄합니다.

UPBIT is a South Korean company, and people died of suicide cause of coin investment.

 UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...