fix: enforce identity restrictions on nested template resolution#198
Open
JuliaKalder wants to merge 1 commit into
Open
fix: enforce identity restrictions on nested template resolution#198JuliaKalder wants to merge 1 commit into
JuliaKalder wants to merge 1 commit into
Conversation
resolveNestedTemplates previously resolved {{template:Name}} includes
against ALL templates regardless of their identities field. This allowed
identity-restricted templates to be silently included by any template,
bypassing access controls.
Fix: in insertTemplateIntoTab, fetch the current identity from
getComposeDetails at the top of the function and filter the template
list to only those whose identities array is empty/absent (unrestricted)
or explicitly includes the current identity, before building the lookup
maps passed to resolveNestedTemplates.
Fixes #48
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.
Summary
resolveNestedTemplateswas looking up{{template:Name}}includes from ALL templates, ignoring theiridentitiesrestrictions — identity-scoped templates could be silently included by any other template.insertTemplateIntoTab, the current compose identity is now fetched at the top of the function viamessenger.compose.getComposeDetails(tabId).allTemplatesis filtered toallowedTemplatesbefore the lookup maps are built: a template passes if itsidentitiesfield is absent/empty (unrestricted) or explicitly lists the current identity.resolveNestedTemplates, so nested includes can only resolve templates the active identity is permitted to use.Test plan
template-insert.test.jstests continue to pass (confirmed locally — 7 pre-existing failures intemplate-store.test.jsmigrateV0toV1are unrelated to this change).{{template:RestrictedForB}}whereRestrictedForB.identities = ["identityB"]— the include should not resolve (warn and leave marker or skip).identitiesrestriction still resolve normally for any identity.Fixes #48