Skip to content

Potential fix for code scanning alert no. 66: Resolving XML external entity in user-controlled data#11

Draft
JDGologic wants to merge 1 commit intomainfrom
alert-autofix-66
Draft

Potential fix for code scanning alert no. 66: Resolving XML external entity in user-controlled data#11
JDGologic wants to merge 1 commit intomainfrom
alert-autofix-66

Conversation

@JDGologic
Copy link
Copy Markdown
Owner

Potential fix for https://github.com/JDGologic/WebGoat/security/code-scanning/66

To fix the XXE vulnerability, always configure the XMLInputFactory to prevent access to external entities—regardless of securityEnabled flag. The recommended mitigation for StAX is to set the properties XMLConstants.ACCESS_EXTERNAL_DTD and XMLConstants.ACCESS_EXTERNAL_SCHEMA to empty strings, which disables access to external resources.

  • In CommentsCache.java, within parseXml(String xml, boolean securityEnabled), remove the conditional and set these two properties unconditionally before parsing the XML.
  • You may remove the securityEnabled flag or keep it for educational purposes, but security should always be enforced when handling untrusted XML.
  • No additional dependencies are needed, only use of standard Java XML APIs.

Files/regions to change:

  • CommentsCache.java: Replace the block in parseXml that conditionally sets properties with code that always sets protective properties.

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

…entity in user-controlled data

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

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.

1 participant