Skip to main content
NIHPA Author Manuscripts logoLink to NIHPA Author Manuscripts
. Author manuscript; available in PMC: 2023 May 30.
Published in final edited form as: Asia CCS 22 (2022). 2022 May 30;2022:1237–1239. doi: 10.1145/3488932.3527293

Enabling Attribute-Based Access Control in Linux Kernel

HO Sai Varshith 1, Jaideep Vaidya 2, Shamik Sural 3, Vijayalakshmi Atluri 4
PMCID: PMC9825047  NIHMSID: NIHMS1854493  PMID: 36625496

Abstract

Linux has built-in security features based on discretionary access control that can be enhanced using the Linux Security Module (LSM) framework. However, so far there has been no reported work on strengthening Linux with Attribute-Based Access Control (ABAC), which is gaining in popularity in recent years due to its flexibility and dynamic nature. In this paper, a method for enabling ABAC for Linux file system objects using LSM is proposed. We report initial experimental results and also share our public repository links for integrating ABAC in any Linux installation.

Keywords: Access Control, ABAC, Linux Security Module, Policy Decision Point, Securityfs

1. INTRODUCTION AND MOTIVATION

Linux, which is a multi-user operating system, has several built-in security features, one of which is Discretionary Access Control (DAC) based file access. In DAC, files and directories in the system are owned and managed by individual users. The kernel also provides a Linux Security Module framework (LSM) that allows implementation of custom mandatory access control based security in which users are granted access to resources based on a centrally defined security policy. Security Enhanced Linux (SELinux) and AppArmor are two examples of LSMs. Role-Based Access control (RBAC) is another popular access control method in which users are assigned roles, and appropriate permissions are assigned to those roles. Access control decisions are made based on the permissions of the role rather than those of the users directly. In Linux, a limited implementation of RBAC can be achieved through SELinux [4].

Attribute-Based Access Control (ABAC) is a relatively new access control model [1] with an expanding user base due its dynamic nature and ability to support fine-grained policies. In ABAC, access control decisions are made using the notion of attributes, which are name-value pairs that capture various properties of the subject, object and environmental conditions of a system. Environmental attributes like CPU load, time of access, etc., enable the administrator to specify dynamic access control rules, which is a unique characteristic of ABAC. An ABAC policy is made up of a number of rules written in terms of attributes and the mode of access. One of the biggest advantages of ABAC is the fine-grained control it offers over other access control models. Supporting fine-grained access control through DAC or RBAC is time-consuming and error-prone. Despite an influential report from NIST [1] mentioning the need for ABAC in operating systems as far back as in 2014, even after more than seven years, there has been no work yet on supporting ABAC in Linux. This paper is the first ever attempt that identifies the challenges in integrating ABAC for file system objects with the Linux kernel and proposes a method for achieving the same.

2. RESEARCH CHALLENGES

One of the main considerations for designing ABAC support in Linux is determining the placement of the Policy Decision Point (PDP). PDP intercepts incoming access requests and makes access decisions (ALLOW/DENY). Flexibility (easily adaptable to different versions of the Linux kernel) and portability (independent of hardware specifications) are two important factors to be addressed. The first possible option is to use a userspace level file system like FUSE [5]. But, that would limit the ABAC to a single file system that the user has to install. Another alternative is to patch Linux’s Virtual File System (VFS) code to implement the PDP. However, it is heavily discouraged to modify VFS code as it is a core kernel component and can significantly impact the kernel’s performance or introduce unexpected bugs that might affect the overall system stability. This led us to use the LSM framework which uses “hook” methods [3] that are called when an object of interest is accessed. Another advantage of using LSM framework is that its overhead characteristics are well-studied [6]. This enables us to implement ABAC as an extension to the kernel.

The next challenge is to appropriately implement the Policy Information Point (PIP). PIP stores user, object and environmental attributes, as well as the ABAC policy and hence should be accessible with very low latency. Our first approach was to use netlink sockets to establish a connection between the kernel and userspace. In this scheme, ABAC data is stored in userspace, and a root-level service uses this data to resolve access requests. The kernel sends UID and Path of incoming access requests to the userspace service, which responds with an appropriate decision. However, this method is too slow due to the latency of netlink sockets. Therefore, we decided to use in-memory kernel data structures to store ABAC data such that access requests can be resolved within the kernel. For this, we use securityfs, which allows us to obtain formatted data from the userspace, parse it, and create kernel data structures that can be directly used by the PDP to resolve access requests.

3. DESIGNING ABAC SUPPORT FOR LINUX

The proposed system is comprised of four major components - the ABAC LSM, ABAC Security File System, userspace background services and the ABAC CLI tool. It requires a shared directory (say /home/shared/) with appropriate DAC permissions so that all users can access this directory. We chose this approach since it prevents users from accidentally allowing unwanted access to their home directory files. Figure 1 gives a high level system overview.

Figure 1:

Figure 1:

High Level Overview of the ABAC LSM

The code of LSM, which is the core component of our approach, is to be patched into the kernel tree and enabled during build-time configuration. Once the kernel is built with ABAC LSM enabled, it is automatically loaded on system boot. The proposed LSM identifies objects based on their path in the system. It uses the file_permission(struct file *file, int mask) hook to perform access control checks for file operations and allows verification during read/write events for an already open file. File structure and access mode are passed as arguments to the hook by VFS code. It returns 0 if access is allowed and −EPERM otherwise. The pseudo-code of the LSM hook is shown in Algorithm 1.

A pseudo-file system is used to inject attributes and policy into the kernel from user space. These are hierarchically organized interfaces to kernel objects, that appear as regular files in the system. They are mainly used for inter-process communication and enabling interaction between the kernel and the userspace. Applications can treat them like regular files and use common system calls like open(), read(), write(), etc. We use the securityfs pseudo file system mounted at /sys/kernel/security to communicate with the kernel from the user space. The proposed system creates a securityfs directory named abac and populates it with the files listed in Table 1. Each of these files has an associated write system call that parses data written to the file and builds appropriate kernel data structures.

Table 1:

Files in ABAC securityfs

Filename Function
user_attr User Id to attribute-value pair mapping
obj_attr File path to attribute-value pair mapping
env_attr Current environment attribute-value pairs
policy ABAC policy rules
Algorithm 1 Pseudo code for ABAC LSM hook                                ¯¯ 1:function ABAC_FILE_PERMISSIONfile∗file,mask 2: uid←current_euid() 3: if uid==0 then return 0 4: path←dentry_path_rawfile 5: if path does not belong to secured directory then 6:  return 0 7: if system not initialized then return -EPERM 8: decision←abac_resolveuid,path,mask 9: if decision==allowed then return 010: return -EPERM                                                                                              ¯

ABAC policies and attributes are stored in JSON format and located in /etc/abac/. Files in this directory contain all ABAC related information and are referred to as the policy and attribute store. ABAC background services and the command line tool interact with this store to obtain and modify ABAC information. It is created automatically during installation and appropriate DAC permissions are set so that only the root user has access to it.

The proposed method has three Systemd services that run in the background. Systemd was chosen since it is currently the most popular and convenient option. They are started automatically on system boot and run until the system is shutdown. These services are required for proper functioning of the kernel components. The first service is the core ABAC service. It has access to the ABAC store and loads ABAC data into the kernel on system boot. It is also responsible for managing object attributes via the command line tool. The next is the shared directory watch service, which assigns appropriate DAC permissions when new files are created in the shared directory. The final service is the environmental attributes service, which is responsible for updating the values of environmental attributes of the system like the time of making an access request. It uses cron based scheduling to prevent unnecessary updates.

An abac command line tool developed by us provides the complete functionality required to interact with the LSM, manage users, objects and their attributes. Written in Python3, it can be installed using setuptools. The abac command has a number of sub-commands, which in turn have several actions corresponding to different tasks. One of the sub-commands, namely obj lets the users manage attributes of the objects they own.

In the proposed system, users are responsible for managing attributes of the objects they own using the abac obj sub-command. Newly created objects are initially inaccessible since they do not have any attributes. User id and path of the object for which attributes are being assigned, are sent to the background ABAC service. The service verifies that the user is indeed the owner of the object at the given path or is the root user. On successful verification, the list of available attributes as well as those already assigned to the object are returned. The command line tool then displays the list it received and prompts for new attributes. Once the prompt is answered, the new set of attributes is sent back and the service updates the attribute store with these attributes. The service then loads the updated attributes into the kernel immediately so that the objects become accessible as per the access control policy. The sequence diagram for this use case is shown in Figure 2.

Figure 2:

Figure 2:

User Creates an Object

We have made the code for the LSM1 and userspace utilities2, along with installation instructions for most of the popular distributions, publicly available on Github.

4. RESULTS AND CONCLUSION

For performance evaluation, we studied the file access time under various scenarios. We conducted multiple experiments using synthetic data sets on a desktop machine with 3.1GHz Intel i7 CPU running Ubuntu 20.04 with ABAC patched kernel (Version 5.10.62) and other LSMs (except capabilities) disabled. In one of the experiments (metadata in Table 2), we study the impact of varying the number of rules in the ABAC policy on access time. We used four configurations (C1-C4) with C1 being the smallest and C4 being the largest in terms of the number of entities and attribute-value pairs. As seen in Figure 3, the time for any given configuration increases linearly with number of rules since more number of rules must be evaluated before an access decision can be made. Even then, the access time is less than half a millisecond for 200 rules, 500 users and 5000 objects. The time across configurations also increase linearly since more number of attributes must be compared for each rule. Note that the LSM hook method is called for every file access. This includes files outside the shared directory. However, as seen in Algorithm 1, for the files outside the shared directory, access is granted immediately. Therefore, there is only a slight overhead for file access times for files outside the shared directory.

Table 2:

Metadata for the Data Set of Figure 3

Parameter C1 C2 C3 C4
# Subjects 10 50 100 500
# Subject Attribute-Value Pairs 25 100 375 750
# Objects 100 500 1000 5000
# Object Attribute-Value Pairs 25 100 225 625
# Environmental Attribute-Value Pairs 6 20 70 150

Figure 3:

Figure 3:

Variation of File Access Time with Number of Rules

We are currently working on several improvements such as providing the ability to define custom environmental attributes and distributed policy management [2] in which under the main administrator, a set of next level admin users or even normal users may be allowed to create policy rules covering a limited set of attributes. Another interesting research direction is towards implementing a cache layer at the PDP to avoid unnecessary resolutions. Better kernel data structures and algorithms can be designed to further speed up access resolution. We also intend to carry out an exhaustive set of experiments for comprehensive performance evaluation.

CCS CONCEPTS.

  • Security and privacy → File system security; Access control.

ACKNOWLEDGMENTS

Research reported in this publication was supported by the National Institutes of Health under award R35GM134927, the Cisco University Research Program Fund, Silicon Valley Community Foundation award number 2020–220329 (3696) and by a research gift received from Cisco University Research. The content is solely the responsibility of the authors and does not necessarily represent the official views of the agencies funding the research.

Footnotes

Contributor Information

H.O. Sai Varshith, Indian Institute of Technology Kharagpur, India

Jaideep Vaidya, Rutgers University, USA.

Shamik Sural, Indian Institute of Technology Kharagpur, India.

Vijayalakshmi Atluri, Rutgers University, USA.

REFERENCES

  • [1].Tong Hu Chung, Ferraiolo David F., Kuhn David R., Schnitzer Adam, Sandlin Kenneth, Miller Robert, and Scarfone Karen. 2019. Guide to Attribute Based Access Control (ABAC) Definition and Considerations https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=927500 [Google Scholar]
  • [2].Jha Sadhana, Sural Shamik, Atluri Vijayalakshmi, and Vaidya Jaideep. 2019. Security Analysis of ABAC under an Administrative Model. IET Information Security 13, 2 (2019), 96–103. [DOI] [PMC free article] [PubMed] [Google Scholar]
  • [3].Muthukumaran Divya, Jaeger Trent, and Ganapathy Vinod. 2012. Leveraging “Choice” to Automate Authorization Hook Placement In Proceedings of the 2012 ACM Conference on Computer and Communications Security (CCS ‘12). ACM, New York, NY, USA, 145–156. [Google Scholar]
  • [4].Smalley Stephen. 2002. Configuring the SELinux policy. NAI Labs Rep (2002), 02–007. [Google Scholar]
  • [5].Reddy Vangoor Bharath Kumar, Agarwal Prafful, Mathew Manu, Ramachandran Arun, Sivaraman Swaminathan, Tarasov Vasily, and Zadok Erez. 2019. Performance and Resource Utilization of FUSE User-Space File Systems. ACM Trans. Storage 15, 2, Article 15 (may 2019), 49 pages. [Google Scholar]
  • [6].Zhang Wenhui, Liu Peng, and Jaeger Trent. 2021. Analyzing the Overhead of File Protection by Linux Security Modules In Proceedings of the 2021 ACM Asia Conference on Computer and Communications Security. ACM, New York, NY, USA, 393–406. [Google Scholar]

RESOURCES