[#992] Apply the confidentiality of a backend index to the running backend - #1000
Open
vharseko wants to merge 2 commits into
Open
[#992] Apply the confidentiality of a backend index to the running backend#1000vharseko wants to merge 2 commits into
vharseko wants to merge 2 commits into
Conversation
…ex to the running backend setConfidential() only compared the setting with the one the index was opened with, so a change of confidentiality-enabled reached neither the CryptoSuite the indexes of the attribute share nor the codecs bound to it, and the comparison never converged: every later change of that index untrusted it again and asked for a rebuild which could not help. The change now puts the new setting in force on that suite before the indexes it adds bind their codecs, so the key hashed index enabling confidentiality creates encrypts its records as well, and gives up the trees of the indexes it keeps: one write untrusts and deletes them, a second opens them again, which is what binds their codecs to the setting now in force. Their records are in the encoding being given up, which the codec of the new one reads back as an empty set of entry IDs rather than failing, so leaving them would answer searches with no entries at all until the rebuild had run. Fixes OpenIdentityPlatform#992
…lity change with its release CodeQL (java/unreleased-lock) flagged the lock taken under `treesGivenUp` and released under the same condition in the finally block: the two are balanced, since the flag is a local which cannot change in between, but the query cannot see that, and the shape reads worse than the one which replaces it. The branch which gives up the trees now takes the lock and releases it as a pair of its own; the write which applies the new configuration to the indexes that are kept becomes writeUpdatedIndexes(), called by that branch and by the one which changes nothing but the entry limit. No behaviour changes.
vharseko
requested review from
maximthomas
and removed request for
maximthomas
September 10, 2026 06:51
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.
Fixes #992
DefaultIndex.setConfidentialonly compared the setting with the one the index was opened with. Nothing moved theCryptoSuitethe indexes of the attribute share to the new value, and nothing bound their codecs again, soconfidentiality-enabledreached the running backend in neither direction, and the comparison never converged: every later change of that index -index-entry-limitincluded - untrusted it again and asked for a rebuild which could not help.The declared admin action of the property is that the index has to be rebuilt (
BackendIndexConfiguration.xml:230), not that the component has to be restarted, so this makes the implementation answer for what is documented.What the change does
AttributeIndex.applyConfigurationChangecompares the old configuration with the new one itself -setConfidentialleaves theIndexinterface, since an index does not need to know about this setting - and when the confidentiality changed:CryptoSuite, throughEntryContainer.setIndexConfidentiality, which keeps the cipher of the backend. Done before the write which opens the indexes this change adds, so the key hashed index that enabling confidentiality of an equality index creates binds its codec to the new setting and encrypts its records, rather than only hashing its keys. Applied outside the writes, which the storage may replay: it changes a live object and is idempotent;writeUpdatedIndexes().The trees are given up rather than left to the rebuild because their records are in the encoding of the setting being given up, and the codec of the new one does not read them back as what they are: an encrypted record read as clear text decodes to an empty set of entry IDs rather than failing, which is a search answered with no entries at all. An empty untrusted index answers "undefined" instead, and so is not used until the rebuild has run. They are deleted rather than emptied record by record, which for an index of any size would be a transaction of its own making, and in two writes rather than one because the storage engines delete and create the tree of an index as operations of their own - as removing and adding an index does. That order also decides how an interrupted change ends: the write which deletes is the one which untrusts, so what is left is an index the next open of the container creates empty and keeps degraded, never a trusted one holding nothing.
DefaultIndex.codecbecomesvolatile, since it is now bound again on a live instance other threads are holding.Tests
IndexConfidentialityChangeTestCase, with a subclass per storage engine (PDBIndexConfidentialityChangeTest,JEIndexConfidentialityChangeTest) because deleting and creating the tree of an index is the engine's own operation. Five behaviours each, all failing before the change:Run green: the ten new tests together with
EncryptedPDBTestCase,EncryptedJETestCase,PDBTestCase,JETestCase,ReplayedConfigChangeTest,DefaultIndexTest,EntryIDSetTest,StateTestandOnDiskMergeImporterTest- 225 tests, no failures.Not in this change
An online
rebuild-indexof an index whose confidentiality was never changed is unaffected. The offline rebuild already applied the setting correctly, since it opens a container of its own; it still does.