-
Notifications
You must be signed in to change notification settings - Fork 37.7k
build: set ENABLE_IPC to OFF when fuzzing #33235
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
base: master
Are you sure you want to change the base?
Conversation
Currently a `BUILD_FOR_FUZZING` build will failure to configure, with missing `capnp`.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33235. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
IPC is by default on, and any build will fail with missing |
It's already special cased though: |
Yes, the multiprocess binary targets are correctly disabled already on current master https://cirrus-ci.com/task/4847132122808320?logs=ci#L2057:
|
Yea. So failing to configure because a dependency you don't even need, isn't installed, doesn't make any sense. |
IIUC, this change which toggles off the ENABLE_IPC option automatically when BUILD_FOR_FUZZING is set is safe for now because the fuzz test binary doesn't currently call any IPC code. The change makes it more convenient to run the fuzz test without capnp installed since you don't have to turn off ENABLE_IPC manually. But I think we would want to revert this change as soon as any fuzz test is written that does call IPC code, so it does seem like there may not much long term benefit in making it, if I understand correctly. It would be good to have some fuzz tests exercising IPC code. |
Is anyone working on that? I guess @Sjors? |
I could put together something very basic like a fuzz test calling the |
Made a note to add a fuzz test if @darosior or @ryanofsky don't get around to it. Would prefer to leave this ON unless such a PR doesn't land before branch-off. Maybe add a v30 milestone? |
I think marcofleon may pick this up next month? |
Just leaving a few notes on fuzzing the IPC interfaces. There are several approaches to fuzzing the IPC interface and not all of them make sense within our repo. If we add IPC fuzz tests in the repo they should not spawn separate processes and not do actual IPC over a socket. This is because the fuzz tests we have in our repo are designed to run in a single process. We could add tests that call the c++ handler methods for the various interface functions either directly or through the capnp wrappers (only if possible without actual ipc). This should work and depending on the approach might not even require capnp as a dependency. This approach would likely suffer from instability due to state build up, just like the RPC fuzz tests. Another approach could be to add IPC fuzz tests to fuzzamoto, where the test would essentially simulate an actual application connecting to the IPC interfaces (i.e. doing real IPC over a socket). The snapshot fuzzing approach would also avoid the state build up problem. This is the approach I would take, if I was gonna work on it. There is also the question of what to target and what assurances it gives us. The IPC interface is trusted, so from a security perspective it's mostly uninteresting (e.g. a crash in this interface isn't considered a security issue). So really, we should mostly fuzz to gain confidence in stability and correctness, for which I'd suggest:
|
Thanks @dergoegge this is really helpful. It's been hard for me to think about what would constitute a meaningful fuzz test, and it still may not be exactly clear, but this provides a great framework. I just have two question
Not spawning separate processes makes sense, but I assumed it might be ok to communicate across an internal sockiet, e.g. with socketpair? That is what a lot of IPC unit tests are doing.
This is true currently, but it would be possible to make IPC interfaces that are untrusted by checking inputs more rigorously and adding resource caps like maximum number of threads or block templates (in case of the mining interface) an IPC client could create. So I'd be curious if it would affect the recommended fuzzing strategy if we did offer untrusted interfaces or decide to make the mining interface less trusted in the future. |
I'd advise against this (e.g. does this work for all OSs in CI?, might be slower) but it might also be fine.
In addition to what I suggested above, I'd fuzz any capnp code that would be exposed (e.g. deserialization) and check what kind of assurances they make w.r.t. security. https://capnproto.org/faq.html#is-capn-proto-secure looks reasonable, except for "the RPC layer is not robust against resource exhaustion attacks, possibly allowing denials of service". |
I'm happy to work on this. Still thinking about the best approach. It seems like using fuzzamoto is ultimately most effective, but it might be worth trying to get a baseline single-process fuzz test into the repo? This would probably be a more practical starting point for me too, but I'm open to suggestions. |
I think so yes, otherwise it might not make the branch-off. |
tACK af4156a I ran into this while trying to measure fuzz coverage. |
A
BUILD_FOR_FUZZING
build will currently failure to configure, with missingcapnp
.