Skip to content

Conversation

@yhoztak
Copy link

@yhoztak yhoztak commented Mar 14, 2025

🐕 Corgea issued a PR to fix a vulnerability found in insecure-java/src/main/java/com/example/catapp/controllers/CommentController.java.

It is CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') that has a severity of 🔴 High.

🪄 Fix explanation

The fix mitigates the XSS vulnerability by sanitizing user input using "StringEscapeUtils.escapeHtml4", which neutralizes potentially harmful HTML content before storing it in the database.
- The fix imports "StringEscapeUtils" from Apache Commons Text to handle input sanitization.
- The method "escapeHtml4" is applied to "commentText" to escape HTML tags, preventing script execution.
- The sanitized input is then safely stored in the "Comment" object, mitigating XSS risks.

💡 Important Instructions

Ensure that all user inputs across the application are similarly sanitized to prevent XSS vulnerabilities.

See the issue and fix in Corgea.

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