Paranoid Penguin - AppArmor in Ubuntu 9
Listing 2. The Finished Profile
# Last Modified: Mon Jun 15 21:29:38 2009
#include <tunables/global>
/usr/bin/spaztacle.sh {
#include <abstractions/base>
#include <abstractions/nameservice>
/bin/dash rix,
/bin/tar rix,
owner /home/** a,
/usr/bin/spaztacle.sh r,
/var/spaetzle/ r,
/var/spaetzle/** r,
}
Happily, if I run spaztacle.sh again, it still works. But, is AppArmor doing anything? I can make sure the new profile is loaded with this command:
bash-$ sudo aa-status
Here's part of its output:
apparmor module is loaded. 26 profiles are loaded. 13 profiles are in enforce mode. /usr/sbin/clamd /usr/sbin/cupsd /usr/bin/spaztacle.sh [...]
Great! The spaztacle.sh profile is loaded in enforce mode. Besides showing what profiles are loaded and in what mode, aa-status also lists which processes are being protected actively. Because spaztacle.sh isn't actually running at the moment, it doesn't turn up in aa-status' output as an active process, but that's okay—normally you'd expect server dæmons, not commands per se, to turn up in that part of aa-status' output.
There's just one more test we'll do to see if AppArmor is doing its job. The more astute among you may have noticed that there's a glaring flaw in my little shell script (Listing 1). Because I didn't contain $1 in quotation marks, it's possible for a mischievous user to execute spaztacle.sh like this:
bash-$ spaztacle.sh "tarfile.tar /etc/apparmor.d/"
When the tar command in spaztacle expands the command input, it will correctly interpret tarfile.tar as the target file, but will include not only /var/spaetzle but also /etc/apparmor.d/ in the tar archive! On the one hand, local file permissions still apply. This works only if users in question have read access to /etc/apparmor.d, which means that although they're tricking spaztacle.sh, they aren't copying anything they'd otherwise be unable to get at.
But on the other hand, this is unexpected behavior for my unfortunate script. I don't want users to be able to include arbitrary directories in their authorized backups of /var/spaetzle.
So I'm glad to see that if I actually try running spaztacle.sh that way with my new AppArmor profile in enforce mode, this is the result:
tar: /etc/apparmor.d: Cannot open: Permission denied tar: Error exit delayed from previous errors
The following message also has been written to /var/log/messages:
Jun 16 01:17:43 micksbox kernel: [57354.414567] type=1503 audit(1245133063.520:1004): operation="inode_permission" requested_mask="::r" denied_mask="::r" fsuid=1000 name="/etc/apparmor.d/" pid=28019 profile="/usr/bin/spaztacle.sh"
Success! AppArmor has correctly identified bad behavior on spaztacle.sh's part. And, the intended tar file (tarfile.tar) not only was created, it also contains the backup of /var/spaetzle that I did want the user to be able to create—only the unexpected part of spaztacle.sh's activity was blocked. Success indeed!
Using genprof may seem a little involved, but the man pages for genprof, logprof and apparmor.d explain most of what you need to know. The tutorials listed in Resources should be helpful too. I hope I've covered enough here to get you started using AppArmor on your own Ubuntu system!
Resources
bodhi.zazen's “Introduction to AppArmor” for Ubuntu: ubuntuforums.org/showthread.php?t=1008906
Official Ubuntu AppArmor User Guide: https://help.ubuntu.com/9.04/serverguide/C/apparmor.html
Official Ubuntu AppArmor Overview: www.ubuntu.com/products/whatisubuntu/serveredition/features/apparmor
Ubuntu Community AppArmor Documentation: https://help.ubuntu.com/community/AppArmor
“AppArmor Is Dead” (Blog Post by Russell Coker): etbe.coker.com.au/2008/08/23/apparmor-is-dead
“Go Ahead, Make My Day” (Response to Coker by Crispin Cowan): blogs.msdn.com/crispincowan/archive/2008/09/02/go-ahead-make-my-day.aspx
Novell AppArmor Developer Roadmap: developer.novell.com/wiki/index.php/Apparmor_dev
Miscellaneous, Interesting AppArmor Notes on the Ubuntu Wiki: https://wiki.ubuntu.com/AppArmor
The OpenSUSE Project's AppArmor Page: en.opensuse.org/Apparmor
“Security Features in SUSE 10.0” by Mick Bauer, LJ April 2006: www.linuxjournal.com/article/8783
“An Introduction to Novell AppArmor” by Mick Bauer, LJ August 2006: www.linuxjournal.com/article/9036
“Security Features in Ubuntu Server” by Mick Bauer, LJ April 2008: www.linuxjournal.com/article/10012
Mick Bauer (darth.elmo@wiremonkeys.org) is Network Security Architect for one of the US's largest banks. He is the author of the O'Reilly book Linux Server Security, 2nd edition (formerly called Building Secure Servers With Linux), an occasional presenter at information security conferences and composer of the “Network Engineering Polka”.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Dynamic DNS—an Object Lesson in Problem Solving
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Download the Free Red Hat White Paper "Using an Open Source Framework to Catch the Bad Guy"
- Tech Tip: Really Simple HTTP Server with Python
- Roll your own dynamic dns
4 hours 26 min ago - Please correct the URL for Salt Stack's web site
7 hours 38 min ago - Android is Linux -- why no better inter-operation
9 hours 53 min ago - Connecting Android device to desktop Linux via USB
10 hours 22 min ago - Find new cell phone and tablet pc
11 hours 20 min ago - Epistle
12 hours 49 min ago - Automatically updating Guest Additions
13 hours 57 min ago - I like your topic on android
14 hours 44 min ago - This is the easiest tutorial
21 hours 19 min ago - Ahh, the Koolaid.
1 day 2 hours ago
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
Ubuntu 9.10, soon to be
Ubuntu 9.10, soon to be released, has even more profiles. See:
https://wiki.ubuntu.com/KarmicKoala/TechnicalOverview#GNOME
https://wiki.ubuntu.com/KarmicKoala/TechnicalOverview#AppArmor
It should also be noted that the Ubuntu kernel team has put a lot of effort into getting AppArmor into the upstream kernel. See http://thread.gmane.org/gmane.linux.kernel.lsm/9493 for details. IMO, the future of AppArmor has never looked better.
I switched from Suse because
I switched from Suse because of their policy of messing with my system, I avoided distro's that implemented SELinux without my permission. I noticed the stealth introduction of AppArmor which I do not want and the fact there is no documentation of how to disable it. Is there any Linux distro left that allows me freedom of choice?
Disabling AppArmor is
Disabling AppArmor is documented here
Sorry for the bad link, See
Sorry for the bad link,
See https://help.ubuntu.com/community/AppArmor#Disable%20AppArmor%20framework for details on how to disable AppArmor.