st-one-io / node-red-contrib-opc-da

A Node-RED node to interact with OPC-DA servers.
Apache License 2.0
13 stars 7 forks source link

OPC-DA ddos attack #8

Open ernell opened 4 years ago

ernell commented 4 years ago

Well, I tried this node for a little while now. Setup 1: A raspberry pi 4 with node-red + a Siemens Sinumerik 840d (old one). Setup 2: A linux server with node-red + same Siemens Sinumerik 840d, but this time through a firewall (mGuard). When its connected it works fine in both cases, but the problem comes when an opc-da server in node-red is deleted, or the flow is deactivated. The connection is still active, and it continues to try to connect, and it will escalate connecting faster and faster. Tried the behaviour lots of times now, and same happens every time. This ddos-ing crashed the firewall, since I had at least three deleted connections going crazy. If for example I deactivate the flow, then go to console stopping node-red, start node-red again, the deactivated flow (with opc-da node inside) still tries to connect, and if the Sinumerik cant be reached at that time, then ddos attack is a fact. Latest version of everything is used.

steuck13 commented 4 years ago

Greetings,

This node creates what is called a configuration node. If you delete the node, the configuration node is still there and will stay active. Try deleting the node here.

Regarding deactivated flows, when you create a configuration node there is a dropdown menu on the bottom of the tab where you can choose in which flows this node will be active. The default option is "On All Flows" which means that even if you disable a flow it will still be started when you run Node-RED.

If the problems persists I'll take a look on what could be causing this behavior.

Ty for your report.

ernell commented 4 years ago

Thanks for the answer and making things a bit more clear. Still I wish the reconnecting mechanism stopped racing away when it can not connect to the machine. I think a delay would be a good thing before trying to connect again. Question:

I might be very wrong here, but in function setup() there is a call to onComServerError when disconnected, which call setup(). That would create a circular reference as long as connection is failing. i can see the text "Trying to reconnect" from onComServerError spamming the node-red log. Just a theory ;) [newbie on node]

ernell commented 4 years ago

Well, I added a quickfix line to the onComServerError on my local install, so at least it will not spam reconnections. Maybe you can add it to the config.

async function onComServerError(e) { node.error(errorMessage(e)); switch(e) { case 0x00000005: return; case 0xC0040010: return; case 0x80040154: return; case 0x00000061: return; default: node.warn("Trying to reconnect..."); await new Promise(resolve => setTimeout(resolve, 5000)); await setup().catch(onComServerError); } }