Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Ldap Node): Fix issue with connections not closing correctly #7432

Merged
merged 3 commits into from
Oct 13, 2023

Conversation

pemontto
Copy link
Contributor

@pemontto pemontto commented Oct 13, 2023

This PR fixes an issue where we never actually disconnect from the LDAP server. We've seen this cause problems in live systems where netstat confirms we have 10s of 1000s of connections open causing a DoS of the LDAP server.

Fixes

The PR implements two solutions to solve this:

  1. Play whack-a-mole and try to ensure we unbind everywhere we should including when we hit errors
  2. Add an optional connection timeout to clean-up anything we may not catch

I've also updated the credentials to allow empty bind DN and password to support anonymous binds.

Questions

  1. Should we set a default connection timeout, something like 5 mins, or 15 mins based on AD's MaxConnIdleTime?
  2. Should the optional timeout be configurable in the node, or just in the credentials?

@github-actions
Copy link
Contributor

Great PR! Please pay attention to the following items before merging:

Files matching packages/**:

  • If fixing bug, added test to cover scenario.
  • If addressing forum or Github issue, added link to description.

Files matching packages/**/*.ts:

  • Added unit tests to cover new or updated functionality.

Files matching packages/nodes-base/nodes/**:

  • Added workflow tests for nodes if possible.

Make sure to check off this list before asking for review.

@Joffcom
Copy link
Member

Joffcom commented Oct 13, 2023

Hey @pemontto,

Thanks for this, I think having it in the credential makes the most sense as chances are you won't want to set it per node. I feel like a 5 minute default is probably going to be the safest option to start with and if someone needs it tweaked they have that option available.

@pemontto pemontto changed the title fix(Ldap Node): Fix hanging TCP connections fix(Ldap Node): Hanging TCP connections cause DoS Oct 13, 2023
@n8n-assistant n8n-assistant bot added community Authored by a community member node/improvement New feature or request labels Oct 13, 2023
@pemontto
Copy link
Contributor Author

@Joffcom I've set the default timeout to 5 minutes. When the timeout occurs it throws with ERROR: SearchRequest: Operation timed out, works well!

@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Attention: 28 lines in your changes are missing coverage. Please review.

Comparison is base (ec14141) 33.50% compared to head (ff0396b) 33.49%.
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7432      +/-   ##
==========================================
- Coverage   33.50%   33.49%   -0.01%     
==========================================
  Files        3389     3390       +1     
  Lines      207038   207069      +31     
  Branches    22346    22345       -1     
==========================================
- Hits        69373    69365       -8     
- Misses     136543   136582      +39     
  Partials     1122     1122              
Files Coverage Δ
...ackages/nodes-base/credentials/Ldap.credentials.ts 0.00% <ø> (ø)
packages/nodes-base/nodes/Ldap/Helpers.ts 0.00% <0.00%> (ø)
packages/nodes-base/nodes/Ldap/Ldap.node.ts 0.00% <0.00%> (ø)

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Joffcom Joffcom changed the title fix(Ldap Node): Hanging TCP connections cause DoS fix(Ldap Node): Fix issue with connections not closing correctly Oct 13, 2023
@Joffcom Joffcom merged commit c3f0be8 into n8n-io:master Oct 13, 2023
11 checks passed
@github-actions github-actions bot mentioned this pull request Oct 18, 2023
netroy added a commit that referenced this pull request Oct 18, 2023
# [1.12.0](https://github.com/n8n-io/n8n/compare/n8n@1.11.0...n8n@1.12.0)
(2023-10-18)


### Bug Fixes

* **core:** Add check that queue is defined and remove cyclic dependency
([#7404](#7404))
([45f2ef3](45f2ef3))
* **core:** Do not throw when deleting workflows with executions without
binary-data ([#7411](#7411))
([2b6a15e](2b6a15e))
* **core:** Fix expression with paired item with multi-input node
([#7424](#7424))
([ec14141](ec14141))
* **core:** Fix ignoring crashed executions without event msgs
([#7368](#7368))
([2f4d91b](2f4d91b))
* **core:** Pg-promise de-initialization fix
([#7417](#7417))
([7703904](7703904))
* **core:** Prevent false stalled jobs in queue mode from displaying as
errored ([#7435](#7435))
([e01b9e5](e01b9e5))
* **core:** Prevent undefined issues when restoring binary data
([#7419](#7419))
([46977a2](46977a2))
* **editor:** Fix remote options fetching on every keystroke
([#7320](#7320))
([367255a](367255a))
* **editor:** Open only one tab with plans page
([#7377](#7377))
([c599006](c599006))
* **Google Sheets Node:** Update by row_number, restored 'Handling Extra
Data Option', updated Cell Format default
([#7357](#7357))
([d8531a5](d8531a5))
* **Ldap Node:** Fix issue with connections not closing correctly
([#7432](#7432))
([c3f0be8](c3f0be8))
* **Set Node:** Null should not throw an error
([#7416](#7416))
([e9b6ab0](e9b6ab0))
* **TheHive 5 Node:** Observable encoding in alert > create fix
([#7450](#7450))
([a2d2e3d](a2d2e3d))


### Features

* **core:** Make executions pruning interval configurable
([#7439](#7439))
([40707fa](40707fa))
* **Google Calendar Trigger Node:** Add support for cancelled events
([#7436](#7436))
([9d241a0](9d241a0))
* **HubSpot Trigger Node:** Add support for ticket related events
([#7156](#7156))
([57c6093](57c6093))
* **n8n Form Trigger Node:** New node
([#7130](#7130))
([3ddc176](3ddc176))
* **Spreadsheet File Node:** Improve CSV parsing
([#7448](#7448))
([79f23fb](79f23fb))

Co-authored-by: netroy <netroy@users.noreply.github.com>
@janober
Copy link
Member

janober commented Oct 18, 2023

Got released with n8n@1.12.0

elsmr pushed a commit that referenced this pull request Oct 19, 2023
# [1.12.0](https://github.com/n8n-io/n8n/compare/n8n@1.11.0...n8n@1.12.0)
(2023-10-18)


### Bug Fixes

* **core:** Add check that queue is defined and remove cyclic dependency
([#7404](#7404))
([45f2ef3](45f2ef3))
* **core:** Do not throw when deleting workflows with executions without
binary-data ([#7411](#7411))
([2b6a15e](2b6a15e))
* **core:** Fix expression with paired item with multi-input node
([#7424](#7424))
([ec14141](ec14141))
* **core:** Fix ignoring crashed executions without event msgs
([#7368](#7368))
([2f4d91b](2f4d91b))
* **core:** Pg-promise de-initialization fix
([#7417](#7417))
([7703904](7703904))
* **core:** Prevent false stalled jobs in queue mode from displaying as
errored ([#7435](#7435))
([e01b9e5](e01b9e5))
* **core:** Prevent undefined issues when restoring binary data
([#7419](#7419))
([46977a2](46977a2))
* **editor:** Fix remote options fetching on every keystroke
([#7320](#7320))
([367255a](367255a))
* **editor:** Open only one tab with plans page
([#7377](#7377))
([c599006](c599006))
* **Google Sheets Node:** Update by row_number, restored 'Handling Extra
Data Option', updated Cell Format default
([#7357](#7357))
([d8531a5](d8531a5))
* **Ldap Node:** Fix issue with connections not closing correctly
([#7432](#7432))
([c3f0be8](c3f0be8))
* **Set Node:** Null should not throw an error
([#7416](#7416))
([e9b6ab0](e9b6ab0))
* **TheHive 5 Node:** Observable encoding in alert > create fix
([#7450](#7450))
([a2d2e3d](a2d2e3d))


### Features

* **core:** Make executions pruning interval configurable
([#7439](#7439))
([40707fa](40707fa))
* **Google Calendar Trigger Node:** Add support for cancelled events
([#7436](#7436))
([9d241a0](9d241a0))
* **HubSpot Trigger Node:** Add support for ticket related events
([#7156](#7156))
([57c6093](57c6093))
* **n8n Form Trigger Node:** New node
([#7130](#7130))
([3ddc176](3ddc176))
* **Spreadsheet File Node:** Improve CSV parsing
([#7448](#7448))
([79f23fb](79f23fb))

Co-authored-by: netroy <netroy@users.noreply.github.com>
@github-actions github-actions bot mentioned this pull request Oct 23, 2023
netroy added a commit that referenced this pull request Oct 23, 2023
## [1.11.2](https://github.com/n8n-io/n8n/compare/n8n@1.11.1...n8n@1.11.2)
(2023-10-23)


### Bug Fixes

* **core:** Handle gzip and deflate compressed request payloads
([#7461](#7461))
([f43ff71](f43ff71))
* **core:** Prevent false stalled jobs in queue mode from displaying as
errored ([#7435](#7435))
([465a952](465a952))
* **core:** Reduce logging overhead for levels that do not output
([#7479](#7479))
([010aa57](010aa57))
* **editor:** Allow importing the same workflow multiple times
([#7458](#7458))
([33e3df8](33e3df8)),
closes [#7457](#7457)
* **editor:** Fix canvas selection breaking after interacting with node
actions ([#7466](#7466))
([90ce8de](90ce8de))
* **editor:** Fix connections disappearing after reactivating canvas and
renaming a node ([#7483](#7483))
([b0bd0d8](b0bd0d8))
* **editor:** Open only one tab with plans page
([#7377](#7377))
([d14e9cb](d14e9cb))
* **Ldap Node:** Fix issue with connections not closing correctly
([#7432](#7432))
([60ca02e](60ca02e))
* **MySQL Node:** Resolve expressions in v1
([#7464](#7464))
([2b18909](2b18909))
* **TheHive 5 Node:** Observable encoding in alert > create fix
([#7450](#7450))
([b9547ad](b9547ad))

Co-authored-by: netroy <netroy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member node/improvement New feature or request Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants