Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-9660

trapd may silently discard invalid traps

    XMLWordPrintable

    Details

      Description

      While playing around with some trap generation code, I found that some improperly formatted traps may get dropped without any warnings or log messages.

      For example, after sending a trap with:

      SnmpObjId enterpriseId = SnmpObjId.get(".1.3.6.1.3.95.3");
      SnmpObjId trapOID = SnmpObjId.get(enterpriseId, new SnmpInstId(2));
      SnmpTrapBuilder pdu = SnmpUtils.getV2TrapBuilder();
      pdu.addVarBind(SnmpObjId.get(".1.3.6.1.2.1.1.3.0"), SnmpUtils.getValueFactory().getTimeTicks(0));
      // VALID: pdu.addVarBind(SnmpObjId.get(".1.3.6.1.6.3.1.1.4.1.0"), SnmpUtils.getValueFactory().getObjectId(trapOID));
      INVALID: pdu.addVarBind(SnmpObjId.get(".1.3.6.1.6.3.1.1.4.1.0"), SnmpUtils.getValueFactory().getInt32(1));
      pdu.send("127.0.0.1", 162, "public");
      

      The following log messages show up in trapd.log:

      2017-10-02 10:11:38,635 DEBUG [DefaultUDPTransportMapping_0.0.0.0/162] o.s.Snmp: Fire process PDU event: CommandResponderEvent[securityModel=2, securityLevel=1, maxSizeResponsePDU=65535, pduHandle=PduHandle[1840793222], stateReference=StateReference[msgID=0,pduHandle=PduHandle[1840793222],securityEngineID=null,securityModel=null,securityName=public,securityLevel=1,contextEngineID=null,contextName=null,retryMsgIDs=null], pdu=TRAP[requestID=1840793222, errorStatus=Success(0), errorIndex=0, VBS[1.3.6.1.2.1.1.3.0 = 0:00:00.00; 1.3.6.1.6.3.1.1.4.1.0 = 1]], messageProcessingModel=1, securityName=public, processed=false, peerAddress=127.0.0.1/53658, transportMapping=org.snmp4j.transport.DefaultUdpTransportMapping@45f353b8, tmStateReference=null]
      2017-10-02 10:11:38,685 DEBUG [DefaultUDPTransportMapping_0.0.0.0/162] o.o.n.s.s.Snmp4JTrapNotifier: V2 TRAP numVars or pdu length: 2
      2017-10-02 10:11:38,693 DEBUG [OpenNMS.Sink.AsyncDispatcher.Trap-Thread-1] o.o.n.s.s.Snmp4JTrapNotifier: V2 TRAP first varbind value: 0:00:00.00
      2017-10-02 10:11:38,694 DEBUG [OpenNMS.Sink.AsyncDispatcher.Trap-Thread-1] o.o.n.s.s.Snmp4JTrapNotifier: V2 TRAP first varbind value is of type TIMETICKS (correct)
      

      but nothing further, and nothing in eventd.log.

        Attachments

          Activity

            People

            • Assignee:
              j-white Jesse White
              Reporter:
              j-white Jesse White
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: