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

Non-strict Protocol Negotiation in js-libp2p's multistream-select #2161

Open
frystal opened this issue Oct 17, 2023 · 0 comments
Open

Non-strict Protocol Negotiation in js-libp2p's multistream-select #2161

frystal opened this issue Oct 17, 2023 · 0 comments
Labels
kind/bug A bug in existing code (including security flaws)

Comments

@frystal
Copy link

frystal commented Oct 17, 2023

  • Version:
    "js-libp2p":"js-libp2p-v0.46.14"
    "@libp2p/multistream-select",:"4.0.3"

  • Platform:
    Ubuntu20.04

  • Subsystem:
    multistream-select

Severity:

Very Low

Description:

I find bug in the select function in multistream-select that does not strictly adhere to the libp2p specification for Protocol Negotiation.

As per the specification, if either side receives anything other than the multistream protocol id as the first message, they should abort the negotiation process. However, the implementation does not enforce this. The implementation https://github.com/libp2p/js-libp2p/blob/master/packages/multistream-select/src/select.ts#L86. If the first message does not contain the PROTOCOL_ID, it is ignored.

Additionally, according to the specification, if the protocol is not supported, the Responder should respond with the string "na" to indicate that the requested protocol is Not Available. The implementation https://github.com/libp2p/js-libp2p/blob/master/packages/multistream-select/src/select.ts#L104. If the current node does not support the received protocol, it directly closes the connection without notifying the remote peer with "na".

Steps to reproduce the error:

None

Tasks

No tasks being tracked yet.
@frystal frystal added the need/triage Needs initial labeling and prioritization label Oct 17, 2023
@maschad maschad added kind/bug A bug in existing code (including security flaws) and removed need/triage Needs initial labeling and prioritization labels Nov 7, 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
Status: 🤨Needs Investigation
Development

No branches or pull requests

2 participants