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

Fix code scanning alert no. 3: Resolving XML external entity in user-controlled data #258

Merged
merged 2 commits into from
Sep 26, 2024

Conversation

hazendaz
Copy link
Member

Fixes https://github.com/mybatis/ibatis-2/security/code-scanning/3

To fix the problem, we need to ensure that the XML parser is fully secured against XXE attacks by disabling the parsing of external entities. This involves setting additional features on the DocumentBuilderFactory to disallow DOCTYPE declarations and external entities.

  1. Disable DOCTYPE declarations by setting the feature http://apache.org/xml/features/disallow-doctype-decl to true.
  2. Ensure that external entities are not processed by setting the feature http://xml.org/sax/features/external-general-entities and http://xml.org/sax/features/external-parameter-entities to false.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

hazendaz and others added 2 commits September 25, 2024 22:38
…controlled data

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@hazendaz hazendaz marked this pull request as ready for review September 26, 2024 03:05
@hazendaz
Copy link
Member Author

trying partial now until I can look at the doc types.

@coveralls
Copy link

coveralls commented Sep 26, 2024

Coverage Status

coverage: 65.171% (+0.009%) from 65.162%
when pulling 849e99d on autofix/alert-3-60a2799539
into b80acbe on master.

@hazendaz hazendaz merged commit ba20fd0 into master Sep 26, 2024
30 checks passed
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.

2 participants