โคด๏ธPrivesc

Privilege Escalation (Privesc)

Privilege escalation is a common method used by attackers to gain higher levels of access and control over systems and networks. This is often accomplished by exploiting vulnerabilities or weaknesses in software, operating systems, or other security controls to gain access to restricted resources.

As a cybersecurity expert, it's important to understand how privilege escalation attacks work and how to prevent them. In this course, we will cover the basics of privilege escalation and provide examples of common methods used by attackers.

Table of Contents

  1. Introduction

  2. Types of Privilege Escalation

  3. Methods of Privilege Escalation

    • Kernel Exploits

    • Misconfigured File Permissions

    • Weak Passwords

    • Application Vulnerabilities

  4. Detecting and Preventing Privilege Escalation

  5. Example

  6. Conclusion

1. Introduction

Privilege escalation is the process of gaining higher levels of access to a system or network than what is initially granted to a user or application. This can be accomplished by exploiting vulnerabilities or weaknesses in security controls, such as software, operating systems, or user accounts.

Privilege escalation attacks can have serious consequences for organizations, including data theft, system hijacking, and disruption of critical business processes. As such, it's important for cybersecurity professionals to understand how these attacks work and how to prevent them.

2. Types of Privilege Escalation

There are two main types of privilege escalation: vertical and horizontal.

  • Vertical privilege escalation involves gaining access to higher levels of permission within a single system or application. For example, an attacker may gain access to an administrative account on a server, which grants them full control over the system.

  • Horizontal privilege escalation involves gaining access to the same level of permission on multiple systems or applications. For example, an attacker may use the same password to gain access to multiple user accounts on different servers.

Both types of privilege escalation can be used to gain unauthorized access to sensitive data and resources, and both can be dangerous to organizations.

3. Methods of Privilege Escalation

There are several methods that attackers can use to escalate privileges on a system or network. Some common methods include:

Kernel Exploits

A kernel exploit is a type of vulnerability that allows an attacker to execute arbitrary code with kernel-level privileges. This can give the attacker full control over the system, allowing them to install malware, steal data, or perform other malicious actions.

Example: The Dirty COW vulnerability in Linux allowed attackers to gain root access to a system by exploiting a race condition in the kernel's copy-on-write mechanism.

Misconfigured File Permissions

File permissions are used to control access to files and directories on a system. If these permissions are misconfigured, an attacker may be able to gain access to files or directories that they shouldn't have access to.

Example: An attacker may be able to read sensitive data from a configuration file if the file permissions are set to allow anyone to read the file.

Weak Passwords

Weak passwords are a common method used by attackers to gain access to user accounts on a system or network. If a user's password is easily guessable, an attacker may be able to gain access to their account and escalate their privileges.

Example: An attacker may use a dictionary attack to guess a user's password and gain access to their account.

Application Vulnerabilities

Application vulnerabilities can also be used to escalate privileges on a system or network. For example, an attacker may be able to exploit a vulnerability in a web application to gain administrative access to the underlying system.

Example: The Apache Struts vulnerability used by the Equifax data breach allowed attackers to execute arbitrary code on a system and gain access to sensitive data.

4. Detecting and Preventing Privilege Escalation

There are several ways to detect and prevent privilege escalation attacks:

  • Regularly apply software patches and updates to address known vulnerabilities.

  • Implement strong password policies, such as requiring complex passwords and enforcing regular password changes.

  • Limit user privileges to only those necessary for their job function.

  • Monitor system logs and network traffic for suspicious activity.

  • Use intrusion detection and prevention systems to detect and block known attack patterns.

5. Example

One common method of privilege escalation on Linux systems is through the GRUB bootloader. GRUB is responsible for loading the operating system and is typically protected by a password to prevent unauthorized changes. However, if an attacker is able to gain access to the GRUB menu, they may be able to escalate their privileges and gain access to the root account. In this example chapter, we will explore how attackers can exploit vulnerabilities in the GRUB bootloader to gain higher levels of access and how to prevent these attacks.

What's the GRUB ?

GRUB (Grand Unified Bootloader) is a popular bootloader used on Linux and other Unix-like operating systems. Its primary function is to load the operating system into memory and start the boot process. GRUB is typically installed on the system's boot partition and is responsible for locating and loading the kernel, as well as any other necessary boot files. In addition, GRUB provides a menu interface that allows users to select different boot options, such as different kernel versions or alternative operating systems installed on the same machine. GRUB is an essential component of the Linux boot process and is critical for starting the operating system.

Let's start!

The first step is to restart the server. On the boot, press e key to edit commands before booting.

Looks for a line that start with linux /boot/ and finish with ro quiet and replace Read-Only ro by Read-Write rw and add an init parameter and set it up to the binary /in/bash then press F10 to boot.

  • init = kernel startup option, takes any executable/binary as parameter.

  • /bin/bash = return to bash shell.

You can find more binaries potentially vulnerable to privesc here.

6. Conclusion

Privilege escalation is a common method used by attackers to gain higher levels of access and control over systems and networks. Understanding the different methods of privilege escalation and how to prevent them is crucial for cybersecurity professionals. By implementing strong security controls and regularly monitoring for suspicious activity, organizations can help prevent privilege escalation attacks and protect their sensitive data and resources.

Last updated