[CHORE] Sanitize login page message #153

Closed
opened 2026-02-04 18:12:37 +03:00 by OVERLORD · 8 comments
Owner

Originally created by @jbaez on GitHub (Jul 24, 2022).

Protect agains XSS when rendering HTML from "untrusted sources".
Currently the HTML is injected through VITE_LOGIN_PAGE_MESSAGE env variable, although this might change.

Would need to sanitize the HTML before rendering either in the client or in the server (depends where the source of the login page message is)

Originally created by @jbaez on GitHub (Jul 24, 2022). Protect agains XSS when rendering HTML from "untrusted sources". Currently the HTML is injected through `VITE_LOGIN_PAGE_MESSAGE` env variable, although this might change. Would need to sanitize the HTML before rendering either in the client or in the server (depends where the source of the login page message is)
Author
Owner

@bo0tzz commented on GitHub (Jul 24, 2022):

If this is set by the server admin it can be considered trusted, right?

@bo0tzz commented on GitHub (Jul 24, 2022): If this is set by the server admin it can be considered trusted, right?
Author
Owner

@alextran1502 commented on GitHub (Jul 24, 2022):

If this is set by the server admin it can be considered trusted, right?

Yes, the concern here is that less technical admin who could be the target of social engineering attacks.

@alextran1502 commented on GitHub (Jul 24, 2022): > If this is set by the server admin it can be considered trusted, right? Yes, the concern here is that less technical admin who could be the target of social engineering attacks.
Author
Owner

@bo0tzz commented on GitHub (Jul 24, 2022):

There is a lot more surface area there that couldn't reasonably be covered - I don't think it's worth worrying about.

@bo0tzz commented on GitHub (Jul 24, 2022): There is a lot more surface area there that couldn't reasonably be covered - I don't think it's worth worrying about.
Author
Owner

@bo0tzz commented on GitHub (Aug 10, 2022):

Is this issue still applicable, or can it be closed?

@bo0tzz commented on GitHub (Aug 10, 2022): Is this issue still applicable, or can it be closed?
Author
Owner

@jbaez commented on GitHub (Aug 12, 2022):

I would consider rendering HTML unsafe unless it has been sanitized before, either in the server or the client.
I have implemented a "client sanitizer helper" long time ago, although it looks like there are libraries that do a better job and even a promising future native API https://developer.mozilla.org/en-US/docs/Web/API/HTML_Sanitizer_API 🙂

I think we should get this sanitized, as its a quick one to implement and it would remove any possibility of rendering malicious code from that env variable.

I have been busy lately and haven't had chance to work on Immich, but I could find some time to get this one done soon, if everybody is happy with that 😄

@jbaez commented on GitHub (Aug 12, 2022): I would consider rendering HTML unsafe unless it has been sanitized before, either in the server or the client. I have implemented a "client sanitizer helper" long time ago, although it looks like there are libraries that do a better job and even a promising future native API https://developer.mozilla.org/en-US/docs/Web/API/HTML_Sanitizer_API 🙂 I think we should get this sanitized, as its a quick one to implement and it would remove any possibility of rendering malicious code from that env variable. I have been busy lately and haven't had chance to work on Immich, but I could find some time to get this one done soon, if everybody is happy with that 😄
Author
Owner

@bo0tzz commented on GitHub (Aug 12, 2022):

Another reason I'm partial to not sanitizing is because now the admin has complete control over what is rendered. The demo instance currently just uses some italicized text, but I can imagine use cases for including things such as links or images (or even more).

@bo0tzz commented on GitHub (Aug 12, 2022): Another reason I'm partial to not sanitizing is because now the admin has complete control over what is rendered. The demo instance currently just uses some italicized text, but I can imagine use cases for including things such as links or images (or even more).
Author
Owner

@jbaez commented on GitHub (Aug 13, 2022):

Sanitizer libraries provide configuration for what things are allowed in the HTML. I think mainly what it shouldn't be allowed is JavaScript, either in <script> tags or in a tag as an event attribute.

Doing a quick search, looks like this library could be a good option: https://www.npmjs.com/package/xss.
This one also looks good: https://www.npmjs.com/package/dompurify

@jbaez commented on GitHub (Aug 13, 2022): Sanitizer libraries provide configuration for what things are allowed in the HTML. I think mainly what it shouldn't be allowed is JavaScript, either in `<script>` tags or in a tag as an event attribute. Doing a quick search, looks like this library could be a good option: https://www.npmjs.com/package/xss. This one also looks good: https://www.npmjs.com/package/dompurify
Author
Owner

@bo0tzz commented on GitHub (Aug 18, 2022):

After some discussion elsewhere, we've decided to close this issue and revisit the topic when we implement a server side MOTD.

@bo0tzz commented on GitHub (Aug 18, 2022): After some discussion elsewhere, we've decided to close this issue and revisit the topic when we implement a server side MOTD.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#153