Don't treat field_intro_text as HTML in benefits hub (landing_page)#1857
Open
Don't treat field_intro_text as HTML in benefits hub (landing_page)#1857
field_intro_text as HTML in benefits hub (landing_page)#1857Conversation
timcosgrove
approved these changes
Apr 24, 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.
Description
Renders Benefit Hub
field_intro_textas escaped plain text with line breaks from CMS, instead of HTML viadangerouslySetInnerHTML. Also fixes inconsistent application of mobile.va-introtextstyles as pointed out in the original ticket.Instead of evaluating the contents of
field_intro_textas HTML—which is dangerous because this field in particular was never sanitized on the backend—we're now treating the intro string as plain text except that we split on\r\nand join segments with<br />in React (nodangerouslySetInnerHTML). Angle brackets and legacy “HTML-looking” content stay literal and are not parsed or executed.Ticket
Relates to department-of-veterans-affairs/va.gov-cms#24029
Testing Steps
Go to https://va-gov-cms.ddev.site/family-and-caregiver-benefits and edit the intro text to include some script injection like
<script>window.alert('all your base are belong to us!')</script>. Publish it and visit http://localhost:3999/family-and-caregiver-benefits/. On the main branch you'll be vulnerable to that script injection. On this branch, the HTML will be escaped.QA steps
The other part of this ticket is making sure all intro text gets smaller on small screens. Shrink your window down to a mobile sized screen and see the font size change.
Screenshots
Before:
Script injection
After:
No script injection