rapid7 / rex-socket

The Rex Socket Abstraction Library
Other
12 stars 33 forks source link

Set underlying comm value during initialization and do not change it #40

Closed smashery closed 2 years ago

smashery commented 2 years ago

This change supports PR 15706 in Metasploit.

The fact that comm could change at any time (i.e. as the route table changes) made it very difficult to reason about the state of the parameters object. If the route table is changed after a session is established, then the params object associated with the session object could then change its comm value. It is helpful for a Metasploit session object to use the params object to initialize sockets; but if they could change between creation of the session and creation of the socket, this introduces a race condition whereby a session is appropriately set up, but a socket it creates (e.g. via TCP forwarding) believes it's being passed through a different session, or none at all.

This commit also adds the comm attribute to sockets, so that sockets can deduce which session they're listening on.

smashery commented 2 years ago

Actually never mind; I found the API I should have been using instead; this PR won't be needed for the other change.