Skip to content

Conversation

@mikej
Copy link
Contributor

@mikej mikej commented Jan 21, 2026

Prompted by #2439 I've spotted a couple of other XSS vulnerabilities. This PR fixes some of them, in particular:

  • Vulnerability in AddressPresenter where e.g. address elements such as city etc. could contain <script> tags
  • Update handling of event/meeting descriptions where HTML is allowed (use sanitize rather than #html_safe)

Where there are existing tests in place I've updated these to cover the changes, but if no test coverage but it's just a straightforward replacement of #html_safe with sanitize I thought it was worth getting the fixes in place now as part of this.

mikej added 3 commits January 21, 2026 12:14
need to escape each of the individual elements of the address before
joining with <br /> tags and then marking as HTML-safe.

previously was vulnerable to malicious values in the address fields
(street, city etc.)
fix XSS vulnerabilities in meeting/event descriptions

replace `html_safe` with `sanitize` so HTML is still allowed
in descriptions but is limited to safe HTML.
by separating out the link_to rather than using string interpolation
on the whole paragraph we can avoid the need to use html_safe to
preserve the link tags.

the idea here is that by trying to limit use of `html_safe` to only
where it's strictly necessary it makes it easier to keep on top of
where it's being used and to spot other vulnerabilities in the future.
Copy link
Collaborator

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Can't make it anymore?
%p
= "Please #{link_to 'cancel your attendance', @cancellation_url} by following the instructions on the event page.".html_safe
Please #{link_to 'cancel your attendance', @cancellation_url} by following the instructions on the event page.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olleolleolle olleolleolle merged commit 8ee74e4 into codebar:master Jan 21, 2026
2 checks passed
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