Secure input against XSS

Secure input against XSS in JavaScript — with the four heights of help laid out: do it now, make it easier for the next person to accept, work out the right move when you are stuck, and learn the pattern so it stops coming back.

4prompt heights
Open it in the interactive atlas →

The four heights

The same task, four distances: today's deadline, the next reviewer, the stuck moment, the pattern.

Execute — do the immediate task

+
We must stop reflected XSS on the comment widget before the production push. Sanitize…
We must stop reflected XSS on the comment widget before the production push. Sanitize user-submitted comment text so any angle brackets, script tags, and event-attribute syntax are escaped when rendered, and apply a strong Content-Security-Policy that disallows inline scripts. Verify by posting a comment containing <script>alert('xss')</script> and confirming it renders as text.

Improve — make it easier to accept

+
Before I send this XSS fix to security review, make approval obvious: show the original input and…
Before I send this XSS fix to security review, make approval obvious: show the original input and the escaped output side by side, summarize which characters we escape and which we allow (e.g., basic Markdown), highlight where we apply server-side escaping vs client-only, and call out any remaining places that still render raw HTML like admin previews.

Decide — diagnose the stuck moment

+
An admin reported that a stored comment containing an iframe rendered as active HTML on the admin…

An admin page rendered a saved comment as active HTML.

An admin reported that a stored comment containing an iframe rendered as active HTML on the admin preview page, but on the public site the same comment is escaped. I’m worried we missed server-side escaping on the admin route or that a legacy render path bypasses the sanitizer. I don’t know whether the unsafe output comes from stored HTML or a separate rendering pipeline. What tests and quick checks would confirm whether this is a rendering-path bug or bad storage, and what immediate change should I make to stop admin users seeing executable markup?

Become — change the pattern

+
Over multiple incidents we find XSS only in rare admin views and old templates: public pages are…

We keep finding XSS holes in admin and legacy pages.

Over multiple incidents we find XSS only in rare admin views and old templates: public pages are fine but legacy renderers bypass the sanitizer. We spend emergency cycles patching them as they appear. Which two consistent practices will prevent these regressions going forward — what to add to the template system or CI and what developer habit to enforce on review?

Next to this one

Other programming language work people do in JavaScript.

Every task here came from the work, not from a feature list — which is why the prompts name what you want done and never the button that does it. The tool changes; the work does not.
Copyright © LLOS.ai · 2026 — original pedagogy, voice, and design — all rights reserved.

The rest of the map

Same library, five ways in.