Question
How to take sudo-based Linux Least Privilege to the next level with Idira Endpoint Privilege Manager for Linux?
Answer
Introduction
Deciding to enforce least privilege on your users for better security is one thing, but building a least privilege rule set is a completely different thing and far from an easy one. This is especially true when you have a complex infrastructure, lots of different user roles and profiles, and nothing but sudo at your disposal (how long and complicated is your sudoers policy file?!). Lots of administrators are lost in the process of trying to define which users should have access to which commands, and they end up with a hot mess of non-effective policies (either too permissive or too limited) and majorly frustrated users.
This whitepaper explores how Idira Endpoint Privilege Manager for Linux (EPM for Linux) can help you discover which commands users actually use, learn why they use them, and enable an easy way to create policies based on users’ activity.
Prerequisites / Considerations
This whitepaper will help you understand how easy it is to discover command usage and create policies around them with EPM for Linux, but it would be even better if you tried these scenarios on your own – luckily, it’s very easy to do with our EPM free 30-day trial.
If you already have an EPM tenant set up, you can isolate your experimental setup by creating a new Set.
This document assumes that you have at least some familiarity with Linux and, hopefully, Idira EPM too, but if you don’t, here’s a crash course into EPM.
To learn on security best practices and product boundaries refer to our online help.
Using Learning Mode for Quick Discovery
The Discovery period is an essential step for building a well-designed least privilege rule set. During discovery, EPM administrators “listen” to users to uncover their needs and behavior patterns when it comes to using Linux commands. Discovery policies do not interfere with existing user practices beyond asking them questions to provide context for administrators about why a user needs that specific command. Discovery ends in an “command use baseline”, that administrators can constantly refine – taking into account the organization’s IT policy, security considerations, compliance requirements, and customers’ and partners’ requirements (often imposed as a part of supply chain cybersecurity).
Discovery for organizations that have not yet enforced a least privilege policy
Organizations that have not yet enforced a least privilege policy and allow end users to elevate any command with sudo, can enable discovery of sudo commands in EPM, while still allowing all sudo elevations. This way, end users’ work is not disturbed while discovery and least privilege policies establishment is taking place.
EPM detects any sudo command and, if no specific policy was already set, it will create an event for this command in the Event Management pane and elevate the command. Then, the EPM administrator can review the event with all command details, such as the command binary file, the user who ran it, the justification they provided, and decide whether to add this command to the policies.
Use the following workflow to gather information about sudo command usage and define policies.
Step 1: Activate the default policy to monitor activity
In EPM, we call an application (in Linux, a command or script) handled if at least one policy’s definition set matches this specific application. When an application is executed, EPM iterates through the policy list by policy priority, and the first that matches the application will “handle” that application. If no policy matches the application, it is considered unhandled. You can define default policies to handle “unhandled applications”.
Activate the Elevate unhandled applications default policy to monitor all activity and collect events:
In the Management Console, go to Policies > Default Policies.
In the Additional tab, set the Elevate unhandled applications policy to On, then click Yes to confirm the default settings. You can also click Edit to set additional attributes, such as the computers that this policy targets (the default is all computers in the Set), whether the policy should target standard end users, or also administrative end users, and whether they’ll be prompted for justification before they can execute a command execution.
Note: This policy affects all its targeted computers, regardless of their platform. For Linux, this policy only elevates sudo commands.
Step 2: Learn command usage
Callout: The Events Management page in the EPM management console collects all the events that did not match a policy. You can drill down for each event, see its details, and take immediate action to protect endpoints by applying relevant policies.
Use the Events Management page to analyze and learn how users in your enterprise issue commands, and understand how you can implement policies to protect your environment.
Let’s consider an example where John, a standard user, tries to restart the sshd service using the sudo command: ‘sudo systemctl restart sshd’. According to the “Elevate unhandled applications” policy configuration, he is required to authenticate and provide a justification for this action. After John provides the information, the command is successfully elevated.
Note: You can configure EPM not to require users to provide a password to run a sudo command, by setting the “Run without password” configuration in the command definition.
An event is created in the Events Management page with the details of the sudo command that John used. As an EPM administrator, you can review the details of the command, such as its full path or checksum, as well as the justification that John provided.
You can see the number of users who issued this command, and the number of computers on which it was executed, as well as the number of times it was executed. You can click an event to drill down for more details, like the user who executed it and their UID, the user it was executed as, the command line that was typed by the user, the command arguments, the working directory, details of the binary that was used, and more:
Step 3: Define specific policies to control activity
Using the insights that you acquired by checking the context and the user’s justification, you can now define specific policies to elevate or block specific commands, and target them to specific computers and users.
If an event looks like a one-off, you can just delete or ignore it without taking action.
You can continue adding command definitions to the policy going forward, based on the collected events. For details about how to do this, see More event management actions.
For more information about creating and managing policies, see Apply policies.
When you add an event to a policy, it is possible to either choose an existing one or create a new policy:
Let’s add systemctl command to a new policy called “Server IT commands”:
The new Policy Details form appears with the command attributes already filled in:
The administrator can edit the policy details – add a description, update targeting, enable audit, set additional options like scheduled enforcement, and update the command definition if needed:
Once the policy is saved, the systemctl command will be managed and elevated by the new policy, and events for this command will no longer appear in the Events Management page.
Discovery for organizations that have already enforced least privileges with sudoers
Customers who have already defined least privilege policies in sudoers and would like to migrate those to EPM, can use the “Detect privileged unhandled applications” default policy.
This policy detects any unmanaged sudo command and creates an event for it in the Events Management page. Then, the command is executed according to the sudoers policy that is configured on the Linux machine. This is helpful for customers who would like to build their policies in EPM while their existing sudoers policies are still being enforced.
Application Groups for Better Management
An application group is a list of applications (in Linux, commands) that are grouped together for easy management. When you create several policies that include the same set of commands, instead of adding commands one by one to each policy, you can create a group, add the commands to the group, and then use this group in your policies. This is also a great way to ensure that if you need to make any modifications, you can do this once for the group and this change affects every policy that includes the group.
Below is an example of a few command groups for different roles in the organization:
When you review events of commands in the Events Management page, you can also choose to add the command to an application group:
Policy audit
EPM provides policy audit tools that give you an in-depth look at users’ activity in either a report or in the Policy Audit page in the EPM console.
Important: To audit policy events, first enable this capability for the Set, and then for each policy you want to audit.
To enable the audit data collection for the Set, go to Advanced > Agent Configuration and, under Data Collection, set Collect Policy Usage Data to On.
Next, to collect audit for commands that are managed by policies, enable audit collection under the Audit section in the policy details page for each policy for which you want to collect audits. By default, this setting is Off.
When audit is enabled, you can review the audit trail in the Policy Audit page. You can also export the audit trail to reports or use the EPM Events API to export it to external integrated systems.
Note the difference between the Policy Audit and Events Management:
Policy audit is used for auditing purposes and is collected for commands that you already mange in your policies. Events management collects events for unmanaged commands, that usually require attention from the administrator.
Additional Linux Policy Attributes
There are additional options for Linux policies that allow you to define more specific behavior on commands execution for granular control.
Child command handling
There are cases when you want to define how child commands are handled:
Block all – Block all child commands. This is recommended when the command allows shell escape and you want to make sure that no child commands are created from the command. For example, the vi command on RHEL allows the user to run additional commands from within the editor. If you don’t explicitly prohibit this behavior, the user who is allowed to run an elevated vi command can abuse that privilege to run any other command from within the vi with the same permissions. Using this option blocks this potentially insecure behavior.
Elevate all – Elevate all child commands. This option is useful when the command is a known command that should be allowed, together with its child commands. It is recommended to include the checksum of the command as part of the policy definition, to verify the command authenticity and prevent command hijacking. If you use this setting with a script, the checksum allows you to verify that the script has not changed.
Elevate if permitted by any policy – Elevate child commands if there’s at least one policy that permits users to elevate this specific command with sudo. This is recommended when the command executes other unknown commands. For example, when the command is a shell, and you want the shell to be restricted so every command executed in the shell is also validated by the policy.
Environment variables handling
EPM controls the environment variables that are available in the sudo command process, to make sure that only required environment variables are part of the process.
There’s a default list of the variables that are part of the sudo command process and variables that are removed from the process. The EPM administrator can modify these lists separately for each command.
Note: Set the Keep list to ‘*’ to pass all the environment variables that exist in the parent process to the sudo process. This is relevant for commands that need the environment variables from the parent process to be available. These commands are usually executed with the sudo -E option.
Sudo no password
By default, the Linux EPM agent requires users to authenticate before running a sudo command. However, you can disable password authentication for sudo commands. This is relevant for deployments where users authenticate without a password, such as when SSH keys are being used.
Command definition examples
The easiest way to define commands in your policy is to build them based on events collected in the Events Management. You can always edit the command definition that is created automatically based on the event and refine it to suit your needs.
You can find below several examples for command definitions:
The definition above applies on the following commands:
sudo systemctl status sshd
sudo systemctl stop sshd
sudo systemctl start sshd
sudo systemctl restart sshd
The definition above applies on the command ‘sudo su –‘ that opens a root login shell. Since the Child Command option is set to “Elevate if permitted by any policy”, this shell is restricted and commands that are executed in it are elevated only if there’s any policy that allows them.
Conclusion
Idira Endpoint Privilege Manager™ for Linux provides essential endpoint security controls and enforces the principle of least privilege for Linux servers and workstations. It eliminates manually intensive, error-prone sudo administrative processes, allows endpoint security managers to centrally configure sudo, and enforce least privilege across Linux systems, at scale, based on policies.
Idira Endpoint Privilege Manager for Linux is an integral component of Idira Endpoint Privilege Manager, a comprehensive endpoint security solution that provides single pane-of-glass administration and centralized, policy-based privilege management for Windows, macOS and Linux endpoints. With Endpoint Privilege Manager, security professionals can centrally manage geographically dispersed, heterogenous endpoints in a consistent manner from a single SaaS console.
Endpoint Privilege Manager can provide visibility and control over all enterprise endpoints, including remote endpoints that infrequently connect to the corporate network. A flexible reporting engine and detailed event journal make it easy to provide evidence for compliance audits, to support forensics investigations, and to demonstrate cyber readiness and proof of required security controls to insurance underwriters.
Endpoint Privilege Manager REST APIs allow you to tie activity and event auditing into your existing security information and event management (SIEM) platforms. And Endpoint Privilege Manager’s policy engine is accessible via API for integration with external policy orchestration and automation tools.
Endpoint Privilege Manager is delivered as a SaaS solution for rapid deployment, simple operation, and easy integration with other cloud-based services. A SaaS deployment model helps you accelerate time to value and reduce TCO by avoiding on-premises equipment expenses and operations hassles.
View full article