Skip to content

Strip potentially dangerous tags from SVG files - #12687

Merged
SchrodingersGat merged 2 commits into
inventree:masterfrom
SchrodingersGat:svg-fix
Aug 23, 2026
Merged

SchrodingersGat merged 2 commits into
inventree:masterfrom
SchrodingersGat:svg-fix

Conversation

@SchrodingersGat

Copy link
Copy Markdown
Member

No description provided.

@SchrodingersGat SchrodingersGat added this to the 1.6.0 milestone Aug 23, 2026
@SchrodingersGat SchrodingersGat added the security Relates to a security issue label Aug 23, 2026
@netlify

netlify Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit a5b5dd6
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a8a4d3005b5600008659d85
😎 Deploy Preview https://deploy-preview-12687--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98 (🟢 up 1 from production)
Accessibility: 81 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@SchrodingersGat
SchrodingersGat requested a lite review from Copilot August 23, 2026 01:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This pull request tightens SVG sanitization by removing SMIL animation elements from the allowed SVG tag/attribute allowlists, and adds a regression test to guard against a known “SMIL sets href to javascript: at render-time” bypass pattern.

Changes:

  • Remove SMIL animation-related SVG elements (e.g. set, animate*) from ALLOWED_ELEMENTS_SVG.
  • Remove a set of SMIL/animation-related attributes (e.g. to, from, values, attributeName) from ALLOWED_ATTRIBUTES_SVG.
  • Add a new unit test covering a SMIL-based javascript: smuggling technique.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/backend/InvenTree/InvenTree/sanitizer.py Tightens the SVG allowlist by excluding SMIL animation elements/attributes and documents the security rationale.
src/backend/InvenTree/InvenTree/tests.py Adds a regression test to ensure SMIL elements cannot smuggle javascript: URLs through SVG sanitization.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.80%. Comparing base (f063a6c) to head (2801193).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12687   +/-   ##
=======================================
  Coverage   86.79%   86.80%           
=======================================
  Files        1455     1455           
  Lines       97521    97520    -1     
  Branches    11402    11405    +3     
=======================================
+ Hits        84640    84648    +8     
+ Misses      12815    12806    -9     
  Partials       66       66           
Flag Coverage Δ
backend 90.86% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 92.24% <ø> (ø)
Backend General 93.74% <ø> (ø)
Frontend 79.65% <ø> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matmair matmair added backport Apply this label to a PR to enable auto-backport action backport-to-1.5.x labels Aug 23, 2026
@SchrodingersGat
SchrodingersGat merged commit f16fb36 into inventree:master Aug 23, 2026
44 checks passed
@SchrodingersGat
SchrodingersGat deleted the svg-fix branch August 23, 2026 08:50
@github-actions

Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
✅ 1.5.x

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

matmair pushed a commit that referenced this pull request Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Apply this label to a PR to enable auto-backport action backport-to-1.5.x security Relates to a security issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants