Skip to content

fix: enforce identity restrictions on nested template resolution#198

Open
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-48
Open

fix: enforce identity restrictions on nested template resolution#198
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-48

Conversation

@JuliaKalder
Copy link
Copy Markdown
Owner

Summary

  • resolveNestedTemplates was looking up {{template:Name}} includes from ALL templates, ignoring their identities restrictions — identity-scoped templates could be silently included by any other template.
  • In insertTemplateIntoTab, the current compose identity is now fetched at the top of the function via messenger.compose.getComposeDetails(tabId).
  • allTemplates is filtered to allowedTemplates before the lookup maps are built: a template passes if its identities field is absent/empty (unrestricted) or explicitly lists the current identity.
  • The filtered maps are passed to resolveNestedTemplates, so nested includes can only resolve templates the active identity is permitted to use.

Test plan

  • All existing template-insert.test.js tests continue to pass (confirmed locally — 7 pre-existing failures in template-store.test.js migrateV0toV1 are unrelated to this change).
  • Manually: compose a message with identity A, insert a template containing {{template:RestrictedForB}} where RestrictedForB.identities = ["identityB"] — the include should not resolve (warn and leave marker or skip).
  • Verify that templates with no identities restriction still resolve normally for any identity.
  • Verify templates explicitly listing the current identity still resolve correctly.

Fixes #48

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MEDIUM] resolveNestedTemplates bypasses identity restrictions on included templates

1 participant