Repository navigation
discard introspection data cached against an outdated introspector set - #450
Open
rootvector2 wants to merge 1 commit into
Open
rootvector2 wants to merge 1 commit into
rootvector2 wants to merge 1 commit into
Conversation
getIntrospectionData fills descriptorsCache with an unsynchronized get/compute/put, while addBeanIntrospector, removeBeanIntrospector and resetBeanIntrospectors invalidate that cache by clearing it. A thread that already entered fetchIntrospectionData when the introspector list changes stores its pre-change result after the clear has run, and the entry is never invalidated again, so registering SuppressPropertiesBeanIntrospector concurrently with a read of the same bean class leaves the suppressed property readable and writable. Stamp the introspector-set version before introspecting and remove 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.
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.
PropertyUtilsBean.getIntrospectionDatafillsdescriptorsCachewith an unsynchronized get/compute/put, while the three methods that change the registeredBeanIntrospectorlist (addBeanIntrospector,removeBeanIntrospector,resetBeanIntrospectors) invalidate that cache by clearing it (#435). A thread that already enteredfetchIntrospectionDatawhen 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 thePropertyUtilsBean.Registering
SuppressPropertiesBeanIntrospectorwhile another thread reads the same bean class consequently leaves the suppressed property readable and writable throughgetProperty,setPropertyandBeanUtilsBean.populate, so the documented CVE-2014-0114 / BEANUTILS-463 hardening fails open. The defaultsresetBeanIntrospectorsinstalls (SUPPRESS_CLASS,SUPPRESS_DECLARING_CLASS) sit in the same window, and the sharedPropertyUtilssingleton is commonly warmed by framework or ORM threads, so the two orders do overlap in practice.Found by auditing the
descriptorsCacheinvalidation 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":
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 throughclearDescriptorCaches()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.testAddBeanIntrospectorDuringIntrospectionInvalidatesCacheis a deterministic version of the race: a latch-blockingBeanIntrospectorholds the fetch open while the suppressor is registered. Onmasterit fails withand it passes with the change.
Full default goal is green: 1318 tests, 0 failures, 0 errors,
apache-ratandcheckstyleclean.mvn; that'smvnon the command line by itself.