Repository navigation
fix(core): room consolidation applies the privacy filter before the embedder (#1464) - #1604
Merged
Merged
Conversation
…mbedder (#1464) The consolidated text was embedded first and filtered on store, so a remote embedding backend could receive an unmasked secret. The text is now validated and masked before it is embedded; strict mode refuses it and nothing is embedded.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
ConsolidationStore::embed_contentruns the privacy filter before the embedder: the text is masked (or refused in strict mode) and the masked text is embedded, so the vector matches the stored text. The comment ininsert_memorythat claimed the earlier embedding was harmless is corrected. CHANGELOG entry under the 0.22.0 Security section.Why
Found by the Cora review of the v0.22.0 release PR (#1603): consolidated text came from an LLM, was embedded first and masked only when stored. With an
openaiorollamabackend an unmasked secret in that text would reach the remote embedding provider. The sources were already masked when written, so the exposure needed the LLM to introduce a secret (or the filter to be off at write time), but the order was wrong and strict mode could not prevent it.Testing
cargo fmt,cargo clippy --workspace --all-targets --locked -- -D warnings,cargo test --workspace --locked.consolidated_text_is_filtered_before_it_is_embedded: a recording embedder never sees the token in default mode, and in strict mode the text is refused and nothing is embedded. It fails with the old behaviour (checked by reverting the change).