Repository navigation
fix(example): HTML-escape interpolated values in the before/ migration app - #67
Merged
Merged
Conversation
…n app Co-Authored-By: Claude <noreply@anthropic.com>
cschetan77
approved these changes
Oct 8, 2026
Piyush-85
approved these changes
Oct 8, 2026
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
The
before/app in themigration-express-openid-connectexample interpolated user-controlled values straight into HTML sent withres.send(...), which servestext/html. This change wraps those values in anescapeHtml()helper so a value like a display name containing<script>is rendered as text instead of running in the visitor's browser.Why
The security review of the migration feature flagged reflected
XSSin the example apps. Theafter/app was already fixed in #63, but the siblingbefore/app was missed and still rendered claims unescaped. Example apps are copied into real projects, so the unsafe pattern should not ship even in a demo.Changes
escapeHtml()helper that escapes the five significant HTML characters (&,<,>,",'), ampersand first. It mirrors the helper already in theafter/app.user.name ?? user.sub)/(JSON.stringify(user, ...))/private(JSON.stringify(req.oidc.user, ...))Values that are not attacker-controlled are left as is, matching how #63 scoped the
after/fix: theexpiresAtISO date, theAUDIENCEoperator config, and theyes/notoken-presence flags.Testing
tsc --noEmiton thebefore/tsconfig passes.