-
Notifications
You must be signed in to change notification settings - Fork 20
Add metadata-extractor CVE-2019-14262 target #28
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
Open
mjkoo
wants to merge
5
commits into
master
Choose a base branch
from
metadata-extractor-cve-2019-14262
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| mayhem/ | ||
| README.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| FROM gradle:6.7.1-jdk15 as builder | ||
|
|
||
| RUN apt-get update && apt-get -y install \ | ||
| patch && \ | ||
| rm -rf /var/apt/lists/* | ||
|
|
||
| WORKDIR /build | ||
| COPY exception-handler.patch exception-handler.patch | ||
| RUN git clone https://github.com/drewnoakes/metadata-extractor.git -b 2.12.0 && \ | ||
| cd metadata-extractor && \ | ||
| patch -p1 < ../exception-handler.patch && \ | ||
| sed -e "s/'1.6'/'1.8'/g" -i build.gradle && \ | ||
| gradle --no-daemon jar && \ | ||
| mkdir ../artifacts && \ | ||
| cp build/libs/metadata-extractor-2.1.1.jar ../artifacts && \ | ||
| wget https://repo1.maven.org/maven2/com/adobe/xmp/xmpcore/6.1.11/xmpcore-6.1.11.jar && \ | ||
| cp xmpcore-6.1.11.jar ../artifacts | ||
|
|
||
| FROM openjdk:17-jdk-slim | ||
|
|
||
| WORKDIR /app | ||
| COPY --from=builder /build/artifacts/*.jar ./ | ||
|
|
||
| ENTRYPOINT ["java", "-cp", "/app/xmpcore-6.1.11.jar:/app/metadata-extractor-2.1.1.jar", "com.drew.imaging.ImageMetadataReader"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Metadata Extractor CVE-2019-14262 Example | ||
|
|
||
| This target replicates finding [CVE-2019-14262](https://nvd.nist.gov/vuln/detail/CVE-2019-14262), a stack exhaustion bug caused by uncontrolled recursion in version 2.1.0 of the metadata-extractor library ([CVSS Score](https://nvd.nist.gov/vuln-metrics/cvss): 7.5). | ||
|
|
||
| This vulnerability was reported to the maintainers and resolved [here](https://github.com/drewnoakes/metadata-extractor/issues/419). | ||
|
|
||
| Note that the CVE is for the C# version of the same code, where one cannot typically recover from a stack overflow. | ||
| This example reproduces the vulnerability in the Java version to demonstrate the Java fuzzing capabilities of Mayhem. | ||
|
sciencemanx marked this conversation as resolved.
|
||
|
|
||
| ## To build | ||
|
|
||
| Assuming you just want to build the docker image, run: | ||
|
|
||
| ```bash | ||
| docker build -t forallsecure/metadata-extractor-cve-2019-14262 . | ||
| ``` | ||
|
|
||
| ## Get from Dockerhub | ||
|
|
||
| If you don't want to build locally, you can pull a pre-built image directly from Dockerhub: | ||
|
|
||
| ```bash | ||
| docker pull forallsecure/metadata-extractor-cve-2019-14262 | ||
| ``` | ||
|
|
||
| ## Run under Mayhem | ||
|
|
||
| Change to the `metadata-extractor-cve-2019-14262` folder and run: | ||
|
|
||
| ```bash | ||
| mayhem run mayhem/metadata-extractor | ||
| ``` | ||
|
|
||
| and watch Mayhem replicate the bug! | ||
| This bug should be found within a minute of starting the run. | ||
|
|
||
| ## Run locally | ||
|
|
||
| Change to the `metadata-extractor-cve-2019-14262` folder and run: | ||
|
|
||
| ```bash | ||
| docker run --rm -v `pwd`:/in forallsecure/metadata-extractor-cve-2019-14262 /in/mayhem/metadata-extractor/poc/crashing-input | ||
| ``` | ||
|
|
||
| ## POC | ||
|
|
||
| We have included a proof of concept output under the `poc` directory. | ||
|
|
||
| > Note: Fuzzing has some degree of non-determinism, so when you run yourself you may not get exactly this file. | ||
| > This is expected; your output should still trigger the bug. | ||
|
|
||
| This bug was originally found by ForAllSecure employee [Alex Rebert](https://forallsecure.com/about-us). | ||
| This bug has since been [fixed](https://github.com/drewnoakes/metadata-extractor/issues/419) by project maintainers. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| diff --git a/Source/com/drew/imaging/ImageMetadataReader.java b/Source/com/drew/imaging/ImageMetadataReader.java | ||
| index 628ec9e5..e2b97daa 100644 | ||
| --- a/Source/com/drew/imaging/ImageMetadataReader.java | ||
| +++ b/Source/com/drew/imaging/ImageMetadataReader.java | ||
| @@ -252,9 +252,8 @@ public class ImageMetadataReader | ||
| Metadata metadata = null; | ||
| try { | ||
| metadata = ImageMetadataReader.readMetadata(file); | ||
| - } catch (Exception e) { | ||
| - e.printStackTrace(System.err); | ||
| - System.exit(1); | ||
| + } catch (ImageProcessingException ipe) { | ||
| + return; | ||
| } | ||
| long took = System.nanoTime() - startTime; | ||
| if (!markdownFormat) |
10 changes: 10 additions & 0 deletions
10
metadata-extractor-cve-2019-14262/mayhem/metadata-extractor/Mayhemfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| version: '1.10' | ||
| project: metadata-extractor-cve-2019-14262 | ||
| target: metadata-extractor | ||
| baseimage: forallsecure/metadata-extractor-cve-2019-14262 | ||
| duration: 600 | ||
| cmds: | ||
| - cmd: /app/metadata-extractor-2.1.1.jar @@ | ||
| env: | ||
| MFUZZ_JAVA: "1" | ||
| CLASSPATH: /app/xmpcore-6.1.11.jar |
Binary file added
BIN
+368 Bytes
metadata-extractor-cve-2019-14262/mayhem/metadata-extractor/corpus/test-1
Binary file not shown.
Binary file added
BIN
+368 Bytes
metadata-extractor-cve-2019-14262/mayhem/metadata-extractor/poc/crashing-input
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.