Skip to main content
Menu
Advisories

Admin users can update stock items at restricted stock locations

GHSA-HMF2-MW8G-C8QGPublished Updated GitHub

Description

A signed-in admin user with the role Spree::PermissionSets::RestrictedStockManagement for a subset of stock locations can update the count_on_hand and backorderable flag of stock items regardless of location by ID using the new admin.

Details

SolidusAdmin::ControllerHelpers::Authorization#authorize_solidus_admin_user! authorizes :admin and the action against the Spree::StockItem class, rather than individual instances, so the permission set's stock_location_id condition isn't evaluated. There is no record-level authorization. ResourcesController#set_resource loads the record with find(params[:id]) with no authorize!. StockItemsController#update saves the attributes and builds a stock movement. Note that solidus_backend is not affected.

Proof of concept

A user with the RestrictedStockManagement role assigned to stock location A visits /admin/stock_items/:id/edit for a stock item at stock location B. They then update the quantity and backorderable values. This should cause a 403 status and reject the user, but it does not, allowing the operation.

Impact

Users are able to affect the integrity of the system by updating stock item's at stock locations they were deliberately excluded from.

Workaround

If you are unable to upgrade to solidus_admin v0.5.1, put the following in an initializer:

Rails.application.config.to_prepare do
  SolidusAdmin::StockItemsController.before_action(only: %i[edit update]) do
    authorize! action_name.to_sym, @stock_item
  end
end

Credit

Ash Allen

Affected versions

References

GitHub · solidusio/solidus