nerdexam
CompTIA

PT0-001 · Question #44

After gaining initial low-privilege access to a Linux system, a penetration tester identifies an interesting binary in a user's home folder titled ''changepass." -sr-xr-x 1 root root 6443 Oct 18…

The correct answer is A. Copy changepass to a writable directory and export the ENV_PATH environmental variable to the. The SUID root binary uses the ENV_PATH environment variable to construct the path of a child executable named 'changepw', enabling PATH hijacking by placing a malicious binary at the attacker-controlled location.

Post-exploitation and lateral movement

Question

After gaining initial low-privilege access to a Linux system, a penetration tester identifies an interesting binary in a user's home folder titled ''changepass." -sr-xr-x 1 root root 6443 Oct 18 2017 /home/user/changepass Using "strings" to print ASCII printable characters from changepass, the tester notes the following:

$ strings changepass exit setuid strcmp GLIBC_2.0 ENV_PATH %s/changepw malloc strlen Given this information, which of the following is the MOST likely path of exploitation to achieve root privileges on the machine?

Options

  • ACopy changepass to a writable directory and export the ENV_PATH environmental variable to the
  • BCreate a copy of changepass in the same directory, naming it changepw. Export the ENV_PATH
  • CExport the ENV_PATH environmental variable to the path of a writable directory that contains a
  • DRun changepass within the current directory with sudo after exporting the ENV_PATH

How the community answered

(14 responses)
  • A
    64% (9)
  • B
    7% (1)
  • C
    7% (1)
  • D
    21% (3)

Why each option

The SUID root binary uses the ENV_PATH environment variable to construct the path of a child executable named 'changepw', enabling PATH hijacking by placing a malicious binary at the attacker-controlled location.

ACopy changepass to a writable directory and export the ENV_PATH environmental variable to theCorrect

The strings output reveals the binary uses ENV_PATH with the format string '%s/changepw' to build the full path of the executable it will call, and the setuid string confirms the process runs as root. By copying or navigating to a writable directory, placing a malicious binary named 'changepw' there, and exporting ENV_PATH to that directory's path, the attacker causes the SUID root process to execute their payload with root privileges when changepass is run.

BCreate a copy of changepass in the same directory, naming it changepw. Export the ENV_PATH

Naming a copy of the changepass binary itself as 'changepw' would cause the SUID binary to invoke itself recursively rather than execute an attacker-controlled payload, producing no privilege escalation.

CExport the ENV_PATH environmental variable to the path of a writable directory that contains a

Exporting ENV_PATH alone without ensuring the correct malicious 'changepw' binary is present in the target directory and properly executable does not complete the exploit chain needed to achieve privilege escalation.

DRun changepass within the current directory with sudo after exporting the ENV_PATH

Invoking changepass with sudo requires the low-privilege user to have sudo rights, which are not available given only initial low-privilege access has been established on the system.

Concept tested: SUID binary environment variable PATH hijacking for privilege escalation

Source: https://man7.org/linux/man-pages/man2/setuid.2.html

Topics

#SUID exploitation#PATH hijacking#privilege escalation#Linux

Community Discussion

No community discussion yet for this question.

Full PT0-001 Practice