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

XXE Mitigation #870

Merged
merged 5 commits into from
May 10, 2021
Merged

Conversation

gmwalker
Copy link
Contributor

@gmwalker gmwalker commented May 6, 2021

Reference Issue

Fixes #869

What does this implement/fix? Explain your changes.

This address the issue of XXE Vulnerability by changing SvgDtdResolver so it only resolves external resources if SvgDocument.ResolveExternalResources is true. SvgDocument will no longer resolve external resources by default, to be on the safe side as suggested in the issue.

Any other comments?

In SvgDtdResolver I narrowed the check around whether to serve up the embedded svg11.dtd to URIs that look like DTD requests.  Only checking for 'svg' could match a directory named 'svg' containing a different resource altogether - which was a problem I encountered making the unit tests for this pull request.

This is my first contribution to this project and I'm looking forward to collaborating with you all.

…XXE attacks. The existing functionality resolving svg11.dtd references to the embedded version was preserved.
…to URIs that look like DTD requests. Only checking for 'svg' could match a directory named 'svg' containing a different resource.
@gmwalker gmwalker changed the title feature/869-prevent-xxe XXE Mitigation May 6, 2021
Copy link
Member

@mrbean-bremen mrbean-bremen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution, this looks good! Can you please add an entry in the release notes?

private const string SvgTextId = "secretText";
private const string Secret = "This is a secret!";
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done

@gmwalker
Copy link
Contributor Author

Added "change" to release notes, as requested.

@mrbean-bremen mrbean-bremen merged commit 062dc7c into svg-net:master May 10, 2021
@mrbean-bremen
Copy link
Member

Thank you!

github-actions bot pushed a commit that referenced this pull request May 10, 2021
…s Nuget README.md Samples Source Tests doc docfx.json index.md license.txt No longer resolves external resources in DTDs by default, to prevent XXE attacks. The existing functionality resolving svg11.dtd references to the embedded version was preserved. BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Added tests to show the vulnerability and the mitigation. BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Narrowed the check around whether to serve up the embedded svg11.dtd to URIs that look like DTD requests. Only checking for 'svg' could match a directory named 'svg' containing a different resource.
@kimsey0
Copy link
Contributor

kimsey0 commented May 11, 2021

What perfect timing! We just noticed this problem too. Do you know anything about when the next release will be?

Thanks a lot, @gmwalker! ♥

This was referenced May 11, 2021
github-actions bot pushed a commit to piaoye2019/SVG that referenced this pull request Jul 31, 2021
…nerators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt No longer resolves external resources in DTDs by default, to prevent XXE attacks. The existing functionality resolving svg11.dtd references to the embedded version was preserved. BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Added tests to show the vulnerability and the mitigation. BuildProcessTemplates CONTRIBUTING.md Generators Nuget README.md Samples Source Tests doc docfx.json index.md license.txt Narrowed the check around whether to serve up the embedded svg11.dtd to URIs that look like DTD requests. Only checking for 'svg' could match a directory named 'svg' containing a different resource.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Security: vulnerable to XXE attacks
4 participants