SlideShare a Scribd company logo
An overview on AppArmor
‫ارائه‬
‫کالسی‬
‫درس‬
‫امنیت‬
‫پایگاه‬
‫داده‬
‫دانشگاه‬
‫صنعتی‬
‫شریف‬
: ‫ارائه‬
‫دهندگان‬
‫ابوالفضل‬
‫فرهادی‬ - ‫امیرحسین‬
‫آشناور‬
: ‫استاد‬
‫درس‬
‫دکتر‬
‫صادق‬
‫دری‬
‫نوگورانی‬
‫نیمسال‬1401-1400
What is AppArmor ?
AppArmor is Mandatory Access Control (MAC) like security system for Linux.
AppArmor security policies completely define what system resources
individual applications can access, and with what privileges.
AppArmor secures applications by enforcing good application behavior
without relying on attack signatures, so it can prevent attacks even if
previously unknown vulnerabilities are being exploited.
Unconfined programs are run under standard Linux Discretionary Access
Control (DAC) security. AppArmor augments traditional DAC in that confined
programs are evaluated under traditional DAC first and if DAC allows the
behavior then AppArmor policy consulted.
How does AppArmor work ?
In AppArmor, processes are restricted by profiles , these profiles are stored in
the /etc/apparmor.d directory. These profiles are plain-text files that can
contain comments .
In addition to manually creating profiles, AppArmor includes a learning mode,
in which profile violations are logged, but not prevented. This log can then be
used for generating an AppArmor profile, based on the program's typical
behavior.
Profiles can run in “complain mode” or “enforce mode ” that will be described
next .
Enforce mode vs. Complain mode
Enforce – In the enforce mode, system begins enforcing the rules and report
the violation attempts in syslog or auditd (only if auditd is installed) and
operation will not be permitted.
Complain – In the complain mode, system doesn’t enforce any rules. It will only
log the violation attempts.
Syntax of security profiles for AppArmor* part 1
PROFILE = ( PROFILE HEAD ) [ ATTACHMENT SPECIFICATION ] [ PROFILE FLAG CONDS ] '{' (RULES )* '}'
PROFILE HEAD = [ 'profile' ] FILEGLOB | 'profile' PROFILE NAME
FILEGLOB = ( QUOTED FILEGLOB | UNQUOTED FILEGLOB )
QUOTED FILEGLOB = '"' UNQUOTED FILEGLOB '"'
UNQUOTED FILEGLOB = (must start with '/' (after variable expansion), AARE have special meanings; see below. May
include VARIABLE. Rules with embedded spaces or tabs must be quoted. Rules must end with '/' to apply to
directories.)
PROFILE FLAG CONDS = [ 'flags=' ] '(' comma or white space separated list of PROFILE FLAGS ')'
PROFILE FLAGS = 'complain' | 'audit' | 'enforce' | 'mediate_deleted' |'attach_disconnected' | 'chroot_relative'
VARIABLE = '@{' ALPHA [ ( ALPHANUMERIC | '_' ) ... ] '}'
VARIABLE ASSIGNMENT = VARIABLE ('=' | '+=') (space separated values)
*See https://manpages.ubuntu.com/manpages/xenial/man5/apparmor.d.5.html for full description
Syntax of security profiles for AppArmor part 2
FILE RULE = [ QUALIFIERS ] [ 'owner' ] ( 'file' | [ 'file' ] ( FILEGLOB ACCESS | ACCESS FILEGLOB ) [ '->' EXEC TARGET ] )
ACCESS = ( 'r' | 'w' | 'a' | 'l' | 'k' | 'm' | EXEC TRANSITION )+ (not all combinations are allowed)
EXEC TRANSITION =( 'ix' | 'ux' | 'Ux' | 'px' | 'Px' | 'cx' | 'Cx' | 'pix' | 'Pix' | 'cix' | 'Cix' | 'pux' | 'PUx' | 'cux' | 'CUx' | 'x'
)
A bare 'x' is only allowed in rules with the deny qualifier, everything else only without the deny qualifier.
r - read , w - write , a - append , deny x - disallow execute
EXEC TARGET = name
Requires EXEC TRANSITION specified
ACCESS TYPE = ( 'allow' | 'deny' )
QUALIFIERS = [ 'audit' ] [ ACCESS TYPE ]
Syntax of security profiles for AppArmor part 3
CAPABILITY RULE = [ QUALIFIERS ] 'capability' [ CAPABILITY LIST ]
CAPABILITY LIST = ( CAPABILITY )+
CAPABILITY = (lowercase capability name without 'CAP_' prefix; see capabilities )
NETWORK RULE = [ QUALIFIERS ] 'network' [ DOMAIN ] [ TYPE | PROTOCOL ]
DOMAIN = ( 'inet' | 'ax25' | 'ipx' | 'appletalk' | 'netrom' | 'bridge' | 'atmpvc' |
'x25' | 'inet6' | 'rose' | 'netbeui' | 'security' | 'key' | 'packet' | 'ash' |
'econet' | 'atmsvc' | 'sna' | 'irda' | 'pppox' | 'wanpipe' | 'bluetooth' | 'netlink' |
'unix' | 'rds' | 'llc' | 'can' | 'tipc' | 'iucv' | 'rxrpc' | 'isdn' | 'phonet' |
'ieee802154' | 'caif' | 'alg' | 'nfc' | 'vsock' | 'mpls' | 'ib' ) ','
TYPE = ( 'stream' | 'dgram' | 'seqpacket' | 'rdm' | 'raw' | 'packet' )
PROTOCOL = ( 'tcp' | 'udp' | 'icmp' )
What are important commands ?
aa-status _ check the current status
aa-enforce _ set profile to enforce mode (from disable or complain)
aa-complain _ set profile to complain mode (from diable or enforcement)
apparmor_parser _ to load/reload an altered policy
aa-genprof _ generate a new profile
aa-logprof _ used to change the policy when the binary/program is changed
aa-mergeprof _ used to merge the policies
Now let’s put it in practice …
aa-status
Use apt install apparmor-utils to make AppArmor commands available
aa-genprof <executable> for profile generation
Default profile
Sample application for testing AppArmor features , it fails to read from
file with default profile
File read access added
Use apparmor_parser to update or add profile
Now application can read file normally
Application fails to execute another app
Appropriate rule added
Now it can execute another app
Test app that can set fileToRead file owner to current user
New rule added , now Application can execute test app , ix shows that
test will be executed with its parent profile
Even with root privilege test could NOT change file’s owner , because
chroot capability was not defined in profile .
Stop AppArmor as a service
Start AppArmor as a service
ping.py script for pinging google.com
ping.py
Making ping.py executable
Testing ping executable
aa-genprof ping
Now it fails due to default profile …
aa-status shows ping profile is added .
Syslog after failed execution
ping updated profile
Changing ping profile mode to complain mode
Now ping is executed in complain mode
Syslog for complain mode execution
Syslog for complain mode execution
Reference:
• https://gitlab.com/apparmor/apparmor/-/wikis/Documentation
• https://wiki.ubuntu.com/AppArmor
• https://manpages.ubuntu.com/manpages/xenial/man5/apparm
or.d.5.html
• https://en.wikipedia.org/wiki/AppArmor
Thank you for your attention !

More Related Content

What's hot

Install ldap server
Install ldap serverInstall ldap server
Install ldap server
Mawardi 12
 
Apache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheApache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With Apache
Wildan Maulana
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guide
webhostingguy
 
httpd — Apache Web Server
httpd — Apache Web Serverhttpd — Apache Web Server
httpd — Apache Web Server
webhostingguy
 

What's hot (20)

2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server
2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server
2018 Student360 - Beyond xp_cmdshell - Owning the Empire Through SQL Server
 
Install ldap server
Install ldap serverInstall ldap server
Install ldap server
 
DerbyCon2016 - Hacking SQL Server on Scale with PowerShell
DerbyCon2016 - Hacking SQL Server on Scale with PowerShellDerbyCon2016 - Hacking SQL Server on Scale with PowerShell
DerbyCon2016 - Hacking SQL Server on Scale with PowerShell
 
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL Server
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL ServerSecure360 - Beyond xp cmdshell - Owning the Empire through SQL Server
Secure360 - Beyond xp cmdshell - Owning the Empire through SQL Server
 
TROOPERS 20 - SQL Server Hacking Tips for Active Directory Environments
TROOPERS 20 - SQL Server Hacking Tips for Active Directory EnvironmentsTROOPERS 20 - SQL Server Hacking Tips for Active Directory Environments
TROOPERS 20 - SQL Server Hacking Tips for Active Directory Environments
 
CRESTCon Asia 2018 - Config Password Encryption Gone Wrong
CRESTCon Asia 2018 - Config Password Encryption Gone WrongCRESTCon Asia 2018 - Config Password Encryption Gone Wrong
CRESTCon Asia 2018 - Config Password Encryption Gone Wrong
 
2017 Secure360 - Hacking SQL Server on Scale with PowerShell
2017 Secure360 - Hacking SQL Server on Scale with PowerShell2017 Secure360 - Hacking SQL Server on Scale with PowerShell
2017 Secure360 - Hacking SQL Server on Scale with PowerShell
 
Apache Presentation
Apache PresentationApache Presentation
Apache Presentation
 
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
2016 aRcTicCON - Hacking SQL Server on Scale with PowerShell (Slide Updates)
 
2017 Thotcon - Hacking SQL Servers on Scale with PowerShell
2017 Thotcon - Hacking SQL Servers on Scale with PowerShell2017 Thotcon - Hacking SQL Servers on Scale with PowerShell
2017 Thotcon - Hacking SQL Servers on Scale with PowerShell
 
BMC Discovery (ADDM) Cheat Sheet by Traversys Limited
BMC Discovery (ADDM) Cheat Sheet by Traversys LimitedBMC Discovery (ADDM) Cheat Sheet by Traversys Limited
BMC Discovery (ADDM) Cheat Sheet by Traversys Limited
 
2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL2019 Blackhat Booth Presentation - PowerUpSQL
2019 Blackhat Booth Presentation - PowerUpSQL
 
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise securityMuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
MuleSoft ESB Payload Encrypt Decrypt using anypoint enterprise security
 
How To Install and Configure AWS CLI for Windows
How To Install and Configure AWS CLI for WindowsHow To Install and Configure AWS CLI for Windows
How To Install and Configure AWS CLI for Windows
 
Powershell Demo Presentation
Powershell Demo PresentationPowershell Demo Presentation
Powershell Demo Presentation
 
Apache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheApache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With Apache
 
Apache Web server Complete Guide
Apache Web server Complete GuideApache Web server Complete Guide
Apache Web server Complete Guide
 
httpd — Apache Web Server
httpd — Apache Web Serverhttpd — Apache Web Server
httpd — Apache Web Server
 
EMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG GermanyEMCLI Crash Course - DOAG Germany
EMCLI Crash Course - DOAG Germany
 
Java secure development part 3
Java secure development   part 3Java secure development   part 3
Java secure development part 3
 

Similar to Db Security Seminar AppArmor

User and group security migration
User and group security migrationUser and group security migration
User and group security migration
Amit Sharma
 

Similar to Db Security Seminar AppArmor (20)

Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravel
 
Web service with Laravel
Web service with LaravelWeb service with Laravel
Web service with Laravel
 
Apparmor
ApparmorApparmor
Apparmor
 
Infrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using TerraformInfrastructure-as-Code (IaC) using Terraform
Infrastructure-as-Code (IaC) using Terraform
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgniter
 
introduction to Laravel and its Basic and origin
introduction to Laravel and its Basic and originintroduction to Laravel and its Basic and origin
introduction to Laravel and its Basic and origin
 
Pluggable authentication modules
Pluggable authentication modulesPluggable authentication modules
Pluggable authentication modules
 
05 Creating Stored Procedures
05 Creating Stored Procedures05 Creating Stored Procedures
05 Creating Stored Procedures
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Solr Security: Tips and Tricks and Things You Really Ought to Know - Kevin Co...
Solr Security: Tips and Tricks and Things You Really Ought to Know - Kevin Co...Solr Security: Tips and Tricks and Things You Really Ought to Know - Kevin Co...
Solr Security: Tips and Tricks and Things You Really Ought to Know - Kevin Co...
 
Liferay hardening principles
Liferay hardening principlesLiferay hardening principles
Liferay hardening principles
 
How to write maintainable code without tests
How to write maintainable code without testsHow to write maintainable code without tests
How to write maintainable code without tests
 
Detection as Code, Automation, and Testing: The Key to Unlocking the Power of...
Detection as Code, Automation, and Testing: The Key to Unlocking the Power of...Detection as Code, Automation, and Testing: The Key to Unlocking the Power of...
Detection as Code, Automation, and Testing: The Key to Unlocking the Power of...
 
Les09
Les09Les09
Les09
 
User and group security migration
User and group security migrationUser and group security migration
User and group security migration
 
Sql Server Security
Sql Server SecuritySql Server Security
Sql Server Security
 
Java EE Services
Java EE ServicesJava EE Services
Java EE Services
 
LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
Internet Identity Workshop IIW 2023 - Introduction to ALFA Authorization Lang...
Internet Identity Workshop IIW 2023 - Introduction to ALFA Authorization Lang...Internet Identity Workshop IIW 2023 - Introduction to ALFA Authorization Lang...
Internet Identity Workshop IIW 2023 - Introduction to ALFA Authorization Lang...
 

Recently uploaded

Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
Atif Razi
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
Kamal Acharya
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 

Recently uploaded (20)

KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Peek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdfPeek implant persentation - Copy (1).pdf
Peek implant persentation - Copy (1).pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
A case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfA case study of cinema management system project report..pdf
A case study of cinema management system project report..pdf
 
fluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answerfluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answer
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
İTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering WorkshopİTÜ CAD and Reverse Engineering Workshop
İTÜ CAD and Reverse Engineering Workshop
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Fruit shop management system project report.pdf
Fruit shop management system project report.pdfFruit shop management system project report.pdf
Fruit shop management system project report.pdf
 
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-5 Notes for II-II Mechanical Engineering
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 

Db Security Seminar AppArmor

  • 1. An overview on AppArmor ‫ارائه‬ ‫کالسی‬ ‫درس‬ ‫امنیت‬ ‫پایگاه‬ ‫داده‬ ‫دانشگاه‬ ‫صنعتی‬ ‫شریف‬ : ‫ارائه‬ ‫دهندگان‬ ‫ابوالفضل‬ ‫فرهادی‬ - ‫امیرحسین‬ ‫آشناور‬ : ‫استاد‬ ‫درس‬ ‫دکتر‬ ‫صادق‬ ‫دری‬ ‫نوگورانی‬ ‫نیمسال‬1401-1400
  • 2. What is AppArmor ? AppArmor is Mandatory Access Control (MAC) like security system for Linux. AppArmor security policies completely define what system resources individual applications can access, and with what privileges. AppArmor secures applications by enforcing good application behavior without relying on attack signatures, so it can prevent attacks even if previously unknown vulnerabilities are being exploited. Unconfined programs are run under standard Linux Discretionary Access Control (DAC) security. AppArmor augments traditional DAC in that confined programs are evaluated under traditional DAC first and if DAC allows the behavior then AppArmor policy consulted.
  • 3. How does AppArmor work ? In AppArmor, processes are restricted by profiles , these profiles are stored in the /etc/apparmor.d directory. These profiles are plain-text files that can contain comments . In addition to manually creating profiles, AppArmor includes a learning mode, in which profile violations are logged, but not prevented. This log can then be used for generating an AppArmor profile, based on the program's typical behavior. Profiles can run in “complain mode” or “enforce mode ” that will be described next .
  • 4. Enforce mode vs. Complain mode Enforce – In the enforce mode, system begins enforcing the rules and report the violation attempts in syslog or auditd (only if auditd is installed) and operation will not be permitted. Complain – In the complain mode, system doesn’t enforce any rules. It will only log the violation attempts.
  • 5. Syntax of security profiles for AppArmor* part 1 PROFILE = ( PROFILE HEAD ) [ ATTACHMENT SPECIFICATION ] [ PROFILE FLAG CONDS ] '{' (RULES )* '}' PROFILE HEAD = [ 'profile' ] FILEGLOB | 'profile' PROFILE NAME FILEGLOB = ( QUOTED FILEGLOB | UNQUOTED FILEGLOB ) QUOTED FILEGLOB = '"' UNQUOTED FILEGLOB '"' UNQUOTED FILEGLOB = (must start with '/' (after variable expansion), AARE have special meanings; see below. May include VARIABLE. Rules with embedded spaces or tabs must be quoted. Rules must end with '/' to apply to directories.) PROFILE FLAG CONDS = [ 'flags=' ] '(' comma or white space separated list of PROFILE FLAGS ')' PROFILE FLAGS = 'complain' | 'audit' | 'enforce' | 'mediate_deleted' |'attach_disconnected' | 'chroot_relative' VARIABLE = '@{' ALPHA [ ( ALPHANUMERIC | '_' ) ... ] '}' VARIABLE ASSIGNMENT = VARIABLE ('=' | '+=') (space separated values) *See https://manpages.ubuntu.com/manpages/xenial/man5/apparmor.d.5.html for full description
  • 6. Syntax of security profiles for AppArmor part 2 FILE RULE = [ QUALIFIERS ] [ 'owner' ] ( 'file' | [ 'file' ] ( FILEGLOB ACCESS | ACCESS FILEGLOB ) [ '->' EXEC TARGET ] ) ACCESS = ( 'r' | 'w' | 'a' | 'l' | 'k' | 'm' | EXEC TRANSITION )+ (not all combinations are allowed) EXEC TRANSITION =( 'ix' | 'ux' | 'Ux' | 'px' | 'Px' | 'cx' | 'Cx' | 'pix' | 'Pix' | 'cix' | 'Cix' | 'pux' | 'PUx' | 'cux' | 'CUx' | 'x' ) A bare 'x' is only allowed in rules with the deny qualifier, everything else only without the deny qualifier. r - read , w - write , a - append , deny x - disallow execute EXEC TARGET = name Requires EXEC TRANSITION specified ACCESS TYPE = ( 'allow' | 'deny' ) QUALIFIERS = [ 'audit' ] [ ACCESS TYPE ]
  • 7. Syntax of security profiles for AppArmor part 3 CAPABILITY RULE = [ QUALIFIERS ] 'capability' [ CAPABILITY LIST ] CAPABILITY LIST = ( CAPABILITY )+ CAPABILITY = (lowercase capability name without 'CAP_' prefix; see capabilities ) NETWORK RULE = [ QUALIFIERS ] 'network' [ DOMAIN ] [ TYPE | PROTOCOL ] DOMAIN = ( 'inet' | 'ax25' | 'ipx' | 'appletalk' | 'netrom' | 'bridge' | 'atmpvc' | 'x25' | 'inet6' | 'rose' | 'netbeui' | 'security' | 'key' | 'packet' | 'ash' | 'econet' | 'atmsvc' | 'sna' | 'irda' | 'pppox' | 'wanpipe' | 'bluetooth' | 'netlink' | 'unix' | 'rds' | 'llc' | 'can' | 'tipc' | 'iucv' | 'rxrpc' | 'isdn' | 'phonet' | 'ieee802154' | 'caif' | 'alg' | 'nfc' | 'vsock' | 'mpls' | 'ib' ) ',' TYPE = ( 'stream' | 'dgram' | 'seqpacket' | 'rdm' | 'raw' | 'packet' ) PROTOCOL = ( 'tcp' | 'udp' | 'icmp' )
  • 8. What are important commands ? aa-status _ check the current status aa-enforce _ set profile to enforce mode (from disable or complain) aa-complain _ set profile to complain mode (from diable or enforcement) apparmor_parser _ to load/reload an altered policy aa-genprof _ generate a new profile aa-logprof _ used to change the policy when the binary/program is changed aa-mergeprof _ used to merge the policies
  • 9. Now let’s put it in practice …
  • 11. Use apt install apparmor-utils to make AppArmor commands available
  • 12. aa-genprof <executable> for profile generation
  • 14. Sample application for testing AppArmor features , it fails to read from file with default profile
  • 16. Use apparmor_parser to update or add profile
  • 17. Now application can read file normally
  • 18. Application fails to execute another app
  • 20. Now it can execute another app
  • 21. Test app that can set fileToRead file owner to current user
  • 22. New rule added , now Application can execute test app , ix shows that test will be executed with its parent profile
  • 23. Even with root privilege test could NOT change file’s owner , because chroot capability was not defined in profile .
  • 24. Stop AppArmor as a service
  • 25. Start AppArmor as a service
  • 26. ping.py script for pinging google.com
  • 31. Now it fails due to default profile …
  • 32. aa-status shows ping profile is added .
  • 33. Syslog after failed execution
  • 35. Changing ping profile mode to complain mode
  • 36. Now ping is executed in complain mode
  • 37. Syslog for complain mode execution
  • 38. Syslog for complain mode execution
  • 39. Reference: • https://gitlab.com/apparmor/apparmor/-/wikis/Documentation • https://wiki.ubuntu.com/AppArmor • https://manpages.ubuntu.com/manpages/xenial/man5/apparm or.d.5.html • https://en.wikipedia.org/wiki/AppArmor
  • 40. Thank you for your attention !