fix(security): prevent cross-vendor order status change via orders bulk-actions endpoint (IDOR)#3291
Open
MdAsifHossainNadim wants to merge 1 commit into
Open
fix(security): prevent cross-vendor order status change via orders bulk-actions endpoint (IDOR)#3291MdAsifHossainNadim wants to merge 1 commit into
MdAsifHossainNadim wants to merge 1 commit into
Conversation
…point (IDOR) The dokan/v2 (and inherited dokan/v3) orders bulk-actions REST endpoint changed order statuses from a vendor-supplied list of ids without verifying ownership, so any authenticated vendor could change another vendor's order statuses. Filter the submitted order ids to the requesting vendor's own orders before dispatching the status change; admins and shop managers (manage_woocommerce) are exempt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthrough
ChangesVendor-scoped bulk order status update
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
Fixes a cross-vendor IDOR on the vendor orders bulk-actions REST endpoint: any authenticated vendor could change the status of any other vendor's order.
What's the actual issue?
POST /wp-json/dokan/v2/orders/bulk-actions(and the inheriteddokan/v3route) is guarded only byupdate_order_permissions_check(), which checks the genericdokan_manage_ordercapability and the global "order status change" setting — it never verifies that the submitted order ids belong to the requesting vendor. The callback then forwards the raworder_idsstraight intodokan_apply_bulk_order_status_change(), which calls$order->update_status()on each id.So a vendor could send another vendor's order ids in the
order_idsarray and flip their statuses (e.g. mark a competitor's pending orders ascompleted/processing), bypassing the per-order ownership check that the single-order endpoints already enforce.How we fixed it —
includes/REST/OrderControllerV2.phpBefore dispatching the status change, drop any order the current vendor does not own. Admins / shop managers (
manage_woocommerce) are exempt and keep acting on every order, exactly like the single-order endpoints:This reuses Dokan's canonical ownership helper (
dokan_is_seller_has_order()), andOrderControllerV3inherits the method so thedokan/v3route is covered by the same change.How to test
completed.Test result: ✅ Verified on a live install. As a non-admin vendor: the vendor's own order changed status normally, while a foreign order (owned by another seller) stayed in its original status after the crafted request. Admins/shop managers remain unaffected.
Related Pull Request(s)
Closes
Changelog entry
Fix — Cross-vendor order status change via the orders bulk-actions REST endpoint
The vendor orders bulk-actions endpoint changed order statuses from a vendor-supplied list of ids without checking ownership, so a vendor could change another vendor's order statuses. Order ids are now filtered to the requesting vendor's own orders (admins and shop managers are exempt).