rootvector2 opened a new pull request, #450: URL: https://github.com/apache/commons-beanutils/pull/450
`PropertyUtilsBean.getIntrospectionData` fills `descriptorsCache` with an unsynchronized get/compute/put, while the three methods that change the registered `BeanIntrospector` list (`addBeanIntrospector`, `removeBeanIntrospector`, `resetBeanIntrospectors`) invalidate that cache by clearing it (#435). A thread that already entered `fetchIntrospectionData` when the list changes therefore stores its pre-change result after the clear has run, and nothing invalidates that entry again, so the stale descriptors stay cached for the life of the `PropertyUtilsBean`. Registering `SuppressPropertiesBeanIntrospector` while another thread reads the same bean class consequently leaves the suppressed property readable and writable through `getProperty`, `setProperty` and `BeanUtilsBean.populate`, so the documented CVE-2014-0114 / BEANUTILS-463 hardening fails open. The defaults `resetBeanIntrospectors` installs (`SUPPRESS_CLASS`, `SUPPRESS_DECLARING_CLASS`) sit in the same window, and the shared `PropertyUtils` singleton is commonly warmed by framework or ORM threads, so the two orders do overlap in practice. Found by auditing the `descriptorsCache` invalidation added in #435 for the case where that invalidation and a cache fill overlap. Reproduced with a single reader thread and no custom introspector, 400 rounds of "start reader, register the suppressor, check whether the suppressed property is still visible": ``` rounds=400 leaks(suppressed property still present)=347 // before rounds=400 leaks(suppressed property still present)=0 // after ``` The fix stamps the introspector-set version before introspecting and conditionally removes the entry again when the version changed while the fetch was running, so the next caller refetches against the current introspectors. `clearDescriptors()` now routes through `clearDescriptorCaches()` so it carries the same stamp. Single-threaded behavior is unchanged. Different root cause from the neighbouring changes in this area: #435 added the missing invalidation (here the invalidation runs and is then undone by an in-flight fetch), #413 / #431 are the mapped-descriptor fallback in `getPropertyDescriptor`, and #439 / #449 are unrelated to the cache. `PropertyUtilsTest.testAddBeanIntrospectorDuringIntrospectionInvalidatesCache` is a deterministic version of the race: a latch-blocking `BeanIntrospector` holds the fetch open while the suppressor is registered. On `master` it fails with ``` Suppressed property should have no descriptor ==> expected: <null> but was: <java.beans.PropertyDescriptor[name=stringProperty; ...]> ``` and it passes with the change. Full default goal is green: 1318 tests, 0 failures, 0 errors, `apache-rat` and `checkstyle` clean. - [x] Read the [contribution guidelines](CONTRIBUTING.md) for this project. - [x] Read the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) if you use Artificial Intelligence (AI). - [x] I used AI to create any part of, or all of, this pull request. Which AI tool was used to create this pull request, and to what extent did it contribute? - [x] Run a successful build using the default [Maven](https://maven.apache.org/) goal with `mvn`; that's `mvn` on the command line by itself. - [x] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
