Chat d'équipe
Find a file
Andre Vasconcelos 13a0d63b3c
MM-67372: Improve link preview metadata handling and filtering (#35178)
* MM-67372: Filter SVG images from OpenGraph metadata to prevent DoS

This commit adds server-side filtering of SVG images from OpenGraph
metadata to mitigate a DoS vulnerability where malicious SVG images
in og:image tags can crash Chromium-based browsers and Safari.

Changes:
- Add IsSVGImageURL() helper function in model package to detect SVG URLs
- Filter SVG images in parseOpenGraphMetadata() for regular HTML pages
- Filter SVG images in parseOpenGraphFromOEmbed() for oEmbed responses
- Add defense-in-depth filtering in TruncateOpenGraph() and getImagesForPost()
- Add comprehensive tests for all SVG filtering functionality

SVG detection is based on:
- File extension (.svg, .svgz) - case-insensitive
- MIME type (image/svg+xml)

Reference: https://issues.chromium.org/issues/40057345

* MM-67372: Filter SVG images from cache/DB and direct SVG URLs

This commit addresses remaining attack vectors for the SVG DoS vulnerability:

1. Cache/DB filtering: Apply TruncateOpenGraph when returning OpenGraph
   from cache or database to filter stale data that was stored before
   the initial fix was deployed.

2. Direct SVG URLs: Filter PostImage entries with Format="svg" to prevent
   browser crashes when someone posts a direct link to an SVG file.

3. Embed creation: Skip creating image embeds for SVG images and create
   link embeds instead.

4. New SVG detection: Return nil instead of creating PostImage when
   fetching direct SVG URLs to prevent storing them in the database.

These changes ensure that even environments with pre-existing malicious
link metadata will be protected after a server restart.

* MM-67372: Fix test expectation for SVG image handling

* Removed duplicate logic in favor of already implemented FilterSVGImages in model

* Addressing PR comments

* Replacing exact match comparison with prefix check

* Added new test cases for unit tests
2026-02-09 16:26:14 +02:00
.github (fix): verified by label and playwright rerun on failed specs (#35161) 2026-02-05 08:48:29 +08:00
api [MM-66836] Integrate PropertyAccessService into API and app layers (#34818) 2026-02-06 18:06:51 -05:00
e2e-tests (chore): upgrade playwright and its dependencies (#35175) 2026-02-09 21:30:07 +08:00
server MM-67372: Improve link preview metadata handling and filtering (#35178) 2026-02-09 16:26:14 +02:00
tools Add support for make i18n-extract when dep folders are symlinked (#34385) 2025-11-04 16:18:24 +02:00
webapp [MM-66836] Add ability to delete orphaned protected fields from uninstalled plugins (#34867) 2026-02-06 20:45:27 -05:00
.editorconfig Move .editorconfig to repo root (#24398) 2023-08-30 16:29:07 -04:00
.gitignore Add optional Claude.md orchestration for Webapp folder (#34668) 2026-01-14 13:04:20 -05:00
.gitpod.yml Add .gitpod.yml to use mattermost-gitpod-config repo for Gitpod configuration (#19984) 2022-04-14 11:02:50 -04:00
.nvmrc MM-66972 Upgrade to node 24 and main dependencies with babel, webpack and jest (#34760) 2026-01-14 13:14:01 +08:00
CHANGELOG.md Changelog link (#8805) 2018-05-30 10:23:25 -04:00
CODEOWNERS MM-59271 Add DataLoader classes and batch loading missing users and statuses (#27804) 2024-08-06 15:39:10 -04:00
CONTRIBUTING.md update CONTRIBUTING.md and github ISSUE_TEMPLATE (#30862) 2025-04-29 15:42:40 +03:00
enable-claude-docs.sh Add optional Claude.md orchestration for Webapp folder (#34668) 2026-01-14 13:04:20 -05:00
LICENSE.enterprise Source available metrics (#24879) 2024-01-08 10:47:24 -04:00
LICENSE.txt Update LICENSE.txt to reflect new paths (#28241) 2024-10-01 09:47:09 -03:00
NOTICE.txt chore: Update NOTICE.txt file with updated dependencies (#35158) 2026-02-02 13:23:28 +02:00
README.md Update README first line to match new use cases (#31247) 2025-05-30 19:28:37 +00:00
SECURITY.md MM-41988 Updated links to legacy domain about.mm.com (#19552) 2022-03-16 19:47:57 +08:00

Mattermost logo

Mattermost is an open core, self-hosted collaboration platform that offers chat, workflow automation, voice calling, screen sharing, and AI integration. This repo is the primary source for core development on the Mattermost platform; it's written in Go and React, runs as a single Linux binary, and relies on PostgreSQL. A new compiled version is released under an MIT license every month on the 16th.

Deploy Mattermost on-premises, or try it for free in the cloud.

mattermost user interface

Learn more about the following use cases with Mattermost:

Other useful resources:

Table of contents

Install Mattermost

Other install guides:

Native mobile and desktop apps

In addition to the web interface, you can also download Mattermost clients for Android, iOS, Windows PC, macOS, and Linux.

Get Mattermost on Google Play Get Mattermost on the App Store Get Mattermost on Windows PC Get Mattermost on Mac OSX Get Mattermost on Linux

Get security bulletins

Receive notifications of critical security updates. The sophistication of online attackers is perpetually increasing. If you're deploying Mattermost it's highly recommended you subscribe to the Mattermost Security Bulletin mailing list for updates on critical security releases.

Subscribe here

Get involved

Learn more

License

See the LICENSE file for license rights and limitations.

Get the latest news

Contributing

Small Image

Please see CONTRIBUTING.md. Join the Mattermost Contributors server to join community discussions about contributions, development, and more.