Описание
Micronaut has Unbounded bundleCache in ResourceBundleMessageSource that Allows Memory Exhaustion via Accept-Language Header
Summary
ResourceBundleMessageSource maintains two caches: messageCache (bounded at 100 entries via ConcurrentLinkedHashMap) and bundleCache (unbounded ConcurrentHashMap). The bundleCache is keyed by (Locale, baseName) where the locale originates from the HTTP Accept-Language header. In applications that explicitly register a ResourceBundleMessageSource bean and serve HTML error responses, an unauthenticated attacker can exhaust heap memory by sending requests with large numbers of unique Accept-Language values, each causing a new entry in the unbounded bundleCache. Unlike GHSA-2hcp-gjrf-7fhc and the sibling messageCache (both bounded), bundleCache was not updated to use a bounded cache implementation.
Details
The bundleCache is initialized in inject/src/main/java/io/micronaut/context/i18n/ResourceBundleMessageSource.java at line 150:
The resolveBundle() method at line 169 inserts into bundleCache with no eviction policy:
The attack path requires:
- The application registers a
ResourceBundleMessageSourcebean (non-default, requires explicit user configuration). - The attacker sends requests that trigger HTML error responses — i.e., requests with
Accept: text/htmlto any URL that returns an error (e.g., 404 for any non-existent path). - Each request uses a unique
Accept-Languagevalue (e.g.,zz-AA,zz-AB, …). DefaultHtmlErrorResponseBodyProvider.error()callsmessageSource.getMessage(code, locale)→CompositeMessageSourcedelegates toResourceBundleMessageSource→resolveBundle(locale)inserts one entry per unique locale intobundleCache.
For locales that don't match any bundle file, ResourceBundle.getBundle() throws MissingResourceException and Optional.empty() is stored — a low-cost sentinel. For locales that DO match a bundle, a full ResourceBundle object is retained in memory. In either case, the map itself and the MessageKey objects grow without bound.
Note: the messageCache is bounded at 100 entries but does not prevent bundleCache growth, as resolveBundle() is called directly (bypassing messageCache) whenever a messageCache miss occurs.
PoC
Against a Micronaut application with a ResourceBundleMessageSource bean registered (e.g., @Bean ResourceBundleMessageSource messages() { return new ResourceBundleMessageSource("messages"); }):
Each unique zz-XXXX tag creates one new bundleCache entry. The MessageKey (Locale + baseName) and map overhead cost approximately 100-200 bytes per entry. At 100,000 entries, heap consumption from the cache alone reaches roughly 20 MB — significant in resource-constrained deployments. If a locale matches a bundle file, retained ResourceBundle objects cost substantially more per entry.
Impact
- Only affects applications that explicitly register a
ResourceBundleMessageSourcebean (not the default configuration). - Requires the ability to send HTTP requests with
Accept: text/htmlheaders and control over theAccept-Languagevalue. - Memory grows approximately 100-200 bytes per novel locale (for non-matching locales) up to several KB per locale if bundles are found. Sustained attack over time causes gradual heap exhaustion.
- Partial availability impact (A:L) under sustained attack in long-running services.
Recommended Fix
Apply the same bounded-cache pattern used for the sibling messageCache:
The number of distinct resource bundle files is bounded at compile time; a limit of 50 entries is more than sufficient for any realistic i18n configuration while fully preventing unbounded growth.
Ссылки
- https://github.com/micronaut-projects/micronaut-core/security/advisories/GHSA-3rfq-4wpf-qqw3
- https://nvd.nist.gov/vuln/detail/CVE-2026-44242
- https://github.com/micronaut-projects/micronaut-core/releases/tag/v3.10.6
- https://github.com/micronaut-projects/micronaut-core/releases/tag/v3.8.14
- https://github.com/micronaut-projects/micronaut-core/releases/tag/v4.10.22
Пакеты
io.micronaut:micronaut-inject
>= 4.10.0, < 4.10.22
4.10.22
io.micronaut:micronaut-inject
>= 3.10.0, < 3.10.6
3.10.6
io.micronaut:micronaut-inject
< 3.8.14
3.8.14
Связанные уязвимости
Micronaut Framework is a JVM-based full stack Java framework designed for building modular, easily testable JVM applications. Prior to 4.10.22, the bundleCache is keyed by (Locale, baseName) where the locale originates from the HTTP Accept-Language header. In applications that explicitly register a ResourceBundleMessageSource bean and serve HTML error responses, an unauthenticated attacker can exhaust heap memory by sending requests with large numbers of unique Accept-Language values, each causing a new entry in the unbounded bundleCache. This vulnerability is fixed in 4.10.22.