Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔒 Fixed SVG sanitization for staff profile pictures #21798

Merged
merged 3 commits into from
Dec 5, 2024

Conversation

sagzy
Copy link
Contributor

@sagzy sagzy commented Dec 4, 2024

closes https://linear.app/ghost/issue/ENG-1506

  • when uploading a SVG image as staff profile picture, we previously had a validation against malicious <script> tags or on* attributes
  • this has proven to be unsufficient, as malicious scripts can be added via other tags (e.g. <foreignObject>) and other attributes (e.g. xlink:href)
  • we now satinize SVGs using the DOMPurify library during validation
  • if the file is invalid and cannot be sanitized, we show an error to the user
  • also added support for sanitizing .svgz files

closes https://linear.app/ghost/issue/ENG-1506

- when uploading a SVG image as staff profile picture, we previously had a validation against malicious `<script>` tags or `on*` attributes
- this has proven to be unsufficient, as malicious scripts can be added via other tags (e.g. `<foreignObject>`) and other attributes (e.g. `xlink:href`)
- we now satinize SVGs using the DOMPurify library during validation
- if the file is invalid and cannot be sanitized, we show an error to the user
@sagzy sagzy force-pushed the fix/svg-upload-validation branch from a934694 to 1dbee84 Compare December 4, 2024 07:59
@sagzy sagzy merged commit a686d64 into main Dec 5, 2024
21 checks passed
@sagzy sagzy deleted the fix/svg-upload-validation branch December 5, 2024 09:36
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.

1 participant