{"id":25776241,"url":"https://github.com/fuzzitdev/javafuzz","last_synced_at":"2025-02-27T06:05:53.431Z","repository":{"id":52388965,"uuid":"221952404","full_name":"fuzzitdev/javafuzz","owner":"fuzzitdev","description":"coverage guided fuzz testing for java","archived":true,"fork":false,"pushed_at":"2021-04-30T03:42:39.000Z","size":371,"stargazers_count":228,"open_issues_count":6,"forks_count":25,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-06-10T12:12:45.969Z","etag":null,"topics":["fuzz-testing","fuzzer","fuzzing","java","testing"],"latest_commit_sha":null,"homepage":"https://gitlab.com/gitlab-org/security-products/analyzers/fuzzers/javafuzz","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fuzzitdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-15T15:34:51.000Z","updated_at":"2024-05-31T05:11:33.000Z","dependencies_parsed_at":"2022-09-06T03:43:09.490Z","dependency_job_id":null,"html_url":"https://github.com/fuzzitdev/javafuzz","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuzzitdev%2Fjavafuzz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuzzitdev%2Fjavafuzz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuzzitdev%2Fjavafuzz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fuzzitdev%2Fjavafuzz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fuzzitdev","download_url":"https://codeload.github.com/fuzzitdev/javafuzz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987435,"owners_count":19889333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fuzz-testing","fuzzer","fuzzing","java","testing"],"created_at":"2025-02-27T06:01:19.838Z","updated_at":"2025-02-27T06:05:53.424Z","avatar_url":"https://github.com/fuzzitdev.png","language":"Java","readme":"fuzzit.dev was [acquired](https://about.gitlab.com/press/releases/2020-06-11-gitlab-acquires-peach-tech-and-fuzzit-to-expand-devsecops-offering.html) by GitLab and the new home for this repo is [here](https://gitlab.com/gitlab-org/security-products/analyzers/fuzzers/javafuzz)\n\n# Javafuzz: coverage-guided fuzz testing for Java\n\nJavafuzz is coverage-guided [fuzzer](https://developer.mozilla.org/en-US/docs/Glossary/Fuzzing) \nfor testing Java packages.\n\nFuzzing for safe languages like nodejs is a powerful strategy for finding bugs like unhandled exceptions, logic bugs,\nsecurity bugs that arise from both logic bugs and Denial-of-Service caused by hangs and excessive memory usage.\n\nFuzzing can be seen as a powerful and efficient strategy in real-world software in addition to classic unit-tests.\n\n## Usage\n\n### Fuzz Target\n\nThe first step is to implement the following function (also called a fuzz target):\n\n```java\npublic class FuzzExample extends AbstractFuzzTarget {\n    public void fuzz(byte[] data) {\n        try {\n            BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));\n        } catch (IOException e) {\n            // ignore as we expect this exception\n        }\n    }\n}\n```\n\nFeatures of the fuzz target:\n\n* Javafuzz will call the fuzz target in an infinite loop with random data (according to the coverage guided algorithm) passed to `buf`.\n* The function must catch and ignore any expected only (dont catch Exception) exceptions that arise when passing invalid input to the tested package.\n* The fuzz target must call the test function/library with with the passed buffer or a transformation on the test buffer \nif the structure is different or from different type.\n* Fuzz functions can also implement application level checks to catch application/logical bugs - For example: \ndecode the buffer with the testable library, encode it again, and check that both results are equal. To communicate the results\nthe result/bug the function should throw an exception.\n* Javafuzz will report any unhandled exceptions as crashes as well as inputs that hit the memory limit specified to javafuzz\nor hangs/they run more the the specified timeout limit per testcase.\n\n### Installing\nAdd this to your `pom.xml`\n\n```yaml\n  \u003cdependencies\u003e\n    \u003cdependency\u003e\n      \u003cgroupId\u003edev.fuzzit.javafuzz\u003c/groupId\u003e\n      \u003cartifactId\u003ecore\u003c/artifactId\u003e\n      \u003cversion\u003e1.23-SNAPSHOT\u003c/version\u003e\n      \u003cscope\u003etest\u003c/scope\u003e\n    \u003c/dependency\u003e\n  \u003c/dependencies\u003e\n\n\u003cplugin\u003e\n        \u003cplugin\u003e\n          \u003cgroupId\u003edev.fuzzit.javafuzz\u003c/groupId\u003e\n          \u003cartifactId\u003ejavafuzz-maven-plugin\u003c/artifactId\u003e\n          \u003cversion\u003e1.22\u003c/version\u003e\n        \u003c/plugin\u003e\n\u003c/plugins\u003e\n```\n\n\n### Running\n\nThe next step is to javafuzz with your fuzz target function\n\n\n```bash\ndocker run -it maven:3.6.2-jdk-11 /bin/bash\ngit clone https://github.com/fuzzitdev/javafuzz.git\ncd javafuzz\nmvn install\ncd examples\nwget -O jacocoagent.jar https://github.com/fuzzitdev/javafuzz/raw/master/javafuzz-maven-plugin/src/main/resources/jacocoagent-exp.jar\nMAVEN_OPTS=\"-javaagent:jacocoagent.jar\" mvn javafuzz:fuzz -DclassName=dev.fuzzit.javafuzz.examples.FuzzYaml\n```\n\n\n```bash\n\n\n# Output:\n#0 READ units: 0\n#1 NEW     cov: 61 corp: 0 exec/s: 1 rss: 23.37 MB\n#23320 PULSE     cov: 61 corp: 1 exec/s: 10614 rss: 35.3 MB\n#96022 NEW     cov: 70 corp: 1 exec/s: 11320 rss: 129.95 MB\n#96971 NEW     cov: 78 corp: 2 exec/s: 10784 rss: 129.95 MB\n#97046 NEW     cov: 79 corp: 3 exec/s: 9375 rss: 129.95 MB\n#97081 NEW     cov: 81 corp: 4 exec/s: 11666 rss: 129.95 MB\n#97195 NEW     cov: 93 corp: 5 exec/s: 9500 rss: 129.95 MB\n#97216 NEW     cov: 97 corp: 6 exec/s: 10500 rss: 129.95 MB\n#97238 NEW     cov: 102 corp: 7 exec/s: 11000 rss: 129.95 MB\n#97303 NEW     cov: 108 corp: 8 exec/s: 10833 rss: 129.96 MB\n#97857 PULSE     cov: 108 corp: 9 exec/s: 225 rss: 129.96 MB\n#97857 PULSE     cov: 108 corp: 9 exec/s: 0 rss: 940.97 MB\n#97857 PULSE     cov: 108 corp: 9 exec/s: 0 rss: 1566.01 MB\n```\n\nThis example quickly finds an infinite hang which takes all the memory in `jpeg-js`.\n\n### Corpus\n\nJavafuzz will generate and test various inputs in an infinite loop. `corpus` is optional directory and will be used to\nsave the generated testcases so later runs can be started from the same point and provided as seed corpus.\n\nJavafuzz can also start with an empty directory (i.e no seed corpus) though some valid test-cases in the seed corpus\nmay speed up the fuzzing substantially.  \n\nJavafuzz tries to mimic some of the arguments and output style from [libFuzzer](https://llvm.org/docs/LibFuzzer.html).\n\nMore fuzz targets examples (for real and popular libraries) are located under the examples directory and\nbugs that were found using those targets are listed in the trophies section.\n\n### Coverage\n\nFor coverage instrumentation we use [JaCoCo library](https://github.com/jacoco/jacoco)\n\n\n## Other languages\n\nCurrently this library also exists for the following languages:\n* javascript [jsfuzz](https://github.com/fuzzitdev/jsfuzz)\n* python via [pythonfuzz](https://github.com/fuzzitdev/pythonfuzz)\n\n## Credits \u0026 Acknowledgments\n\nJavafuzz is a port of [fuzzitdev/jsfuzz](https://github.com/fuzzitdev/jsfuzz).\n\nWhich in turn based based on [go-fuzz](https://github.com/dvyukov/go-fuzz) originally developed by [Dmitry Vyukov's](https://twitter.com/dvyukov).\nWhich is in turn heavily based on [Michal Zalewski](https://twitter.com/lcamtuf) [AFL](http://lcamtuf.coredump.cx/afl/).\n\nAnother solid fuzzing with coverage library for java is [JQF](https://github.com/rohanpadhye/jqf) but is more\nfocused on semantic fuzzing (i.e structure aware) and thus depends on quickcheck. JavaFuzz does not \ndepends on any framework an focuses on mutations producing buffer array and using coverage to find more bugs.\n\n## Contributions\n\nContributions are welcome!:) There are still a lot of things to improve, and tests and features to add. We will slowly post those in the\nissues section. Before doing any major contribution please open an issue so we can discuss and help guide the process before\nany unnecessary work is done.\n\n","funding_links":[],"categories":["测试","Secure Programming","Java"],"sub_categories":["Fuzzing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuzzitdev%2Fjavafuzz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffuzzitdev%2Fjavafuzz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffuzzitdev%2Fjavafuzz/lists"}