Skip to content

fix(security): treat as and is as the element's tag - #603

Merged
farnabaz merged 1 commit into
mainfrom
fix/security-as-is-tag
Nov 17, 2026
Merged

farnabaz merged 1 commit into
mainfrom
fix/security-as-is-tag

Conversation

@farnabaz

@farnabaz farnabaz commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Written by an AI agent (Amp) on behalf of @farnabaz, who directed the change.

The security plugin now treats as and is as the tag the element renders as, instead of only stripping a bad value.

  • An element whose as or is names a blocked tag, or a tag outside allowedTags, is removed or passed to tagFallback, like an element with that tag. Its props are validated for the named tag, so as="object" drops them all.
  • The element's own tag is still checked, since the Vue, React and Angular renderers fall back to it when no component matches as. Without this, <iframe as="x"> would get past blockedTags: ['iframe'].
  • as and is must be literal strings matching [A-Za-z0-9_-]+. Anything else is stripped (spaces, <script>, a.b, empty strings).
  • Bound selectors are always stripped: :as, v-bind:as, :is, v-bind:is (JSON strings included), variants like AS or .is, and object bindings (v-bind, v-bind:, :) that contain as/is or come from render-time data.

Behavior change: the alert plugin sets as on blockquotes (as: 'note', …). With allowedTags, alerts are now removed unless their type names are allowed too.

Frontmatter sanitizing is unchanged.

Checks run: comark tests (2110 passed, 4 skipped), the Vue bound-props tests, pnpm test:sanitizer, pnpm typecheck, oxlint, oxfmt, and the docs linter.


Read this PR faster

Summary by CodeRabbit

  • Security
    • Tag filtering checks an element’s own tag and valid literal as or is values against blocked and allowed tag lists.
    • Elements are removed if a checked tag is blocked or not allowed. Dynamic or bound values that could set as or is are stripped.
    • Props are validated against the first unsafe checked tag, or the element’s own tag if none is unsafe.
  • Documentation
    • Clarified how tag filtering handles as, is, tag, bindings, and component-like values.

@coldtea-pr-lens

coldtea-pr-lens Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
  • Redraw · drawn at 38b5b00, the branch has moved on

Architecture

Walkthrough of Strict element filtering and binding rejection for as and is props, in four steps

Read this PR faster


Data flow

No data-flow sequence changed in this PR.


Review

✨ Nothing flagged · reviewed 38b5b00


Tip

Open a diagram on the canvas, then press W or click play to walk through the change one step at a time

🪧 More tips
  • Run npx skills add coldteadotai/pr-lens, then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Run npx @coldtea/pr-lens-cli analyze --base origin/main on a branch, then npx @coldtea/pr-lens-cli render .pr-lens/graph.json. Same lenses, your own model key, before the pull request exists
  • Click the link under each diagram to open it on a canvas you can zoom, pan and step through
  • The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change
  • The CLI's render reads .github/pr-lens.yml and applies your renames, exclusions and lane pins at draw time
  • Set github.comment.collapsed: true in .github/pr-lens.yml to fold the comment behind one View architecture… row. Drawing still runs as before
  • Set github.draw: on-demand in .github/pr-lens.yml and PR Lens stops drawing pull requests on its own. Comment @pr-lens draw on a pull request when you want that one drawn
  • Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and your model provider's key as its api-key to run PR Lens from your own CI. Any /chat/completions endpoint works
  • After a push, tick Redraw to draw the latest commit
  • Switch GitHub to dark mode and the diagrams follow. The moving dots are this pull request's data in motion
  • Set github.description: false in .github/pr-lens.yml to stop PR Lens adding buttons to your PR descriptions

Thanks for using PR Lens! It's free for OSS. If it helped, a star helps other teams find it.  Star PR Lens on GitHub

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
comark Ready Ready Preview Nov 17, 2026 12:41pm UTC
comark-binding Ready Ready Preview Nov 17, 2026 12:41pm UTC
comark-json-render Ready Ready Preview Nov 17, 2026 12:41pm UTC
comark-nextjs Ready Ready Preview Nov 17, 2026 12:41pm UTC
comark-nuxt Ready Ready Preview Nov 17, 2026 12:41pm UTC
comark-svelte Ready Ready Preview Nov 17, 2026 12:41pm UTC
comark-sveltekit Ready Ready Preview Nov 17, 2026 12:41pm UTC
comark-twoslash Ready Ready Preview Nov 17, 2026 12:41pm UTC
comark-vue Ready Ready Preview Nov 17, 2026 12:41pm UTC

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Documentation previews

📚 Preview all documentation changes (follows new pushes)

Pinned to the current head: 46da220

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The security plugin now checks valid literal as and is values during tag filtering. It removes selector attributes and object bindings that can set selectors. Prop validation uses the first unsafe checked tag, or the element’s own tag.

Changes: Selector-aware tag filtering

Layer / File(s) Summary
Selector values and bindings
packages/comark/src/plugins/security.ts, packages/comark/test/plugins/security.test.ts, docs/content/4.plugins/1.built-in/security.md
The plugin adds tag-name validation and detects object bindings that can set selectors. Tests and documentation cover valid and invalid as and is values, and distinguish them from tag values.
Effective tags and prop validation
packages/comark/src/plugins/security.ts, packages/comark/test/plugins/security.test.ts, docs/content/4.plugins/1.built-in/security.md
The plugin filters the element’s own tag and valid literal as and is values, removes dynamic selector attributes and bindings, and validates props against the first unsafe checked tag. Tests and documentation describe these rules.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • comarkdown/comark#579: Restricts as, is, and tag values and overlaps with this change’s handling of bound props.
  • comarkdown/comark#598: Validates as and is tag names, overlapping with this change’s selector validation.
  • comarkdown/comark#587: Limits as and is values in the security plugin and at render time, overlapping with this change’s handling of those attributes.

Suggested reviewers: atinux, larbish

Merge Risk: Minimal · up to 46da2

The security plugin now treats as and is as the rendered tag, validates their values, and strips dynamic selector bindings. No concrete bypass or regression was found in the supplied evidence, so the change looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the security plugin now treats as and is as the element's rendered tag, which matches the raw summary (security.ts validates as/is tag names against blocked an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: the security plugin now treats as and is as the element's rendered tag, which matches the raw summary (security.ts validates as/is tag names against blocked and allowed sets, and props are validated against the resolved tag) and the PR objectives. The title is concise, specific, and uses the same terms as the objectives. No mismatch found.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 02a43b43-f765-4f63-b415-e02bb37a6904
Commits

Reviewing files that changed from the base of the PR and between 38b5b00 and 46da220.

Files selected for processing: 2

  • docs/content/4.plugins/1.built-in/security.md
  • packages/comark/test/plugins/security.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

An element whose `as` or `is` names a blocked or not-allowed tag is now
removed or passed to tagFallback, and its props are validated for that tag.
The element's own tag is still checked, as renderers fall back to it.

`as` and `is` must be literal strings of letters, digits, `_` and `-`.
Bound selectors (`:as`, `v-bind:is`) and object bindings that can set
them are stripped.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1e96f-e90f-749c-89b5-4a49d93eadd0
Co-authored-by: Ahad Birang <farnabaz@gmail.com>
@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

comark

npm i https://pkg.pr.new/comark@603

@comark/angular

npm i https://pkg.pr.new/@comark/angular@603

@comark/ansi

npm i https://pkg.pr.new/@comark/ansi@603

@comark/html

npm i https://pkg.pr.new/@comark/html@603

@comark/nuxt

npm i https://pkg.pr.new/@comark/nuxt@603

@comark/react

npm i https://pkg.pr.new/@comark/react@603

@comark/svelte

npm i https://pkg.pr.new/@comark/svelte@603

@comark/vue

npm i https://pkg.pr.new/@comark/vue@603

commit: 46da220

@codspeed

codspeed Bot commented Nov 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 43 untouched benchmarks


Comparing fix/security-as-is-tag (46da220) with main (cdda585)

Open in CodSpeed

@farnabaz
farnabaz merged commit 1da6775 into main Nov 17, 2026
18 checks passed
@farnabaz
farnabaz deleted the fix/security-as-is-tag branch November 17, 2026 12:55
@github-actions github-actions Bot mentioned this pull request Nov 17, 2026

This branch was successfully deployed

8 active deployments
Preview – comark-nuxt — 46da220b Deployed Nov 17, 2026 by vercel[bot]
Preview – comark-sveltekit — 46da220b Deployed Nov 17, 2026 by vercel[bot]
Preview – comark-json-render — 46da220b Deployed Nov 17, 2026 by vercel[bot]
Preview – comark-binding — 46da220b Deployed Nov 17, 2026 by vercel[bot]
Preview – comark-nextjs — 46da220b Deployed Nov 17, 2026 by vercel[bot]
Preview – comark-twoslash — 46da220b Deployed Nov 17, 2026 by vercel[bot]
Preview – comark-vue — 46da220b Deployed Nov 17, 2026 by vercel[bot]
Preview – comark-svelte — 46da220b Deployed Nov 17, 2026 by vercel[bot]
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.

2 participants