Skip to content

Fix: Harden TCP liveness, atomic IP assignment, and invalid network input handling - #7

Open
mertcano wants to merge 1 commit into
SubzeroLabs:mainfrom
mertcano:mertcano-patch-1
Open

Fix: Harden TCP liveness, atomic IP assignment, and invalid network input handling#7
mertcano wants to merge 1 commit into
SubzeroLabs:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

Description

This PR addresses High-severity networking and liveness vulnerabilities in the deterministic-simulator repository, as identified during the workspace-wide security audit.

Quality & Security Defects Remediated:

  • TCP Connection Liveness (msim/src/sim/net/network.rs, msim/src/sim/net/mod.rs): The simulator previously passed only the local TCP ID when deregistering a connection. This caused remote peer reads to hang indefinitely because they waited on their own local ID. The teardown path now accurately carries and routes both IDs, instantly waking the remote mailbox.
  • Network State Integrity (msim/src/sim/net/network.rs): IP conflicts (set_ip) previously mutated the address map before throwing a panic while the NetSim mutex was held, poisoning the simulator. IP assignment now strictly validates the conflict before mutation and gracefully returns typed io::ErrorKind::AddrInUse or io::ErrorKind::NotFound errors.
  • Invalid Network Input Handling: Binding to unspecified addresses without a node IP previously reached a todo!() macro, and empty ToSocketAddrs iterators triggered panics via unwrapping. These paths now gracefully return io::ErrorKind::AddrNotAvailable and io::ErrorKind::InvalidInput, respectively.

…nput handling

### Description
This PR addresses High-severity networking and liveness vulnerabilities in the `deterministic-simulator` repository, as identified during the workspace-wide security audit.

**Quality & Security Defects Remediated:**
* **TCP Connection Liveness (`msim/src/sim/net/network.rs`, `msim/src/sim/net/mod.rs`):** The simulator previously passed only the local TCP ID when deregistering a connection. This caused remote peer reads to hang indefinitely because they waited on their own local ID. The teardown path now accurately carries and routes both IDs, instantly waking the remote mailbox.
* **Network State Integrity (`msim/src/sim/net/network.rs`):** IP conflicts (`set_ip`) previously mutated the address map before throwing a panic while the `NetSim` mutex was held, poisoning the simulator. IP assignment now strictly validates the conflict before mutation and gracefully returns typed `io::ErrorKind::AddrInUse` or `io::ErrorKind::NotFound` errors.
* **Invalid Network Input Handling:** Binding to unspecified addresses without a node IP previously reached a `todo!()` macro, and empty `ToSocketAddrs` iterators triggered panics via unwrapping. These paths now gracefully return `io::ErrorKind::AddrNotAvailable` and `io::ErrorKind::InvalidInput`, respectively.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant