apparmor介绍
AppArmor
AppArmor 类似于selinux ,主要的作用是设置某个可执行程序的访问控制权限,主要区别就在于apparmor是以路径(path)为基础,而selinux以i节点(inode)为基础
AppArmor ("Application Armor") is a security module for the Linux kernel, released under the GNU General Public License. AppArmor allows the system administrator to associate with each program a security profile that restricts the capabilities of that program. It supplements the traditional Unix discretionary access control (DAC) model by providing mandatory access control (MAC). It was included as of the 2.6.36 version of the mainline Linux kernel. Since 2009, Canonical Ltd. contributes to the ongoing AppArmor development.
In addition to manually specifying profiles, AppArmor includes a learning mode, in which violations of the profile are logged, but not prevented. This log can then be turned into a profile, based on the program's typical behavior.
AppArmor is implemented using the Linux Security Modules (LSM) kernel interface.
AppArmor is offered in part as an alternative to SELinux, which critics consider difficult for administrators to set up and maintain.[1] Unlike SELinux, which is based on applying labels to files, AppArmor works with file paths. Proponents of AppArmor claim that it is less complex and easier for the average user to learn than SELinux.[2] They also claim that AppArmor requires fewer modifications to work with existing systems:[citation needed] for example, SELinux requires a filesystem that supports "security labels", and thus cannot provide access control for files mounted via NFS. AppArmor is filesystem-agnostic.
AppArmor represents one of several possible approaches to the problem of restricting the actions that installed software may take.
The SELinux system generally takes a similar approach to AppArmor. One important difference is that SELinux identifies file system objects by inode number instead of path. This means that, for example, while a file that is inaccessible may become accessible under AppArmor when a hard link is created to it, SELinux would deny access through the newly created hard link.
While there has been considerable debate about which approach is better, there is as yet no strong evidence that either approach is preferable. Discussion about their relative merits often revolves around which approach is more aligned with existing Unix/Linux access control mechanisms, but Unix and Linux use a combination of path-based and inode-based access control. Note also that existing access control mechanisms remain in place with either system.[citation needed]
SELinux and AppArmor also differ significantly in how they are administered and how they integrate into the system.
Introduction
AppArmor is a Mandatory Access Control (MAC) system which is a kernel (LSM) enhancement to confine programs to a limited set of resources. AppArmor's security model is to bind access control attributes to programs rather than to users. AppArmor confinement is provided via profiles loaded into the kernel, typically on boot. AppArmor profiles can be in one of two modes: enforcement and complain. Profiles loaded in enforcement mode will result in enforcement of the policy defined in the profile as well as reporting policy violation attempts (either via syslog or auditd). Profiles in complain mode will not enforce policy but instead report policy violation attempts.
AppArmor is different from some other MAC systems on Linux in that it is path-based, allows for mixing of enforcement and complain mode profiles, uses include files to ease development and has a far lower barrier to entry than other popular MAC systems.
AppArmor is an established technology first seen in Immunix, and later integrated into Ubuntu, Novell/SUSE, and Mandriva. Core AppArmor functionality is in the mainline Linux kernel from 2.6.36 onwards; work is ongoing by AppArmor, Ubuntu and other developers to merge additional AppArmor functionality into the mainline kernel.
Example profile
From /etc/apparmor.d/usr.sbin.tcpdump on Ubuntu 9.04:
#include <tunables/global> /usr/sbin/tcpdump {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/user-tmp> capability net_raw,
capability setuid,
capability setgid,
capability dac_override,
network raw,
network packet, # for -D
capability sys_module,
@{PROC}/bus/usb/ r,
@{PROC}/bus/usb/** r, # for -F and -w
audit deny @{HOME}/.* mrwkl,
audit deny @{HOME}/.*/ rw,
audit deny @{HOME}/.*/** mrwkl,
audit deny @{HOME}/bin/ rw,
audit deny @{HOME}/bin/** mrwkl,
@{HOME}/ r,
@{HOME}/** rw, /usr/sbin/tcpdump r,
}
The above profile for tcpdump demonstrates several properties of AppArmor:
- profiles are simple text files
- comments are supported in the profile
- absolute paths as well as file globbing can be used when specifying file access
- various access controls for files are present. From the profile we see 'r' (read), 'w' (write), 'm' (memory map as executable), 'k' (file locking), and 'l' (creation hard links). There are others not demonstrated in this profile, including (but not limited to) 'ix' (execute and inherit this profile), 'Px' (execute under another profile, after cleaning the environment), and 'Ux' (execute unconfined, after cleaning the environment)
- access controls for capabilities are present
- access controls for networking are present
specificity in rule matching, ie the most specific rule matches (eg access to @{HOME}/bin/bad.sh is denied with auditing due to 'audit deny @{HOME}/bin/** mrwkl,' even though general access to @{HOME} is permitted with '@{HOME}/** rw,')
include files are supported to ease development and simplify profiles (ie #include <abstractions/base>,#include <abstractions/nameservice>, #include <abstractions/user-tmp>)
variables can be defined and manipulated outside the profile (#include <tunables/global> with @{PROC} and @{HOME})
AppArmor profiles are easy to read and audit
Please see More information below for full details on updating and developing profiles as well as instructions using AppArmor.
AppArmor in Ubuntu
AppArmor support was first introduced in Ubuntu 7.04, and is turned on by default in Ubuntu 7.10 and later. AppArmor confinement in Ubuntu is application specific with profiles available for specific binaries. With each release, more and more profiles are shipped by default, with more planned.
If a profile is not available for an application, users may create a profile and add it to /etc/apparmor.d. If a profile is not defined for a particular binary, the binary is not confined. See More information for details.
apparmor介绍的更多相关文章
- 当 tcpdump -w 遇到 Permission denied
为了定位问题,需要在Linux上使用tcpdump并且保存到文件,遇到了如下问题: tcpdump port 9001 -w xxtcpdump: xx: Permission denied 因为已经 ...
- KVM 介绍(8):使用 libvirt 迁移 QEMU/KVM 虚机和 Nova 虚机 [Nova Libvirt QEMU/KVM Live Migration]
学习 KVM 的系列文章: (1)介绍和安装 (2)CPU 和 内存虚拟化 (3)I/O QEMU 全虚拟化和准虚拟化(Para-virtulizaiton) (4)I/O PCI/PCIe设备直接分 ...
- Apparmor——Linux内核中的强制访问控制系统
AppArmor 因为最近在研究OJ(oline judge)后台的安全模块的实现,所以一直在研究Linux下沙箱的东西,同时发现了Apparmor可以提供访问控制. AppArmor(Appli ...
- LXC-Linux Containers介绍
Linux Containers,Linux的容器,容器嘛,可以想象成一个大的装东西的罐子,罐子口很大,里面可以装很多同样形状,只不过大小不同的小罐子.专业的话,叫做基于容器的操作系统层面的虚拟化技术 ...
- Docker学习总结之Run命令介绍
Docker学习总结之Run命令介绍 本文由Vikings(http://www.cnblogs.com/vikings-blog/) 原创,转载请标明.谢谢! 在使用Docker时,执行最多的命令某 ...
- 学习LSM(Linux security module)之三:Apparmor的前世今生和基本使用
感冒了,感觉一脑子浆糊,真是蛋疼. 先粗略讲一些前置知识. 一:MAC和DAC DAC(Discretionary Access Control),自主访问控制,是最常用的一类访问控制机制,意思为主体 ...
- 2.LXC和namespace介绍
lxc介绍 LXC又名Linux container,是一种虚拟化的解决方案,这种是内核级的虚拟化.(主流的解决方案Xen ,KVM, LXC) Linux Container容器是一种内核虚拟化技术 ...
- kvm详细介绍
KVM详解,太详细太深入了,经典 2016-07-18 19:56:38 分类: 虚拟化 原文地址:KVM详解,太详细太深入了,经典 作者:zzjlzx KVM 介绍(1):简介及安装 http:// ...
- ubuntu1604环境下mariadb启动卡住报错和apparmor基本使用
问题描述:Ubuntu 1604 新环境下使用apt安装的mariadb10版本,结果第二天就起不来了,很是郁闷 启动时会卡住,当时就慌了,这什么情况啊,昨天好好的今天就起不来了,过了一会儿就有返回信 ...
随机推荐
- 关于mysql的error-based injection payload
今天用sqlmap扫一个网站,想得到一个表的所有列名,注意到sqlmap用到的一个error-based payload的: 1 AND (SELECT 3174 FROM(SELECT COUNT( ...
- 【JS】Beginner3 & 4 & 5 & 6:Maths & Logic & Conditonal & Looping
1.number operator () * / + - 2.logic make decisions in code compare values to produce a boolean valu ...
- linux驱动程序之电源管理之linux的电源管理架构(3)
设备电源管理 Copyright (c) 2010 Rafael J. Wysocki<rjw@sisk.pl>, Novell Inc. Copyright (c) 2010 Alan ...
- Esper系列(九)NamedWindow语法create、Insert、select
功能:用于存储一种或多种类型的事件的集合,并能对所存储的事件进行增删改查操作. CreateNameWindow 根据已有的数据源构造 格式: 1 [context context_name] 2 ...
- Esper系列(三)Context和Group by
Context 把不同的事件按照框的规则框起来(规则框在partition by中定义),并且有可能有多个框,而框与框之间不会互相影响. 功能: 组合事件查询并进行分组,类型:Hash Context ...
- Codeforces2B - The least round way(DP)
题目大意 给定一个N*N的格子,每个格子里有一个非负数,要求你找出从左上角到右下角的一条路径,使得它满足路径上的格子里的数全部乘起来的积尾部0最少 题解 如果要产生0肯定是2*5得出来的,最终的乘积可 ...
- puppet yum仓库
http://tmz.fedorapeople.org/repo/puppet/epel/5/x86_64/ [epel-puppet] name=epel puppet baseurl=http:/ ...
- PHP中的生成XML文件的4种方法(转)
<?xml version="1.0" encoding="utf-8"?> <article> <item> <ti ...
- java中通过反射获取方法并且调用(getMethod和invoke深入)实践
为了支持业务的快速变更,往往采用可配置的方式,将业务逻辑的处理部分配置在数据库中或者XMl文件里.配置什么,如何配置才更灵活,That's a problem. 以数据库配置为例(xml相同),在数据 ...
- Windows上常见的集中布尔类型的比较
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:Windows上常见的集中布尔类型的比较.