Skip to content

fix(security): patch CVE-2022-41404 DoS vulnerability (CRITICAL) - #10

Merged
szkiba merged 1 commit into
mainfrom
security-fix-patch-cve-2022-41404-dos-vulnerability
Jan 30, 2026
Merged

szkiba merged 1 commit into
mainfrom
security-fix-patch-cve-2022-41404-dos-vulnerability

Conversation

@szkiba

@szkiba szkiba commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Implement configurable recursion depth limit to prevent stack overflow from circular variable references in INI file variable substitution.

Changes

  • Add CircularReferenceException for clear error reporting
  • Add Config.maxResolveDepth property (default: 16, configurable via -Dorg.ini4j.config.maxResolveDepth=N)
  • Implement depth tracking through fetchInternal() methods in BasicProfile and BasicOptionMap
  • Add package-protected getConfig() methods for config access
  • Add hasVariableSubstitution() helper to check for ${...} patterns

Security Impact

CVE-2022-41404: Denial of Service via infinite recursion

  • Attack vector: Circular references like [a] x=${b/y} and [b] y=${a/x}
  • Impact: StackOverflowError crashes JVM
  • Mitigation: Throw CircularReferenceException when depth limit exceeded

Testing

  • Add 3 regression tests for circular reference detection:
    • BasicProfileTest.testFetchRecursiveInfiniteLoop
    • BasicOptionMapTest.testFetchCircularReference
    • BasicProfileSectionTest.testFetchCircularReferenceAcrossSections
  • All 206 tests passing

Acknowledgments

Thanks to bingdian for the original vulnerability report on SourceForge ticket #56.

Additional thanks to Marc Lafon, paradox, and Craig for their contributions to identifying and documenting this issue.

Fixes #6

Implement configurable recursion depth limit to prevent stack overflow
from circular variable references in INI file variable substitution.

**Changes:**

- Add CircularReferenceException for clear error reporting
- Add Config.maxResolveDepth property (default: 16, configurable via
  -Dorg.ini4j.config.maxResolveDepth=N)
- Implement depth tracking through fetchInternal() methods in
  BasicProfile and BasicOptionMap
- Add package-protected getConfig() methods for config access
- Add hasVariableSubstitution() helper to check for ${...} patterns

**Security Impact:**

CVE-2022-41404: Denial of Service via infinite recursion
- Attack vector: Circular references like [a] x=${b/y} and [b] y=${a/x}
- Impact: StackOverflowError crashes JVM
- Mitigation: Throw CircularReferenceException when depth limit exceeded

**Testing:**

- Add 3 regression tests for circular reference detection:
  * BasicProfileTest.testFetchRecursiveInfiniteLoop
  * BasicOptionMapTest.testFetchCircularReference
  * BasicProfileSectionTest.testFetchCircularReferenceAcrossSections
- All 206 tests passing

**Acknowledgments:**

Thanks to [bingdian](https://sourceforge.net/u/bingdians/profile/)
for the original vulnerability report on SourceForge ticket #56.

Additional thanks to Marc Lafon, paradox, and Craig for their
contributions to identifying and documenting this issue.

Fixes #6
@szkiba szkiba linked an issue Jan 30, 2026 that may be closed by this pull request
5 tasks
@szkiba
szkiba merged commit dda3743 into main Jan 30, 2026
@szkiba
szkiba deleted the security-fix-patch-cve-2022-41404-dos-vulnerability branch January 30, 2026 18:43
@tswern tswern mentioned this pull request Nov 10, 2026
10 of 18 tasks
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 Fix: Patch CVE-2022-41404 DoS vulnerability

1 participant