Remove duplicate check from wfe.FinalizeOrder (#7987)

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.
This commit is contained in:
Aaron Gable 2025-01-30 11:57:05 -08:00 committed by GitHub
parent d93f0c316a
commit 1ae184713b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -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) {
@ -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 {

View File

@ -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",