Skip to content

Commit 9d4dda1

Browse files
Merge commit from fork
The adjustDraftOrderLine Admin API mutation was decorated with Permission.Owner in addition to Permission.UpdateOrder. Permission.Owner causes the AuthGuard to create an anonymous session and admit callers that hold none of the other required permissions, so an unauthenticated caller could adjust the line quantities of any draft order by supplying its id. Draft orders have no owning customer, so Owner grants no meaningful scoping here; every sibling draft-order mutation requires a concrete permission and none use Owner. Require Permission.UpdateOrder only, matching the other draft-order mutations, and add an e2e test asserting an anonymous caller is rejected. Relates to GHSA-hc75-2v4j-x372
1 parent 551d423 commit 9d4dda1

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

packages/core/e2e/draft-order.e2e-spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,23 @@ describe('Draft Orders resolver', () => {
168168
expect(adjustDraftOrderLine.lines[0].quantity).toBe(2);
169169
});
170170

171+
// GHSA-hc75-2v4j-x372 — adjustDraftOrderLine must reject unauthenticated callers
172+
it('adjustDraftOrderLine is not accessible to anonymous users', async () => {
173+
const firstLine = draftOrder.lines[0];
174+
if (!firstLine) throw new Error('Expected first line to exist');
175+
await adminClient.asAnonymousUser();
176+
await expect(
177+
adminClient.query(adjustDraftOrderLineDocument, {
178+
orderId: draftOrder.id,
179+
input: {
180+
orderLineId: firstLine.id,
181+
quantity: 99,
182+
},
183+
}),
184+
).rejects.toThrow('not currently authorized to perform this action');
185+
await adminClient.asSuperAdmin();
186+
});
187+
171188
it('removeDraftOrderLine', async () => {
172189
const firstLine = draftOrder.lines[0];
173190
if (!firstLine) throw new Error('Expected first line to exist');

packages/core/src/api/resolvers/admin/draft-order.resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class DraftOrderResolver {
9999

100100
@Transaction()
101101
@Mutation()
102-
@Allow(Permission.UpdateOrder, Permission.Owner)
102+
@Allow(Permission.UpdateOrder)
103103
async adjustDraftOrderLine(
104104
@Ctx() ctx: RequestContext,
105105
@Args() { orderId, input }: MutationAdjustDraftOrderLineArgs,

0 commit comments

Comments
 (0)