Audits autoescape bypasses, sanitizes Markdown with allowlists, and writes sanitization tests to prevent XSS when rendering untrusted content.
Ships in browser-extensions. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Template engines autoescape by default, so the vulnerable surface is small and enumerable: it is exactly the places where something says this value is already safe HTML. Find those first; everything else is already handled.
# Server-side (Jinja/Django templates + the Python that feeds them)
grep -rnE '\|\s*safe|Markup\(|autoescape false|mark_safe' templates/ src/
# Client-side
grep -rnE 'innerHTML|outerHTML|insertAdjacentHTML|document\.write' web/ static/
Every hit is a claim that needs justification. A |safe on a value that came from
a database column is a claim about everything that has ever been written to that
column, including via an import path nobody remembers.
Markdown renderers pass raw HTML through by design — that is a documented feature, not a bug. So a shared template filter shaped like this is an XSS sink:
# BAD — the filter marks arbitrary stored markup trusted.
def _markdown(text: str) -> Markup:
return Markup(markdown.markdown(text, extensions=["extra", "tables"]))
"Only admins author content" is not a boundary. As soon as there is an import path, a seed script, or a second author, the content store is untrusted input.
Render, then sanitize with an allowlist, and only then mark trusted:
import markdown, nh3
from markupsafe import Markup
ALLOWED_TAGS = {
"p", "br", "hr", "em", "strong", "code", "pre", "blockquote",
"h1", "h2", "h3", "h4", "h5", "h6", "ul", "ol", "li",
"a", "img", "table", "thead", "tbody", "tr", "th", "td",
}
ALLOWED_ATTRS = {
"a": {"href", "title", "rel"},
"img": {"src", "alt", "title"},
"th": {"style", "align"},
"td": {"style", "align"},
}
def _markdown(text: str) -> Markup:
html = markdown.markdown(text, extensions=["extra", "tables"])
return Markup(nh3.clean(
html,
tags=ALLOWED_TAGS,
attributes=ALLOWED_ATTRS,
filter_style_properties={"text-align"}, # see below
))
Do not hand-roll the allowlist logic. Use a maintained HTML sanitizer
(nh3, the Rust/ammonia-backed successor to bleach). Regex-stripping <script>
is not sanitization.
Markdown's tables extension encodes column alignment as an inline style —
<th style="text-align: left;">. An allowlist that drops style is "secure" and
silently removes alignment from every table in the corpus. Allow style on
table cells and constrain which properties survive (filter_style_properties).
Then note that the sanitizer normalizes what it keeps: text-align: left;
comes back as text-align:left — no space, no trailing semicolon. An
exact-output test must expect the normalized form, not the string Markdown
emitted, or it fails on a correct fix.
One filter feeds every post body, every FAQ answer, every description. Changing it re-renders all of them at once, and the failure mode is not a crash — it is content quietly losing a construct.
Render every piece of authored content before and after the change and diff it character by character, then keep that as a regression test:
@pytest.mark.parametrize("path", sorted(CONTENT_DIR.glob("*.md")))
def test_authored_content_is_unchanged_by_sanitization(path):
raw = markdown.markdown(path.read_text(), extensions=EXTENSIONS)
assert _markdown(path.read_text()) == raw
If no authored file contains raw HTML, that equality holds and any future diff is a genuine regression. If some file does need raw HTML, you have found the one case worth an explicit decision instead of discovering it in production.
The same value is often rendered several times on one page: in prose, in
<meta> tags, and inside a JSON-LD <script> block. A whole-document assertion
therefore reports a vulnerability that isn't one:
# BAD — fails even when the prose is correctly sanitized.
assert "<script>alert(1)</script>" not in html
Template tojson filters emit HTML-safe JSON — angle brackets become
\u003c / \u003e, so the JSON-LD copy cannot break out of its
<script> element and is not a vulnerability. But the payload's text still
appears there, so a document-wide assertion goes red while the prose is
perfectly sanitized. Scope the assertion to the rendered prose:
article = extract_article_html(html)
assert "<script>" not in article
assert "<script>" in article # proves it was escaped, not dropped
Assert the escaped form is present, not just that the dangerous form is absent — otherwise a filter that silently deletes the whole field passes.
Also scope the audit: a feed or export built from separately-escaped title/description fields that never includes the body is not part of this surface. Don't "fix" it.
Server-side escaping does nothing for a client that re-injects the same value
through innerHTML. A card grid rendered safely by the server and a detail modal
built with a template literal are two independent sinks, and the second one is
usually the one that got missed.
// Prefer the API that cannot execute markup.
el.textContent = item.description;
// When you must build markup, escape into a local first.
const description = escapeHtml(item.description);
const tags = item.tags.map(escapeHtml).join(", ");
modal.innerHTML = `<p>${description}</p><footer>${tags}</footer>`;
Escaping into a const before the template literal is not just style: wrapping
the expression inline pushes the line past the linter's length limit, and
reflowing the HTML string to fit introduces leading whitespace that is visible
inside white-space: pre-wrap blocks. Escape first, interpolate second.
Asserting that no on* attribute appears in rendered output looks like a strong
XSS regression test, and it goes red immediately: application templates
legitimately emit handlers (onclick="showDetail(3)"). A test that fails on
correct code gets deleted within a week.
Allowlist the handlers your own templates emit and assert on the remainder:
handlers = re.findall(r'\son(\w+)="([^"]*)"', card_html)
assert handlers == [("click", "showDetail(3)")]
Pinning the full list (rather than not any(...)) also catches a second,
injected handler alongside the legitimate one — presence assertions can't.
- [ ] Every |safe / Markup() / mark_safe / innerHTML site enumerated and justified
- [ ] Markdown (and any rich-text) output passes through an allowlist sanitizer
before being marked trusted — a maintained library, not a regex
- [ ] Allowlist keeps constructs the renderer depends on (table-cell style),
and tests expect the sanitizer's normalized output
- [ ] Authored content diffed before/after the filter change, pinned by a test
- [ ] Sanitization tests assert on the rendered prose, and assert the escaped
form is present — not just that the raw payload is absent
- [ ] Client-side injection points escape too (or use textContent)
- [ ] Handler/attribute assertions allowlist what the app's own templates emit
What SKILL.md sets; muted values are Claude Code's defaults
10 skills in this plugin
/building-accessible-interfacesMakes web and app UIs usable by keyboard, screen-reader, low-vision and motion-sensitive users — semantic HTML before ARIA, labelled controls, visible focus, WCAG AA contrast measured rather than eyeballed, touch targets, reduced motion, and automated axe checks plus a manual keyboard pass in CI or before every UI PR. Use when building or restyling a screen, adding a form, modal, menu or custom control, choosing colors, or reviewing a UI change./wiring-application-configLoad, merge, and validate layered application configuration (defaults plus a user YAML/TOML/JSON file or a stored settings object) so a mis-wired or misspelled key fails loudly instead of silently reverting to the default — sections the code reads that exist nowhere, sections that exist but nothing reads, unvalidated recursive merges, `bool`-passes-as-`int`, defaults aliased by a shallow merge, falsy-but-valid values killed by `or`/`||`, partial write-backs that are stickier than a missing file, and bootstrap ordering that swallows the loader's own warnings. Use when adding a config key, writing or reviewing a config loader/merge/schema, reading a setting in a new module, persisting user settings, wiring logging from config, or debugging a setting that "has no effect"./building-browser-extensionsBuilds and tests Manifest V3 browser extensions — service-worker message channels that survive teardown, chrome.storage read-modify-write safety, settings validation in the popup, and a Jest chrome mock that can actually fail. Use when writing or reviewing a background service worker, a popup that reads/writes chrome.storage, an extension's Jest suite, or debugging an extension whose UI silently stops responding./shipping-build-artifactsMake the build step a real gate on what you actually distribute — build scripts that warn and exit 0 on a missing input, size checks with only an upper bound, hand-maintained file lists that drift from the entrypoints they must cover, committed bundles that go stale when only the source changes, GNU-only shell in release scripts that aborts on the other OS, and verification that runs against the source tree instead of the artifact. Use when writing or reviewing a build/package script, a `dist/` copy step, a release workflow that uploads a zip or installer, or a committed compiled asset./running-github-actions-efficientlyCut GitHub Actions minutes and wall-clock time without losing coverage — the OS billing multiplier (macOS 10x / Windows 2x / Linux 1x), trigger hygiene that stops push+pull_request double-firing, concurrency that cancels superseded runs, dependency caching keyed on lockfiles, matrix discipline, and auditing scheduled crons that bill 24/7. Use when CI is burning included minutes, when runs feel slow, when setting up a new repo's workflows, or when reviewing an existing workflow for waste./keeping-git-repos-cleanPrevents, detects, and remediates files that should never be committed — secrets (.env, API tokens, hardcoded credentials) and dev artifacts (build output, scratch databases, editor/OS files). Covers .gitignore (and why it does not untrack), git rm --cached, auditing tracked files, history scrubbing, and credential rotation. Use when a repo has committed secrets or junk, when setting up a new repo's ignore rules, or when reviewing what a repo actually tracks./browser-extensions:rendering-untrusted-contentfrom browser-extensions
npx claudepluginhub wdm0006/python-skills --plugin browser-extensionsOther plugins' skills for the same job