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

Swallowed Error in CircuitRelayV2 if reservations.defaultDataLimit is set to number #1903

Closed
justin0mcateer opened this issue Jul 26, 2023 · 1 comment · Fixed by #1778 · May be fixed by #2133
Closed

Swallowed Error in CircuitRelayV2 if reservations.defaultDataLimit is set to number #1903

justin0mcateer opened this issue Jul 26, 2023 · 1 comment · Fixed by #1778 · May be fixed by #2133
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@justin0mcateer
Copy link

  • Version:
    0.45.9

  • Platform:
    Linux master 6.3.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 30 May 2023 13:44:01 +0000 x86_64 GNU/Linux
    Brave Browser 114.1.52.117

  • Subsystem:
    CircuitRelayV2

Severity:

Low

Description:

When configuring 'reservations' on the CircuitRelayServer, there is a very easy landmine to hit. Setting the 'defaultDataLimit' to any number will cause all relay connections to start failing. This is caused because the configuration value is passed directly through to 'countStreamBytes' with no validation.
https://github.com/libp2p/js-libp2p/blob/master/packages/libp2p/src/circuit-relay/utils.ts#L14

While the operation will throw a TypeError due to the mixed types, it will not be seen because of the way countStreamBytes used in a pipeline submitted to queueMicroTask.

Steps to reproduce the error:

  • create a CircuitRelayServer service
  • configure 'reservations.defaultDataLimit' to any number (eg. 131072)
  • observe CircuitRelay connections will be setup but fail to upgrade
@justin0mcateer justin0mcateer added the need/triage Needs initial labeling and prioritization label Jul 26, 2023
@maschad
Copy link
Member

maschad commented Jul 27, 2023

Related #1573

@maschad maschad moved this to 🛠️ Todo in js-libp2p Jul 27, 2023
@maschad maschad moved this from 🛠️ Todo to 🏃‍♀️In Progress in js-libp2p Sep 5, 2023
@maschad maschad added kind/bug A bug in existing code (including security flaws) and removed need/triage Needs initial labeling and prioritization labels Sep 12, 2023
@github-project-automation github-project-automation bot moved this from 🏃‍♀️In Progress to 🎉Done in js-libp2p Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws)
Projects
Archived in project
2 participants