fix: security hardening — XXE protection, class loading restrictions, dependency upgrades - #1
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…deps - Add XXE protections to XmlBeanDefinitionReader (both src/ and src+/): disable DOCTYPE declarations, external general/parameter entities, XInclude - Add class name denylist in BeanDefinition.setBeanClassName() to block dangerous classes (Runtime, ProcessBuilder, Thread, javax.naming, etc.) - Replace swallowed e.printStackTrace() with thrown IllegalArgumentException - Upgrade dependencies: JUnit 4.7->4.13.2, aspectjweaver 1.6.11->1.9.22, cglib-nodep 2.1_3->3.3.0, Java source/target 1.6->1.8 Co-Authored-By: Scoldfield <530314297@qq.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Security audit and hardening of the tiny-spring codebase. Fixes critical and medium-severity issues found during a full scan:
CRITICAL fixes:
XmlBeanDefinitionReader(bothsrc/andsrc+/) now disables DOCTYPE declarations, external general/parameter entities, and XInclude processing. Previously, malicious XML could read local files, perform SSRF, or cause DoS via billion-laughs attacks.BeanDefinition.setBeanClassName()now includes a denylist blocking dangerous classes (Runtime,ProcessBuilder,Thread,javax.naming.*,java.net.*,java.io.*,java.lang.reflect.Proxy). Previously, untrusted XML could trigger instantiation of any class on the classpath.MEDIUM fixes:
3. Information Disclosure — Replaced
e.printStackTrace()inBeanDefinitionwith a thrownIllegalArgumentException, preventing stack trace leakage to stderr.4. Outdated Dependencies — Upgraded JUnit 4.7→4.13.2, aspectjweaver 1.6.11→1.9.22, cglib-nodep 2.1_3→3.3.0, Java source/target 1.6→1.8.
Not found (N/A for this library): No hardcoded secrets, SQL injection, CORS, HTTP endpoints, debug endpoints, or auth layers.
Review & Testing Checklist for Human
DocumentBuilderFactoryfeatures match OWASP recommendationsBeanDefinition.setBeanClassName()— consider whether additional classes should be blocked or if an allowlist approach is more appropriate for your use casemvn compileto confirm compilation succeeds (note: 2 pre-existing test failures exist on Java 17 due to cglib module-system incompatibility and a missing field in test XML config — these are not caused by this PR)java.io.*orjava.net.*packages, verify they are not unintentionally blocked by the new denylistNotes
source option 6 is no longer supported), so the Java 1.6→1.8 upgrade was required.ApplicationContextTest.testandApplicationContextTest.testPostBeanProcessor) exist on master and are unrelated to these changes — they stem from cglib's incompatibility with Java 17's module system and aNoSuchFieldExceptionin the test XML config.aopalliance 1.0was not upgraded because 1.0 is the only version ever released.Link to Devin session: https://app.devin.ai/sessions/2f5ed20a86974f4d8016d4badc36861f
Requested by: @scoldfield