Linux Privilege Escalation (Part 2 of 3)

 






Linux Privileges

Every file in a Linux system must comply with user and group permissions according to the fundamental capabilities of read, write, and execute. Most of the resources, including directories, files, devices, and network connections that represented in the file system is one of the distinguishing characteristics of Linux and its UNIX variants.

Insecure File Permissions

The pen tester should find an executable file that provide him right access and elevated privileges to take advantage of unsafe file permissions. Linux passwords are generally stored in /etc/shadow file, which is inaccessible to unprivileged users, unless a centralized credential system like Active Directory or LDAP is utilized. However, in the past, the password hashes and other account details were kept in publicly accessible file /etc/passwd. so, if he has access to the /etc/passwd file then, he can set any account's password to whatever he choose. 

Environmental Variable

Variables that are unique to an environment are called Environmental variables. For example, the environment for a privileged user may differ form an unprivileged one. Some of the Linux environmental variables are USER, HOME, SHELL, LANG, MAIL, HOSTNAME. Sometimes, the misconfigured privileges or values for an environmental variable may lead to a lateral movement opportunity for the penetration tester and hence he should always check them.

Cron Jobs

Cron is used for scheduling jobs on Unix-based operating system. It allows us to plan tasks that can run on a regular basis. Cron is often used to automate processes like email downloads, virus scans, and website update checks. The syntax is same for all the crontabs. Each line refers to a command that should be executed together with the appropriate time. The image below shows the crontab syntax-
The penetration tester will try to abuse the fact that every single cron job is running with root privileges. It means that every command that is executed in the running scripts/jobs it will execute as roots. Hence, vulnerabilities might occur when unprivileged users are able to modify and save the scripts, waiting for their execution. By modifying the script, pen tester can add themselves and become a superuser. If permissions are secured, the vulnerability may also be found inside the cronjob scripts. It also enables the attackers to modify the behavior of the command and thus become a superuser. 


Conclusion

This part talks about more factors related to the Linux Privilege Escalation.














































Comments

Popular posts from this blog

Query, Visualize, & Monitor Data in Azure Sentinel

Planning for Implementing SAP Solutions on Azure (Part 2 of 5)

Work with String Data Using KQL Statements