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

netty: Add fuzz test for HttpRequestDecoder #12744

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions projects/netty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<fuzzedLibaryVersion>4.1.85.Final</fuzzedLibaryVersion>
<fuzzedLibaryVersion>4.1.115.Final</fuzzedLibaryVersion>
<exec.mainClass>io.netty.handler.codec.http.cookie.ServerCookieDecoderFuzzer</exec.mainClass>
</properties>

Expand All @@ -32,7 +32,7 @@
<dependency>
<groupId>com.code-intelligence</groupId>
<artifactId>jazzer-api</artifactId>
<version>0.12.0</version>
<version>0.22.1</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
Expand Down
1 change: 1 addition & 0 deletions projects/netty/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ primary_contact: "[email protected]"
auto_ccs:
- "[email protected]"
- "[email protected]"
- "[email protected]"
fuzzing_engines:
- libfuzzer
sanitizers:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////

package io.netty.handler;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import io.netty.buffer.Unpooled;
import io.netty.channel.embedded.EmbeddedChannel;

/**
* Base class for fuzzing the input of an inbound handler. Will report exceptions thrown by the handler.
*/
public abstract class HandlerFuzzerBase {
protected final EmbeddedChannel channel = new EmbeddedChannel();

public void test(FuzzedDataProvider provider) {
byte[] bytes = provider.consumeRemainingAsBytes();
channel.writeInbound(Unpooled.wrappedBuffer(bytes));
channel.finishAndReleaseAll();
channel.checkException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////

package io.netty.handler.codec.http;

import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import io.netty.handler.HandlerFuzzerBase;

public class HttpRequestDecoderFuzzer extends HandlerFuzzerBase {
{
channel.pipeline().addLast(new HttpRequestDecoder());
}

public static void fuzzerTestOneInput(FuzzedDataProvider fuzzedDataProvider) {
new HttpRequestDecoderFuzzer().test(fuzzedDataProvider);
}
}