wetware / pkg

Peer-to-peer cloud environment
https://wetware.run
Other
37 stars 7 forks source link

Fix zeroed-out pubsub messages due to use-after-free of capnp segments. #66

Closed lthibault closed 1 year ago

lthibault commented 1 year ago

As of Cap'n Proto v3.0.0-alpha.10, RPC messages and their arenas are pooled and zeroed between reuses. This revealed a preexisting use-after-free bug in Wetware's pubsub code. This bug was formerly harmless, but now causes pubsub to publish and receive messages containing only null bytes. This PR corrects the issue by copying pubsub message data into and out of RPC arenas.

While working on this PR, I observed a one-off data race in the pubsub unit tests. I have not been able to reproduce this, so I have created https://github.com/wetware/ww/issues/67 to track the issue. Note that it is not clear whether this is a problem in Wetware or in Cap'n Proto, nor is it clear that this issue could appear in production. It may be an artifact of the test harness. Upstream maintainers have been notified, and we will continue to track this issue.

lthibault commented 1 year ago

Nope! I'm going to look in a few other places (including CASM) and open PRs if I find anything.