Skip to content
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

Fuzz charon with malicious charon node #2375

Closed
3 tasks
dB2510 opened this issue Jun 29, 2023 · 0 comments
Closed
3 tasks

Fuzz charon with malicious charon node #2375

dB2510 opened this issue Jun 29, 2023 · 0 comments
Assignees
Labels
protocol Protocol Team tickets

Comments

@dB2510
Copy link
Contributor

dB2510 commented Jun 29, 2023

🎯 Problem to be solved

Currently we have simnet beacon mock fuzz which acts as a beacon node fuzzer by returning random responses for all the beacon node API calls.
As part of our fuzz testing efforts for charon, we need to implement a malicious charon node which should act as a charon fuzzer in a cluster. The malicious charon node should send random responses to its peers in a cluster over defined libp2p protocols.

🛠️ Proposed solution

  • Add charon_peer_fuzz feature flag to enable charon peer fuzzing over p2p network in a cluster via CLI.
  • Wrap existing p2p default writers in sendRecvOpts.writersByProtocol to write random messages when called by send functions in p2p/fuzz.go as something like:
type fuzzWriter struct {
	w pbio.Writer
}

func (fw *fuzzWriter) WriteMsg(msg proto.Message) error {
	cloneMsg := proto.Clone(msg)
	fuzz.New().Fuzz(cloneMsg)

	return fw.w.WriteMsg(cloneMsg)
}
  • Add an SendRecvOption function as:
func WithFuzzWriter() func(*sendRecvOpts) {
	return func(opts *sendRecvOpts) {
		for pID := range opts.writersByProtocol {
			opts.writersByProtocol[pID] = func(s network.Stream) pbio.Writer {
				return &fuzzWriter{w: pbio.NewDelimitedWriter(s)}
			}
		}
	}
}
  • Use WithFuzzWriter when charon_peer_fuzz feature flag is enabled.

🧪 Tests

  • Tested by new automated compose tests
  • Manually tested on core team/canary/test clusters
  • Manually tested on local compose simnet
@github-actions github-actions bot added the protocol Protocol Team tickets label Jun 29, 2023
@dB2510 dB2510 self-assigned this Jul 3, 2023
obol-bulldozer bot pushed a commit that referenced this issue Aug 1, 2023
Adds support for peer to peer fuzzing by adding a fuzz reader writer which intercepts all the libp2p messages and reads/writes fuzzed data.

category: feature
ticket: #2375
obol-bulldozer bot pushed a commit that referenced this issue Aug 4, 2023
Integrates p2p fuzz to compose.

category: test
ticket: #2375
gsora pushed a commit that referenced this issue Aug 9, 2023
Integrates p2p fuzz to compose.

category: test
ticket: #2375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
protocol Protocol Team tickets
Projects
None yet
Development

No branches or pull requests

2 participants