Skip to content

Commit

Permalink
Remove duplicate check from wfe.FinalizeOrder (#7987)
Browse files Browse the repository at this point in the history
This check is duplicated in the next stanza. Instead, replace it with a
check that the acctID encoded in the URL and the acctID corresponding to
the JWS used to sign the request match.
  • Loading branch information
aarongable authored Jan 30, 2025
1 parent d93f0c3 commit 1ae1847
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions wfe2/wfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -2501,6 +2501,11 @@ func (wfe *WebFrontEndImpl) FinalizeOrder(ctx context.Context, logEvent *web.Req
return
}

if acct.ID != acctID {
wfe.sendError(response, logEvent, probs.Malformed("Mismatched account ID"), nil)
return
}

order, err := wfe.sa.GetOrder(ctx, &sapb.OrderRequest{Id: orderID})
if err != nil {
if errors.Is(err, berrors.NotFound) {
Expand All @@ -2517,11 +2522,6 @@ func (wfe *WebFrontEndImpl) FinalizeOrder(ctx context.Context, logEvent *web.Req
return
}

if order.RegistrationID != acctID {
wfe.sendError(response, logEvent, probs.NotFound(fmt.Sprintf("No order found for account ID %d", acctID)), nil)
return
}

// If the authenticated account ID doesn't match the order's registration ID
// pretend it doesn't exist and abort.
if acct.ID != order.RegistrationID {
Expand Down
2 changes: 1 addition & 1 deletion wfe2/wfe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2775,7 +2775,7 @@ func TestFinalizeOrder(t *testing.T) {
// stripped by the global WFE2 handler. We need the JWS URL to match the request
// URL so we fudge both such that the finalize-order prefix has been removed.
Request: signAndPost(signer, "2/1", "http://localhost/2/1", "{}"),
ExpectedBody: `{"type":"` + probs.ErrorNS + `malformed","detail":"No order found for account ID 2","status":404}`,
ExpectedBody: `{"type":"` + probs.ErrorNS + `malformed","detail":"Mismatched account ID","status":400}`,
},
{
Name: "Order ID is invalid",
Expand Down

0 comments on commit 1ae1847

Please sign in to comment.