Skip to content

Fix/security issues - #676

Closed
vipinkutthi-webkul wants to merge 6 commits into
unopim:3.xfrom
vipinkutthi-webkul:fix/security-issues
Closed

vipinkutthi-webkul wants to merge 6 commits into
unopim:3.xfrom
vipinkutthi-webkul:fix/security-issues

Conversation

@vipinkutthi-webkul

Copy link
Copy Markdown
Contributor

Description

  • Fixed an SSRF bypass in the Magic AI platform endpoints (store, update, testConnection): the extras.url field could override api_url at request time but was never checked against SafeWebhookUrl, letting an authenticated admin route outbound webhook calls to internal hosts or cloud metadata endpoints. extras.url is now validated the same way as api_url before create/update/test.
  • Added an ActiveContentScanner (packages/Webkul/Core/src/Rules/ActiveContentScanner.php) that detects embedded active content — JS/auto-actions in PDFs, <script>/inline event handlers/javascript: URIs in SVGs, and macros/auto-run objects in OOXML, legacy OLE, and RTF documents — and wired it into FileOrImageValidValue so it runs on save for every file/image attribute upload.
  • Added a media/scan endpoint (MediaController::scan + MediaScanRequest) that runs the same FileOrImageValidValue check at pick/drop time in the media widget (files, gallery, image components), giving admins immediate feedback before the file reaches save — this is a UX pre-check only, the save-time scan is the actual enforcement point.

How To Test This?

  1. Magic AI SSRF: go to Configuration > Magic AI, add/edit a platform, and submit a payload with extras.url pointing at an internal/link-local address (e.g. http://169.254.169.254/) — the request should be rejected with the unsafe-api-url validation message. Repeat via "Test Connection". Run vendor/bin/pest packages/Webkul/Admin/tests/Feature/MagicAI/MagicAIPlatformSecurityTest.php.
  2. Media upload scanning: on a file/image attribute, attempt to upload a PDF with an /OpenAction or /JavaScript entry, and an SVG containing <script> or an onload attribute — both should be rejected with the "active content detected" message, both when picked in the media widget (via the new media/scan AJAX call) and again if the check is bypassed and save is attempted directly. Run vendor/bin/pest packages/Webkul/Admin/tests/Feature/MediaScanTest.php and vendor/bin/pest packages/Webkul/Core/tests/Unit/FileOrImageValidValueSecurityTest.php.
  3. Confirm a clean, non-malicious file/image upload still succeeds through both the pick-time scan and save.

navneetkumar-pim-webkul added a commit that referenced this pull request Sep 10, 2026
… pick time

Supersedes #676 on top of #690. `MediaContent::activeContentReason()` now
covers .docx/.pptx (vbaProject.bin part), legacy .doc/.ppt (VBA stream) and
RTF (\objupdate, \objautlink) beside the existing PDF markers, using the
same head/tail windowed read so a large upload never lands in memory whole.
`FileOrImageValidValue` reports the reason in the validation message.

A new `admin.media.scan` endpoint runs the same rule on a file the moment
the media widget picks it; the three widgets share one `$scanMedia` helper
in app.js and only treat a 422 as a rejection, since form validation stays
the enforcement point.

Claude-Session: https://claude.ai/code/session_01JvM9wYbv339YvEnEuvsKrT
navneetkumar-pim-webkul added a commit that referenced this pull request Sep 10, 2026
* fix(core): scan Office and RTF uploads for macros, pre-check media at pick time

Supersedes #676 on top of #690. `MediaContent::activeContentReason()` now
covers .docx/.pptx (vbaProject.bin part), legacy .doc/.ppt (VBA stream) and
RTF (\objupdate, \objautlink) beside the existing PDF markers, using the
same head/tail windowed read so a large upload never lands in memory whole.
`FileOrImageValidValue` reports the reason in the validation message.

A new `admin.media.scan` endpoint runs the same rule on a file the moment
the media widget picks it; the three widgets share one `$scanMedia` helper
in app.js and only treat a 422 as a rejection, since form validation stays
the enforcement point.

Claude-Session: https://claude.ai/code/session_01JvM9wYbv339YvEnEuvsKrT

* fix(core): scan Office and RTF uploads for macros, pre-check media at pick time

Supersedes #676 on top of #690. `MediaContent::activeContentReason()` now
covers .docx/.pptx (vbaProject.bin part), legacy .doc/.ppt (VBA stream) and
RTF (\objupdate, \objautlink) beside the existing PDF markers, using the
same head/tail windowed read so a large upload never lands in memory whole.
`FileOrImageValidValue` reports the reason in the validation message.

A new `admin.media.scan` endpoint runs the same rule on a file the moment
the media widget picks it; the three widgets share one `$scanMedia` helper
in app.js and only treat a 422 as a rejection, since form validation stays
the enforcement point.

Claude-Session: https://claude.ai/code/session_01JvM9wYbv339YvEnEuvsKrT

* fix(admin): normalize media scan extensions (#694)
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.

2 participants