Skip to content
Access control Write-up Intermediate

The Shipment You Shouldn’t Be Able to Touch

A missing authorization check in Solidus's shipment transfer endpoint allowed a user with limited permissions to move items into a shipment they were not allowed to manage. An attacker could cause items to be placed in another order's shipment, leading to incorrect fulfilment and inconsistent records.

ohyunwoods663 Follow

Published on medium.com

Bug Bounty

Ohyunwoods, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Solidus is an open-source e-commerce platform, and this bug lives in its API layer, in the shipment controllers. Shipments are the records that tie a set of items to a stock location and an order. The API exposes endpoints to update a shipment and to move items between shipments.

The second of those, transfer_to_shipment, takes two shipments: a source and a target. It moves items out of the source and into the target. That is the feature at the centre of this write-up.

The bug is a missing authorization check, tracked as GHSA-m8v9-2qv9-xrpj. I found it by reading the Solidus API controllers, tested it, and reported it privately to the maintainers, who fixed it quickly.

Setup

To make the bug concrete, the write-up uses a fictional user, Sam, who works at the East warehouse of an online store built on Solidus. The store admin gave Sam a narrow permission: manage shipments at East only. That permission is expressed as a CanCan ability rule:

Ruby
can :manage, Spree::Shipment, stock_location_id: user.stock_locations.pluck(:id)

This is a sensible, conditional rule: Sam can manage a shipment only if its stock location is one of Sam's own stock locations. The question the rest of the article answers is whether that rule holds everywhere it should.

The preconditions that matter for exploitation are set out later in the report: the attacker must already hold :manage on the source shipment and must know the target shipment number. Customers and anonymous users cannot trigger the bug, and stores running the default Solidus roles are not affected, because those roles already grant access to all shipments. Only stores with custom, conditional permissions like the one above are exposed.

Finding it

I noticed one endpoint that checked permission on the first shipment it received but looked up the second one with a plain find_by!. The asymmetry stood out: one identifier was authorised, the other was merely fetched. I tested it, it worked, and I reported it privately.

Exploitation

Step 1: Edit a West shipment (blocked)

First, the baseline. Sam tries to update a shipment at the West warehouse directly:

Text
Sam — PUT /api/shipments/WEST-B → Solidus
Sam ← — — — — 401 Unauthorized — — Solidus

The request is blocked with a 401 Unauthorized. The conditional rule works as intended when the shipment is the direct object of the request.

Step 2: Transfer items into it (allowed)

Next, Sam uses the transfer_to_shipment endpoint, which moves items from one shipment to another. Sam picks a source shipment at East, which Sam is allowed to manage, and a target shipment at West, which Sam is not allowed to manage:

Text
Sam — POST /transfer_to_shipment → Solidus
      source: EAST-A (Sam can manage)
      target: WEST-B (Sam cannot)
Sam ← — — — 202 Success — — — — — Solidus

The request succeeds with a 202. Order A's item is now sitting inside order B's shipment. The permission that blocked the direct update in step 1 did not stop the same user from pushing an item into a West shipment through the transfer endpoint.

Root cause

The controller treated its two shipment identifiers differently:

Text
Source shipment -> authorize! (checked)
Target shipment -> find_by! (never checked)

The controller verified that Sam could manage the source, then loaded the target with a plain lookup:

Ruby
@desired_shipment ||= Spree::Shipment.find_by!(number: params[:target_shipment_number])

There is no authorization on that lookup, and no check that both shipments belong to the same order. The item also keeps its original line item, so order B ends up holding something it never ordered:

Text
Before                          After
Order A: [Shirt]                Order A: []
Order B: [Mug]                  Order B: [Mug, Shirt]  <- no line item for Shirt

The existing defence, the CanCan rule on Spree::Shipment, was never consulted for the target shipment, so it could not stop the transfer. The source-side authorize! call gave the endpoint the appearance of being protected while leaving the second identifier unchecked.

Impact

The advisory rates this Moderate, CVSS 5.1. In practical terms, someone's shirt could ship to the wrong customer, and both orders end up with inconsistent records.

The limits are important:

  • No data is exposed.
  • Customers and anonymous users cannot trigger it.
  • The attacker must already have :manage on the source shipment and know the target shipment number.
  • Only stores with custom, conditional permissions are affected. Default Solidus roles already grant access to all shipments.

So this is a privilege-boundary bug between restricted staff roles, not an unauthenticated or cross-tenant data leak.

Fix

The patched versions look up the target inside the source order and authorise it:

Ruby
@desired_shipment = @original_shipment.order.shipments.find_by!(number: params[:target_shipment_number])
authorize! :update, @desired_shipment

With that change, the two failure modes are separated cleanly:

Text
Target on another order -> 404
Target Sam can't update -> 401

A target that does not belong to the source order is no longer found at all, and a target the caller cannot update is rejected by the authorisation check. If you cannot upgrade yet, the advisory includes a small initializer you can drop in as a workaround.

Upgrade solidus_api to 4.6.5, 4.7.3, or 4.8.1. If you only use the default permission sets, you are not affected.

Credit to the Solidus maintainers, especially jarednorman, for the quick triage and patch. The advisory is at https://github.com/solidusio/solidus/security/advisories/GHSA-m8v9-2qv9-xrpj.

Variants to test

Authorization bugs hide in endpoints that take two IDs. The first one gets checked because it is the obvious one; the second one slips through. When you review an endpoint, ask the same question for every ID in the request: who is allowed to touch this? Also, test with restricted roles, because admin accounts hide this kind of bug.

Concrete things to try on other targets:

  1. Every second identifier in a two-ID endpoint. Find endpoints that accept a source and a target (transfers, merges, moves, copies, links) and swap in an object you should not touch as the second ID. A positive result is a success status where the equivalent direct request on that object returns 401 or 403.
  2. Cross-parent references. Supply a target that belongs to a different parent (another order, tenant, project or account) than the source. A positive result is that the operation completes instead of returning 404.
  3. Lookup versus authorisation. Read the controller for each identifier and note whether it goes through authorize! or a bare find_by!/find. A positive result is a bare lookup whose result is then used in a write.
  4. Restricted-role testing. Reproduce the flow with a narrowly scoped role rather than an admin. A positive result is any state change outside the role's scope that an admin-only test would never reveal.
  5. Record consistency after the operation. Check whether the moved or linked object keeps a reference to its original parent (here, the line item stayed with the item). A positive result is a record that now holds something it never ordered or owned, with no matching line item.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 15 min read.

What happened, in plain words

A shop website built with a piece of software called Solidus had a small hole in its security. Solidus is an open-source e-commerce platform: a ready-made toolkit that people use to build online stores. It handles things like products, orders, warehouses and shipments.

A shipment, in this context, is the record that ties a set of items to a warehouse (a stock location) and to an order. When a customer buys something, the store creates an order, and the items that will actually be sent out are grouped into a shipment.

The hole was in the part of Solidus that other programs talk to, called the API. The API lets a program ask the store to do things, such as "update this shipment" or "move these items from one shipment to another". One of those requests, the one that moves items between shipments, checked whether the person sending it was allowed to touch the first shipment, but forgot to check the second one. That meant a warehouse worker with limited rights could push items into a shipment at a warehouse they were not supposed to touch.

The person who found it, Ohyunwoods, read the code, tested the idea, and reported it privately to the people who maintain Solidus. They fixed it quickly. The bug is tracked under the identifier GHSA-m8v9-2qv9-xrpj.

This article walks through the whole story slowly, explaining each idea as it comes up, so you can follow it even if you have never looked at security before.

Some background you need first

Before the details make sense, here are a few ideas in everyday terms.

What an API is. Think of a restaurant. You do not walk into the kitchen and cook; you tell the waiter what you want, and the waiter takes your order to the kitchen and brings back the result. An API (Application Programming Interface) is that waiter for software. One program sends a request to another program, and the second program does the work and sends back a reply. In this story, the "customer" is some other piece of software, and the "kitchen" is the Solidus store.

Requests and responses. A request is the message one program sends: it says what it wants done (the method, such as GET to read or POST to create or change something), which thing it wants (the path, such as /api/shipments/WEST-B), and sometimes extra details (the parameters, such as a shipment number). A response is the reply: a status code (a number that says whether it worked) plus any data. Common status codes you will see here:

  • 200 or 202: it worked. 202 means "accepted"; here it is the reply to the successful transfer.
  • 401 Unauthorized: you are not authenticated, usually because you are not logged in or your credentials were not accepted.
  • 403 Forbidden: you are logged in, but this particular action is not allowed for you.
  • 404 Not Found: the thing you asked for does not exist (or the server is pretending it does not exist, to avoid telling you anything).

What a permission is. In a shop, not every employee can do everything. A warehouse worker might be allowed to manage shipments at their own warehouse but not at another one. Software stores these rules as permissions. Solidus uses a library called CanCan to express them. A CanCan rule is a line of code that says who can do what to which records.

What authorization means. Authentication is proving who you are (logging in). Authorization is deciding what you are allowed to do once you are known. This bug is an authorization bug: the system knew who the user was, but failed to check what that user was allowed to touch.

What a vulnerability class is. Security problems are grouped into families that share a cause. This one belongs to the family called "missing authorization" (sometimes called broken access control): the code simply forgets to ask the permission question before doing something. Knowing the family helps you spot similar bugs elsewhere.

The setup: Sam and the East warehouse

To make the bug concrete, the write-up uses a fictional user, Sam, who works at the East warehouse of an online store built on Solidus. The store admin gave Sam a narrow permission: manage shipments at East only. That permission is written as a CanCan ability rule:

Ruby
can :manage, Spree::Shipment, stock_location_id: user.stock_locations.pluck(:id)

Line by line, in plain words:

  • can :manage says "this user is allowed to manage". Manage is a broad permission that covers viewing, changing and moving.
  • Spree::Shipment is the kind of record the permission applies to. Spree is the name of the older shop software that Solidus grew out of, so shipment records carry that name.
  • stock_location_id: user.stock_locations.pluck(:id) is the condition. It says the permission only applies when the shipment's warehouse (its stock location) is one of the warehouses that belong to this user. pluck(:id) is a database way of saying "give me just the ID numbers of my warehouses".

So the rule reads: Sam can manage a shipment only if that shipment sits at one of Sam's own warehouses. That is a sensible, conditional rule. The rest of the article asks one question: does that rule hold everywhere it should?

There are also conditions that must be true before anyone can abuse the bug, and they matter a lot:

  • The attacker must already have the manage permission on the source shipment.
  • The attacker must know the target shipment's number.
  • Customers and anonymous visitors cannot trigger it at all.
  • Stores that use Solidus's default roles are not affected, because those default roles already grant access to all shipments. Only stores that set up custom, conditional permissions like Sam's are exposed.

Finding it

Ohyunwoods found the bug by reading the Solidus API controllers. A controller is the part of the code that receives an incoming request and decides what to do with it, a bit like the waiter in the restaurant taking your order to the right station in the kitchen.

While reading, one endpoint stood out. An endpoint is a specific address in the API that does one job, such as "update a shipment" or "transfer items". This endpoint received two shipment identifiers: a source and a target. It checked permission on the first one, but looked up the second one with a plain find_by!.

find_by! is a database lookup: "find the record matching this condition, and raise an error if there is none". It fetches a record. It does not ask whether the person making the request is allowed to see or touch that record. The asymmetry stood out: one identifier was authorised, the other was merely fetched. Ohyunwoods tested it, it worked, and reported it privately to the maintainers.

Exploitation, step by step

Step 1: Edit a West shipment (blocked)

First, the baseline. Before trying anything clever, Sam tries the obvious thing: directly update a shipment at the West warehouse, which Sam is not allowed to manage.

Text
Sam — PUT /api/shipments/WEST-B → Solidus
Sam ← — — — — 401 Unauthorized — — Solidus

What this shows:

  • PUT is the request method used to update an existing record. Sam is saying "change shipment WEST-B".
  • /api/shipments/WEST-B is the path: the address of that particular shipment in the API.
  • The arrow to the right is the request going to Solidus; the arrow to the left is the reply coming back.
  • The reply is 401 Unauthorized. The request is blocked.

The conditional rule works as intended when the shipment is the direct object of the request. This step matters because it proves the permission is real: Sam genuinely cannot touch WEST-B the normal way. Any later success has to come from somewhere else.

Step 2: Transfer items into it (allowed)

Next, Sam uses a different endpoint, transfer_to_shipment, which moves items from one shipment to another. Sam picks a source shipment at East, which Sam is allowed to manage, and a target shipment at West, which Sam is not allowed to manage.

Text
Sam — POST /transfer_to_shipment → Solidus
      source: EAST-A (Sam can manage)
      target: WEST-B (Sam cannot)
Sam ← — — — 202 Success — — — — — Solidus

What this shows:

  • POST is the request method used to send data that creates or changes something. Here it asks Solidus to perform a transfer.
  • /transfer_to_shipment is the endpoint that does the moving.
  • source: EAST-A is the shipment the items come out of. Sam is allowed to manage it, so this half of the request is legitimate.
  • target: WEST-B is the shipment the items go into. Sam is not allowed to manage it, and this is the half the code forgot to check.
  • The reply is 202 Success. The request succeeds.

Order A's item is now sitting inside order B's shipment. The permission that blocked the direct update in step 1 did not stop the same user from pushing an item into a West shipment through the transfer endpoint. The rule was enforced on one door and not on the other.

What went wrong

The controller treated its two shipment identifiers differently:

Text
Source shipment -> authorize! (checked)
Target shipment -> find_by! (never checked)

In plain words: for the source, the code called authorize!, which is the permission check. authorize! asks the CanCan rules "is this user allowed to do this?" and stops the request if the answer is no. For the target, the code called find_by!, which only fetches the record. No permission question was asked about the target at all.

The controller verified that Sam could manage the source, then loaded the target with a plain lookup:

Ruby
@desired_shipment ||= Spree::Shipment.find_by!(number: params[:target_shipment_number])

Line by line:

  • @desired_shipment is a variable, a named box in the code that holds the target shipment once it is found.
  • ||= means "if this box is still empty, fill it with the result of the right-hand side".
  • Spree::Shipment.find_by! is the plain database lookup: find a shipment record.
  • number: params[:target_shipment_number] is the condition: match the shipment whose number equals the target number supplied in the request. params is the collection of values the caller sent along with the request.

There is no authorization on that lookup, and no check that both shipments belong to the same order. The item also keeps its original line item, so order B ends up holding something it never ordered:

Text
Before                          After
Order A: [Shirt]                Order A: []
Order B: [Mug]                  Order B: [Mug, Shirt]  <- no line item for Shirt

A line item is the record inside an order that says "this customer ordered this product". Before the transfer, order A has a shirt and order B has a mug. After the transfer, the shirt has physically moved into order B's shipment, but the shirt's line item still belongs to order A. Order B now contains a shirt it never ordered, and there is no line item explaining it. The records no longer agree with each other.

The existing defence, the CanCan rule on Spree::Shipment, was never consulted for the target shipment, so it could not stop the transfer. The source-side authorize! call gave the endpoint the appearance of being protected while leaving the second identifier unchecked. That is the heart of the bug: a check that looks like it covers the whole request but only covers half of it.

How bad is it?

The advisory rates this Moderate, with a CVSS score of 5.1. CVSS is a standard scoring system for security bugs: it turns things like how easy a bug is to use and how much damage it can do into a number, so people can compare bugs. 5.1 sits in the middle of the scale.

In practical terms, someone's shirt could ship to the wrong customer, and both orders end up with inconsistent records. The limits are important:

  • No data is exposed. The attacker cannot read anyone's private information through this.
  • Customers and anonymous users cannot trigger it. You need a staff account with the right starting permission.
  • The attacker must already have the manage permission on the source shipment and must know the target shipment number.
  • Only stores with custom, conditional permissions are affected. Default Solidus roles already grant access to all shipments.

So this is a privilege-boundary bug between restricted staff roles, not an unauthenticated or cross-tenant data leak. In other words, it is one employee with limited rights stepping slightly outside their lane, not a stranger walking in off the street.

The fix

The patched versions look up the target inside the source order and authorise it:

Ruby
@desired_shipment = @original_shipment.order.shipments.find_by!(number: params[:target_shipment_number])
authorize! :update, @desired_shipment

Line by line:

  • @original_shipment.order.shipments means "the shipments that belong to the same order as the source shipment". The lookup is now confined to that order, so a shipment from a different order can never be found this way.
  • .find_by!(number: params[:target_shipment_number]) still matches on the target number, but only within that confined set.
  • authorize! :update, @desired_shipment then asks the permission rules whether this user may update the target shipment, and stops the request if the answer is no.

With that change, the two failure modes are separated cleanly:

Text
Target on another order -> 404
Target Sam can't update -> 401

A target that does not belong to the source order is no longer found at all, so the reply is 404 Not Found. A target the caller cannot update is rejected by the authorisation check, so the reply is 401 Unauthorized. Each problem now produces its own clear answer instead of slipping through.

If you cannot upgrade yet, the advisory includes a small initializer you can drop in as a workaround. An initializer is a small file of code that a Solidus store loads at startup, so it can adjust behaviour without changing the main code.

Upgrade solidus_api to 4.6.5, 4.7.3, or 4.8.1. solidus_api is the part of Solidus that provides the API. If you only use the default permission sets, you are not affected.

Credit to the Solidus maintainers, especially jarednorman, for the quick triage and patch. Triage is the first pass where maintainers confirm a report is real and decide how serious it is. The advisory is at https://github.com/solidusio/solidus/security/advisories/GHSA-m8v9-2qv9-xrpj.

What to take from this

Authorization bugs hide in endpoints that take two IDs. The first one gets checked because it is the obvious one; the second one slips through. When you review an endpoint, ask the same question for every ID in the request: who is allowed to touch this? Also, test with restricted roles, because admin accounts hide this kind of bug. An admin can do everything, so an admin test never reveals a missing check.

Concrete things to try on other targets:

  1. Every second identifier in a two-ID endpoint. Find endpoints that accept a source and a target (transfers, merges, moves, copies, links) and swap in an object you should not touch as the second ID. A positive result is a success status where the equivalent direct request on that object returns 401 or 403.
  2. Cross-parent references. Supply a target that belongs to a different parent (another order, tenant, project or account) than the source. A positive result is that the operation completes instead of returning 404.
  3. Lookup versus authorisation. Read the controller for each identifier and note whether it goes through authorize! or a bare find_by!/find. A positive result is a bare lookup whose result is then used in a write.
  4. Restricted-role testing. Reproduce the flow with a narrowly scoped role rather than an admin. A positive result is any state change outside the role's scope that an admin-only test would never reveal.
  5. Record consistency after the operation. Check whether the moved or linked object keeps a reference to its original parent (here, the line item stayed with the item). A positive result is a record that now holds something it never ordered or owned, with no matching line item.

Glossary

  • API: the set of addresses and rules one program uses to ask another program to do things, like a waiter carrying orders between a customer and a kitchen.
  • Endpoint: one specific address in an API that performs one job, such as updating a shipment or transferring items.
  • Request: the message a program sends asking for something to be done, including the method, the path and any parameters.
  • Response: the reply a program sends back, including a status code and any data.
  • Status code: a number in a response saying how the request went, such as 202 for success, 401 for not allowed, 404 for not found.
  • Method: the kind of action a request asks for, such as GET to read, PUT to update, or POST to create or change something.
  • Parameter: an extra value sent along with a request, such as a shipment number.
  • Solidus: an open-source e-commerce platform, a ready-made toolkit for building online stores.
  • Spree: the older shop software that Solidus grew out of; its name still appears in record names like Spree::Shipment.
  • Shipment: the record that ties a set of items to a warehouse and an order.
  • Stock location: a warehouse or other place where stock is kept.
  • Order: the record of what a customer bought.
  • Line item: the record inside an order saying which product was ordered.
  • Controller: the part of the code that receives a request and decides what to do with it.
  • Authentication: proving who you are, usually by logging in.
  • Authorization: deciding what a known user is allowed to do.
  • Missing authorization: a security bug where the code forgets to check permission before acting; also called broken access control.
  • Permission: a rule saying what a user may do, such as managing shipments at one warehouse.
  • CanCan: a library Solidus uses to express permission rules in code.
  • Ability rule: a CanCan line of code saying who can do what to which records.
  • authorize!: the code call that asks the permission rules whether an action is allowed and stops the request if not.
  • find_by!: a plain database lookup that fetches a record matching a condition and raises an error if none exists; it does not check permission.
  • pluck(:id): a database call that returns just the ID numbers of a set of records.
  • Initializer: a small file of code a store loads at startup to adjust behaviour without changing the main code.
  • CVSS: a standard scoring system that turns a security bug's ease of use and impact into a number, so bugs can be compared.
  • Triage: the first pass where maintainers confirm a report is real and decide how serious it is.
  • Privilege boundary: the line between what one role is allowed to do and what another is; a bug that crosses it lets a limited user do a little more than intended.
  • Cross-tenant: involving two separate customers or accounts that should never see or affect each other's data.
  • Unauthenticated: done without logging in at all.
  • Workaround: a temporary fix you can apply when you cannot install the proper patch yet.
  • Patch: the corrected version of the code that closes the bug.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.