Skip to content

Conversation

@SyntheticBird45
Copy link
Member

@SyntheticBird45 SyntheticBird45 commented May 12, 2025

In workspace:

  • Pulled project-pin-lite into workspace dependencies. This will later replace project-pin.

In cuprate-p2p-core:

  • Propagated the send_timeout field to TcpInBoundStream

In cuprate-helper:

  • Implemented WriteTimeout and ReadTimeout wrapper of AsyncWrite and AsyncRead respectively.
  • Implemented StreamTimeout wrapper for AsyncWrite + AsyncRead types.
  • Defined ExtractDuration trait for more flexibility on computing the timeout duration.
  • Added 6 TCP tests (read/write/ok/err and stream/err)

What & Why

Discussed during monero-project/meta#1188
Is a mitigation against https://hackerone.com/reports/2912194
Complement #423

Keep-alive or spamming connections are a denial of service attack vector. This PR implements AsyncRead/AsyncWrite timeout wrappers that will return TimedOut if an operation do not succeed after a timeout Duration.

ReadTimeout and WriteTimeout are wrapping AsyncRead and AsyncWrite respectively.
StreamTimeout is wrapping AsyncRead + AsyncWrite.

Question

Usage for P2P:

This is primarily meant to be used within the RPC server, but can also be integrated into p2p transport definition for an upper bound security. To discuss in meeting.

@github-actions github-actions bot added A-p2p Area: Related to P2P. A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-workspace Area: Changes to a root workspace file or general repo file. A-helper Area: Related to cuprate-helper. labels May 12, 2025
@SyntheticBird45 SyntheticBird45 force-pushed the send-timeout branch 4 times, most recently from 5192c03 to 6797c6c Compare May 13, 2025 14:33
nu-ansi-term = { version = "0.46", default-features = false }
paste = { version = "1", default-features = false }
pin-project = { version = "1", default-features = false }
pin-project-lite = { version = "0.2.16", default-features = false }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pin-project-lite is an already included dependency. meanwhile no crates imports pin-project, this can be replaced in the future.

@SyntheticBird45 SyntheticBird45 force-pushed the send-timeout branch 2 times, most recently from de65eab to af0bd5a Compare May 13, 2025 20:18
@SyntheticBird45 SyntheticBird45 marked this pull request as ready for review May 13, 2025 20:23
@SyntheticBird45 SyntheticBird45 force-pushed the send-timeout branch 5 times, most recently from eafafce to 323beff Compare May 13, 2025 23:20
- Pulled `project-pin-lite` into workspace dependencies. This will later replace `project-pin`.

In `cuprate-p2p-core`:
- Propagated the `send_timeout` field to TcpInBoundStream

In `cuprate-helper`:
- Implemented `WriteTimeout` and `ReadTimeout` wrapper of `AsyncWrite` and `AsyncRead` respectively.
- Implemented `StreamTimeout` wrapper for `AsyncWrite + AsyncRead` types.
- Defined `ExtractDuration` trait for more flexibility on computing the timeout duration.
- Added 6 TCP tests (read/write/ok/err and stream/err)
@SyntheticBird45 SyntheticBird45 marked this pull request as draft May 14, 2025 00:39
@SyntheticBird45
Copy link
Member Author

PR is kept in draft as there are platform specific quirks that needs to be understood and dealt with. Fwiw this PR do bring protection for UNIX based systems.

@SyntheticBird45 SyntheticBird45 added the C-fix Category: PRs that fixes code, or issues documenting a fix. label May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-dependency Area: Related to dependencies, or changes to a Cargo.{toml,lock} file. A-helper Area: Related to cuprate-helper. A-p2p Area: Related to P2P. A-workspace Area: Changes to a root workspace file or general repo file. C-fix Category: PRs that fixes code, or issues documenting a fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants