diff --git a/modules/vulnerabilities/unix/local/sudoedit/files/sudo_1.8.26-2_amd64.deb b/modules/vulnerabilities/unix/local/sudoedit/files/sudo_1.8.26-2_amd64.deb new file mode 100644 index 000000000..98168450b Binary files /dev/null and b/modules/vulnerabilities/unix/local/sudoedit/files/sudo_1.8.26-2_amd64.deb differ diff --git a/modules/vulnerabilities/unix/local/sudoedit/manifests/install.pp b/modules/vulnerabilities/unix/local/sudoedit/manifests/install.pp new file mode 100644 index 000000000..b8b65d033 --- /dev/null +++ b/modules/vulnerabilities/unix/local/sudoedit/manifests/install.pp @@ -0,0 +1,47 @@ +class sudoedit::install { + Exec { path => ['/bin', '/usr/bin', '/usr/local/bin', '/sbin', '/usr/sbin'] } + + $secgen_parameters = secgen_functions::get_parameters($::base64_inputs_file) + $leaked_filenames = $secgen_parameters['leaked_filenames'] + $strings_to_leak = $secgen_parameters['strings_to_leak'] + $username = $secgen_parameters['unix_username'][0] + $password = $secgen_parameters['used_password'][0] + + # Magic touch + # EDITOR='nano -- /etc/sudoers' sudoedit /etc/hosts + + # This exploit relies on a user being in sudo group but we dont want access to everything! :) + exec { 'goodbye-sudo': + command => "sed -i 's/%sudo/%root/' /etc/sudoers" + } + -> user { $username: + ensure => present, + managehome => true, + # Make sure we are in the sudo group + groups => 'sudo', + shell => '/bin/bash', + password => pw_hash($password, 'SHA-512', 'mysalt'), + } + # Let access to the hosts file via sudoedit + -> exec { 'i-can-edit-now': + command => "echo '${username} ALL=(ALL:ALL) sudoedit /etc/hosts' >> /etc/sudoers" + } + -> file { '/tmp/sudo_1.8.26-2_amd64.deb': + ensure => file, + source => 'puppet:///modules/sudoedit/sudo_1.8.26-2_amd64.deb', + } + -> package { 'downgrade sudo': + ensure => installed, + provider => dpkg, + source => '/tmp/sudo_1.8.26-2_amd64.deb' + } + + # Leak a file containing a string/flag to /root/ + ::secgen_functions::leak_files { 'sudoedit-file-leak': + storage_directory => '/root', + leaked_filenames => $leaked_filenames, + strings_to_leak => $strings_to_leak, + leaked_from => "", + mode => '0600' + } +} diff --git a/modules/vulnerabilities/unix/local/sudoedit/secgen_metadata.xml b/modules/vulnerabilities/unix/local/sudoedit/secgen_metadata.xml new file mode 100644 index 000000000..e4c9e704d --- /dev/null +++ b/modules/vulnerabilities/unix/local/sudoedit/secgen_metadata.xml @@ -0,0 +1,72 @@ + + + + Sudoedit Escalation + James Davis + MIT + In Sudo before 1.9.12p2, the sudoedit (aka -e) feature mishandles extra arguments + passed in the user-provided environment variables (SUDO_EDITOR, VISUAL, and EDITOR), + allowing a local attacker to append arbitrary entries to the list of files to process. This + can lead to privilege escalation. Affected versions are 1.8.0 through 1.9.12.p1. The problem + exists because a user-specified editor may contain a "--" argument that defeats a protection + mechanism, e.g., an EDITOR='vim -- /path/to/extra/file' value. + + + local_priv_escal + root_rwx + local + linux + medium + + strings_to_leak + leaked_filenames + + + + + + + + + + + + + + + tiaspbiqe2r + + + + .*Stretch.* + + + .*Kali.* + + + .*Windows.* + + + .*Ubuntu.* + + + + EXPLOITATION + EXPLOITATION FRAMEWORKS + + + CVEs and CWEs + + + PENETRATION TESTING - SOFTWARE TOOLS + PENETRATION TESTING - ACTIVE PENETRATION + + + kill chains + + + cyber kill chain + + \ No newline at end of file diff --git a/modules/vulnerabilities/unix/local/sudoedit/sudoedit.pp b/modules/vulnerabilities/unix/local/sudoedit/sudoedit.pp new file mode 100644 index 000000000..d972bceb0 --- /dev/null +++ b/modules/vulnerabilities/unix/local/sudoedit/sudoedit.pp @@ -0,0 +1 @@ +include sudoedit::install diff --git a/scenarios/examples/vulnerability_examples/sudoedit.xml b/scenarios/examples/vulnerability_examples/sudoedit.xml new file mode 100644 index 000000000..a985619bc --- /dev/null +++ b/scenarios/examples/vulnerability_examples/sudoedit.xml @@ -0,0 +1,33 @@ + + + + + + sudoedit + + + + + 172.16.0.2 + + + + + + + + + + spoiler_admin_pass + + + + + + IP_addresses + + + + \ No newline at end of file