You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to write a fail2ban rule for node-red. After defining some users in adminAuth in reference to #539 I expected to see errors on failed login attempts in the syslog (and successful logins too). I configured
I've just checked 0.19.5, with audit: true set as you have it, I get the following type of event in the Node-RED log when I enter an incorrect password:
2 Jan 22:53:21 - [audit] {"event":"auth.login.fail.credentials","username":"admin","client":"node-red-editor","scope":"","level":98,"timestamp":1546469601808}
I see successful access log with IP address, i.e May 04 11:01:15 homeassistant Node-RED[1518]: 4 May 11:01:15 - [audit] {"event":"library.get.all","type":"flow","level":98,"user":{"username":"admin","permissions":"*"},"path":"/library/flows","ip":"192.168.20.181, 192.168.20.181","timestamp":1556992875846}
but failed access attempts don't log the originating IP address so I cant block the offender with fail2ban, is this string configurable or can we request to add IP address?
May 04 11:01:17 homeassistant Node-RED[1518]: 4 May 11:01:17 - [audit] {"event":"comms.auth","user":{"username":"admin","permissions":"*"},"level":98,"timestamp":1556992877375}
I have the same issue with version v0.20.5 running in docker.
The failed login gets logged, but without IP address
8 Jun 16:14:08 - [audit] {"event":"auth.login.fail.credentials","username":"georg80","client":"node-red-editor","scope":"","level":98,"timestamp":1560010448291}
success looks like this
8 Jun 18:42:04 - [audit] {"event":"auth.login","username":"georg90","client":"node-red-editor","scope":" *","level":98,"timestamp":1560019324406}
The IP is missing in both..
my logging settings
logging: {
// Only console logging is currently supported
console: {
// Level of logging to be recorded. Options are:
// fatal - only those errors which make the application unusable should be recorded
// error - record errors which are deemed fatal for a particular request + fatal errors
// warn - record problems which are non fatal + errors + fatal errors
// info - record information about the general running of the application + warn + error + fatal errors
// debug - record information which is more verbose than info + info + warn + error + fatal errors
// trace - record very detailed logging + debug + info + warn + error + fatal errors
// off - turn off all logging (doesn't affect metrics or audit)
level: "trace",
// Whether or not to include metric events in the log output
metrics: false,
// Whether or not to include audit events in the log output
audit: true
}
},
@917huB The log with IP is from the frontend or API?
If anyone stumbled on this from google like I did, it's not as badly wide-open as we were assuming. I dug into the code looking to patch the logging function to add IP addresses to the scope, but there is a flood control hard-coded at the user level in the application already.
@RNCTX's comment has prompted me to go look at the code over the last 10 minutes. I can see why the IP address isn't included, but I can also see getting it included will require some careful reworking of the error handling.
The audit message is currently being logged at the point we identify the password is incorrect. But at that point of the code we have no reference to the http request itself, only the credential data being provided. The audit message is logged and then a generic rejection error is passed back up the stack so the request can be refused.
We will need to change it around so the error contains more details on the failure type, so the event can be logged at a point where we know the IP address. But we need to be very careful to ensure that change in error message doesn't change any other behaviours looked for the existing error.
Thank you for taking a look. If you do take a look at adding the originating IP address to the logging, can I also ask you consider those folks may be running node-red behind a nginx or similar proxy and to consider the implications of $proxy_add_x_forwarded_for headers etc.
I'm running NodeRed 2.2.2 and I'm having the same missing feature.
I would like to secure my server with fail2ban but the log still not show any IP address : 2 Jul 15:42:41 - [audit] {"event":"auth.login.fail.credentials","username":"[email protected]","client":"node-red-editor","scope":"","level":98,"timestamp":1656769361308}
Does someone has a patch for this ? is this scheduled to be put into version 3 of NodeRed ?
@ClementToche The problem is that at the point we know the wrong password has been provided we are deep in a PassportJS callback stack and don't have access to the requesting IP address.
@hardillb, Thanks for answering and I see the problem.
Another solution would be to print 2 traces, 1 when a client connect to the server web front-end and 1 when credentials fails.
Fail2Ban is able to parse 2 lines and I can easily make a regex in this way.
To give an example, mosquitto (MQTT open source server) print those 2 lines : New connection from 192.168.1.10:6565 on port 8883 Client <unknown> disconnected, not authorised.
First line would be printed by the web server front-end when new client connects.
And second line would be printed as already developed in NodeRed code.
Of course, this is not a perfect solution for big server that could have 2 user connection at the very same time but this is for sure enough for personal server at home for which a little bit of security can be added.
Hello Node-RED team.
I would like to raise that up on top of the list since it's a very old request.
Node-RED is a very good tool that can be used for many stuff in a professional grade way but it really need the same level of quality for security requirement and this is really needed to make DDoS attack protection in place for this tool.
Is there is any chance it can come on top of the new major 3.X version ?
Thanks.
@ClementToche I will take another look to see how we can get the required information surfaced. As was said in previous comments, there are some architectural difficulties in getting the information in the right place so it can be logged at the right time.
Activity
knolleary commentedon Jan 2, 2019
Hi,
I've just checked 0.19.5, with
audit: trueset as you have it, I get the following type of event in the Node-RED log when I enter an incorrect password:917huB commentedon May 4, 2019
I see successful access log with IP address, i.e
May 04 11:01:15 homeassistant Node-RED[1518]: 4 May 11:01:15 - [audit] {"event":"library.get.all","type":"flow","level":98,"user":{"username":"admin","permissions":"*"},"path":"/library/flows","ip":"192.168.20.181, 192.168.20.181","timestamp":1556992875846}but failed access attempts don't log the originating IP address so I cant block the offender with fail2ban, is this string configurable or can we request to add IP address?
May 04 11:01:17 homeassistant Node-RED[1518]: 4 May 11:01:17 - [audit] {"event":"comms.auth","user":{"username":"admin","permissions":"*"},"level":98,"timestamp":1556992877375}georg90 commentedon Jun 8, 2019
I have the same issue with version v0.20.5 running in docker.
The failed login gets logged, but without IP address
success looks like this
The IP is missing in both..
my logging settings
@917huB The log with IP is from the frontend or API?
RNCTX commentedon Apr 8, 2020
If anyone stumbled on this from google like I did, it's not as badly wide-open as we were assuming. I dug into the code looking to patch the logging function to add IP addresses to the scope, but there is a flood control hard-coded at the user level in the application already.
node-red/packages/node_modules/@node-red/editor-api/lib/auth/strategies.js
Line 61 in e26eb85
I can verify that the above works after looking at my logs from starting the server via systemd...
917huB commentedon Apr 8, 2020
I dont see an IP address included to the fail messaging that fail2ban can use to block the source address.
RNCTX commentedon Apr 8, 2020
Correct, there is not one, but there is a flood control function built into the application's login flow, see the linked function.
knolleary commentedon Apr 8, 2020
@RNCTX's comment has prompted me to go look at the code over the last 10 minutes. I can see why the IP address isn't included, but I can also see getting it included will require some careful reworking of the error handling.
The audit message is currently being logged at the point we identify the password is incorrect. But at that point of the code we have no reference to the http request itself, only the credential data being provided. The audit message is logged and then a generic rejection error is passed back up the stack so the request can be refused.
We will need to change it around so the error contains more details on the failure type, so the event can be logged at a point where we know the IP address. But we need to be very careful to ensure that change in error message doesn't change any other behaviours looked for the existing error.
917huB commentedon Apr 8, 2020
Thank you for taking a look. If you do take a look at adding the originating IP address to the logging, can I also ask you consider those folks may be running node-red behind a nginx or similar proxy and to consider the implications of $proxy_add_x_forwarded_for headers etc.
RNCTX commentedon Apr 8, 2020
X-Forwarded-For is recorded properly in the functions where IPs are recorded, I verified that when testing the above as well.
I'm running inside-out to a fully qualified subdomain. My internal IP is 192.168.1.77, and the reverse proxy is my router at 192.168.1.1.
Working nginx reverse proxy config:
With x-forwarded-for set to $remote_addr:
Without x-forwarded-for set:
ClementToche commentedon Jul 2, 2022
I'm running NodeRed 2.2.2 and I'm having the same missing feature.
I would like to secure my server with fail2ban but the log still not show any IP address :
2 Jul 15:42:41 - [audit] {"event":"auth.login.fail.credentials","username":"[email protected]","client":"node-red-editor","scope":"","level":98,"timestamp":1656769361308}Does someone has a patch for this ? is this scheduled to be put into version 3 of NodeRed ?
hardillb commentedon Jul 2, 2022
@ClementToche The problem is that at the point we know the wrong password has been provided we are deep in a PassportJS callback stack and don't have access to the requesting IP address.
node-red/packages/node_modules/@node-red/editor-api/lib/auth/strategies.js
Line 110 in f760354
ClementToche commentedon Jul 3, 2022
@hardillb, Thanks for answering and I see the problem.
Another solution would be to print 2 traces, 1 when a client connect to the server web front-end and 1 when credentials fails.
Fail2Ban is able to parse 2 lines and I can easily make a regex in this way.
To give an example, mosquitto (MQTT open source server) print those 2 lines :
New connection from 192.168.1.10:6565 on port 8883Client <unknown> disconnected, not authorised.First line would be printed by the web server front-end when new client connects.
And second line would be printed as already developed in NodeRed code.
Of course, this is not a perfect solution for big server that could have 2 user connection at the very same time but this is for sure enough for personal server at home for which a little bit of security can be added.
Do you think it is something feasible ?
ClementToche commentedon Jun 8, 2024
Hello Node-RED team.
I would like to raise that up on top of the list since it's a very old request.
Node-RED is a very good tool that can be used for many stuff in a professional grade way but it really need the same level of quality for security requirement and this is really needed to make DDoS attack protection in place for this tool.
Is there is any chance it can come on top of the new major 3.X version ?
Thanks.
knolleary commentedon Jun 11, 2024
@ClementToche I will take another look to see how we can get the required information surfaced. As was said in previous comments, there are some architectural difficulties in getting the information in the right place so it can be logged at the right time.