Improve web-page templating sanitization. #188

Closed
opened 2025-10-16 05:54:42 -04:00 by rainbownapkin · 1 comment

Current EJS templates rely on input sanitization keep them safe. While we do trust the server to sanitize data before ingesting it, especially in cases in-which the data is saved to the DB, it would be safer to ensure we safely inject the data into the template no matter what.

We should replace uses of the <%- with the <%= tag where possible, un-escaping HTML entities before-hand to ensure sanitized data displays properly, as <%= expects unsafe data using validator.unescape(). This falls in-line with our method of injecting data on the client-side using JS, in which data is un-escaped with utils.ux.unescape() and injected safely using the node.innerText property.

Current EJS templates rely on input sanitization keep them safe. While we *do* trust the server to sanitize data before ingesting it, especially in cases in-which the data is saved to the DB, it would be safer to ensure we safely inject the data into the template no matter what. We should replace uses of the `<%-` with the `<%=` tag where possible, un-escaping HTML entities before-hand to ensure sanitized data displays properly, as `<%=` expects unsafe data using `validator.unescape()`. This falls in-line with our method of injecting data on the client-side using JS, in which data is un-escaped with `utils.ux.unescape()` and injected safely using the `node.innerText` property.
rainbownapkin added the
Cleanup/Refactor
Security Improvement
labels 2025-10-16 05:54:53 -04:00
rainbownapkin added this to the Canopy v0.4-Indev milestone 2025-10-16 05:54:57 -04:00
rainbownapkin added a new dependency 2025-10-16 05:55:17 -04:00
Author
Owner

Improved sanitization for server-side templating: 08fe051269

Improved sanitization for server-side templating: 08fe051269
rainbownapkin changed title from Improve web-page templating sanatization. to Improve web-page templating sanitization. 2025-11-04 06:12:00 -05:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#164 Tweaks and Fixes
rainbownapkin/canopy
Reference: rainbownapkin/canopy#188
No description provided.