Access Control


  • Thu 08 February 2024
  • misc

Mitigates against

  • Broken access control

Access control refers to the concept of restricting and allowing access to sensitive resources. We observe this concept from the perspective of the principle of least privilege (PoLP). We want users to have that and only that degree of access that allows them to carry out their responsibilities without significant obstruction.

With access to sensitive resources comes an inevitable degree of risk. By adhering to PoLP we indicate that we observe this risk and limit its impact to the lowest possible severity.

For our purposes we can broadly distinguish two forms of access control: attribute-based (ABAC) and role-based (RBAC). With attribute-based control, both resources and users have a set of attributes associated with them that are validated against a set of rules that form the bridge between user and resource. Role-based access control, on the other hand, establishes a set of roles that collect a number of permissions. A user can be assigned a set of roles that in turn allows them to access the resources required to satisfy the requirements of their role.

Setup

Maintaining RBAC setup is easier as most administrative load is up-front when defining appropriate roles. As this is more in line with the concept of this guide, this is what we will focus on. Implementations of RBAC between platforms differ somewhat, but conceptually the approach is simple. The foundation of any dependable RBAC setup is the definition of relevant roles within a team. Imagine a situation wherein a team primarily consists of business analysts, developers and testers.

After the initial setup, on- or offboarding a team member is as easy as assigning the appropriate role to them in any of the systems your team works with. The team member will then automatically receive access to all of the required assets and resources as defined by the role. Similarly, offboarding is as simple as removing the user's role.

Straightforward and uncomplicated on- and offboarding of team members are not the only advantage of this approach. Additionally, this creates the opportunity to gain a concise and complete overview of those with access to certain systems, resources or processes without having to gather a prohibitive amount of data and combining inputs from different sources. The platform you use will provide you with a definitive list of everyone who's been granted access to a certain resource and any changes to the status quo are conveniently reflected. This will allow you to maintain a firm grasp of your environment.

Conversely, ABAC allows for more complicated conditions under which a user is allowed to access certain

Structuring RBAC

Successful and sufficient role-based access control hinges on three separate pillars:

  • Access
  • Operations
  • Sessions

Access

Which resources are exposed to the user? In simple terms, this is in reference to everything the user can view.

Operations

For our purposes we define an operation as any action that retrieves, modifies or otherwise interacts with a resource.

Session management

This relates to when, for how long and under what conditions the user is allowed to access these resources.

One size does not fit all

As different systems have various ways of implementing access control, there is no one-size fits all approach. As such, it should be evaluated how this mitigation can be applied to appropriate systems on a case by case basis. A good place to start is the team's cloud platform, as this is the core of most operations a development team will be involved in. Safeguarding the resources encompassed by such a platform will have a sizeable impact, especially when combined with proper authentication and authorisation practices.

Implementation in your own application

Implementing role-based access control (RBAC) within an application is crucial for ensuring that users have appropriate access to resources based on their roles and responsibilities. As a developer responsible for this task, several important factors should be considered to design and implement RBAC effectively.

Firstly, a thorough analysis of the application's requirements and the roles involved is essential. Identify the various roles that users may have within the system, such as admin, manager, employee, or guest. Each role should be clearly defined with specific permissions and access rights tailored to their responsibilities.

Next, design a robust RBAC model that aligns with the identified roles and their associated permissions. This model should establish a clear hierarchy of roles, ensuring that users have access only to the resources necessary for their roles while preventing unauthorized access to sensitive data or functionalities.

In Java, you can implement RBAC by defining roles as classes or enums, each representing a distinct role within the system. Permissions can be represented as methods or attributes within these role classes, specifying the actions or operations that users with the respective roles are allowed to perform. Utilize access control mechanisms such as method-level security annotations or interceptors to enforce these permissions throughout the application.

Another important aspect of RBAC implementation is the management of roles and permissions. Provide an intuitive user interface or administrative dashboard for role assignment and permission management, allowing administrators to easily assign or revoke roles as users' responsibilities change. Implement secure authentication and authorization mechanisms to ensure that only authorized users can access the administrative functionalities.

Furthermore, RBAC implementation should be coupled with proper logging and monitoring mechanisms (Logging & Monitoring) to track user activities and detect any unauthorized access attempts or security breaches. Implement robust logging functionality to record user actions, access attempts, and role changes, enabling administrators to audit user activities and maintain accountability within the system.

Lastly, RBAC implementation should be periodically reviewed and updated to accommodate changes in the application's requirements or business rules. Conduct regular audits of role assignments and permissions to ensure compliance with security policies and regulations, and make necessary adjustments to the RBAC model as the application evolves.

Overall, implementing RBAC within an application requires careful planning, design, and execution to ensure that users have appropriate access to resources while maintaining the security and integrity of the system. By following these best practices and leveraging appropriate tools and frameworks, developers can establish a robust RBAC system that effectively manages access control within the application.

In Java, the Spring Security library may be used to implement RBAC in a very straighforward and well-documented process. Other frameworks generally offer similar libraries or modules. Using these is strongly recommended over trying to re-invent the wheel.