Insight

Invoice Ninja Accepted Forged PayFast Payments and Shop Payment Flags

Invoice Ninja accepted an invalid PayFast notification when no passphrase was configured, while its optional shop API let public callers create invoices already marked paid.

Invoice Ninja Accepted Forged PayFast Payments and Shop Payment Flags

Invoice Ninja accepted a forged PayFast payment notification when the gateway had no passphrase configured. The notification carried a deliberately invalid signature, but the application created a completed payment and reduced the invoice balance to zero. No payment occurred at PayFast.

A second path existed in Invoice Ninja’s optional shop API. When the feature was enabled, its public company key was enough to create clients and invoices. The invoice creation request also reached internal actions such as paid=true and amount_paid. In our local tests, an unauthenticated caller created a new shop client, created an invoice for that client, and marked the invoice paid with a completed manual payment record. No gateway was involved.

We reproduced the PayFast behavior on official Invoice Ninja images for 5.13.43, 5.13.49, and 5.13.53. We reproduced the shop payment behavior on 5.13.43 and 5.13.49. The original shop routes were absent from 5.13.53.

All tests ran in local environments against records and gateway settings that we controlled. No money moved.

Where this started

During Fenko’s open-source research, we identified the payment paths. We traced the notification handler and shop controller through payment creation, then reproduced the changes using official Docker images.

PayFast verification failed open

PayFast sends an Instant Transaction Notification, or ITN, to tell a merchant application about a payment. Invoice Ninja exposes its payment notification route without a user session because PayFast has to reach it.

That design depends on the application authenticating the notification. In the tested versions, the decision in app/PaymentDrivers/PayFastPaymentDriver.php looked like this:

$passphrase = $this->company_gateway->getConfigField('passphrase') ?? '';

if (strlen($passphrase) > 0
    && ! $this->verifyItnSignature($data, $passphrase)) {
    return response()->json([
        'error' => 'Invalid Webhook Signature',
    ], 400);
}

if (array_key_exists('pf_payment_id', $data)
    && strlen($data['pf_payment_id']) > 1) {
    PaymentCompletedWebhook::dispatch(
        $data,
        $request->company_key,
        $this->company_gateway->id
    );

    return response()->json([], 200);
}

When a passphrase exists, Invoice Ninja verifies the signature. When it is empty, the whole check is skipped. The admin API allowed the gateway to be saved that way. The later job checked that the submitted amount matched the initiated payment, but the customer payment form already contained the payment identifier, notification URL, and exact amount needed for the transaction.

The result was an authentication failure at the payment boundary. An amount check can stop a caller from choosing an arbitrary balance, but it cannot prove that PayFast sent the notification or received funds.

What we reproduced with PayFast

For each tested version, we configured a PayFast gateway with an empty passphrase and created an invoice for 1000.43. We used the normal customer flow to initiate payment, which produced a valid application payment identifier and the expected amount.

From a fresh context with no cookie or API token, we sent a notification carrying a deliberately invalid signature and an invented PayFast transaction reference. A queue worker processed the notification. The resulting state was consistent across all three versions:

Before:
  invoice status = sent
  invoice balance = 1000.43

After:
  invoice status = paid
  invoice balance = 0
  payment status = completed
  transaction reference = attacker-supplied test value

No PayFast payment occurred, and the application made no server-to-server confirmation call.

We then set a passphrase through the normal admin API and repeated the test against a second invoice. The application returned HTTP 400 with Invalid Webhook Signature. The invoice stayed unpaid and no payment row appeared. This negative control ties the result to the conditional signature check.

Exploitation requires PayFast configured with an empty passphrase, a valid initiated-payment identifier and its matching amount, and a queue worker to process the notification. The normal customer payment form supplies the identifier and amount for that payment attempt.

The shop API passed privileged flags inward

Invoice Ninja 5.13.43 and 5.13.49 registered public shop routes under /api/v1:

Route::middleware('company_key_db', 'locale')
    ->prefix('api/v1')
    ->group(function () {
        Route::post('shop/clients', [Shop\ClientController::class, 'store']);
        Route::post('shop/invoices', [Shop\InvoiceController::class, 'store']);
        Route::get('shop/invoice/{invitation_key}', [Shop\InvoiceController::class, 'show']);
        // other read routes omitted
    });

The feature was disabled by default. When enabled, the middleware selected a company from X-API-COMPANY-KEY. That same company key appeared in the public client login page, so it could identify the company but could not serve as a private credential.

StoreShopInvoiceRequest::authorize() returned true. Its validation required a client belonging to the selected company, but it did not remove payment actions from the request. This abridged controller excerpt shows how the whole request reached invoice storage and triggeredActions:

public function store(StoreShopInvoiceRequest $request)
{
    $company = Company::where(
        'company_key',
        $request->header('X-API-COMPANY-KEY')
    )->first();

    if (! $company->enable_shop_api) {
        return response()->json(['message' => 'Shop is disabled'], 403);
    }

    $invoice = $this->invoice_repo->save(
        $request->all(),
        InvoiceFactory::create($company->id, $company->owner()->id)
    );

    $invoice = $invoice->service()->triggeredActions($request)->save();

    return $this->itemResponse($invoice);
}

TriggeredActions was written for trusted invoice workflows. It honored the payment flags directly:

if ($this->request->has('paid')
    && $this->request->input('paid') == 'true') {
    $this->invoice = $this->invoice->service()
        ->markPaid($this->request->input('reference'))
        ->save();
}

if ($this->request->has('amount_paid')
    && is_numeric($this->request->input('amount_paid'))) {
    $this->invoice = $this->invoice->service()
        ->applyPaymentAmount(
            $this->request->input('amount_paid'),
            $this->request->input('reference')
        )
        ->save();
}

The public shop endpoint was therefore calling an internal action service with caller-controlled administrative flags.

What we reproduced with the shop API

We enabled the shop API through the normal admin interface. In a context without a user session, we recovered the company key from the public portal page and used the intended shop route to create a new client. We then created invoices for that same shop-created client.

With paid=true, Invoice Ninja created an invoice for 4242.43 in paid state, set its balance to zero, and stored a completed manual payment. The payment had no company gateway and no gateway type.

With amount_paid=333.43, a second invoice for 333.43 also became paid and received another completed manual payment with the supplied reference.

Two controls behaved correctly. A wrong company key created no state, and disabling the shop API produced HTTP 403. This issue required the optional feature to be enabled.

Both payment examples used the client created through the public shop API. The caller created paid invoice records and completed manual payments without a gateway event or merchant approval.

The same request path accepted other administrative flags. On 5.13.43, send_email=true generated a new-invoice email to the shop-created contact. The caller could also change the company’s default invoice footer and terms, which apply to future invoices.

What changed in later releases

Invoice Ninja 5.13.53 no longer contained routes/shop.php, and its registered route list had no original shop controller routes. POST requests to the old client and invoice endpoints returned HTTP 404.

The changes between 5.13.50 and 5.13.51 removed the shop routes and their registration. This closes the payment-fabrication path described here.

The PayFast behavior remained reproducible on 5.13.53. Removing the shop API did not change the empty-passphrase signature condition.

VersionForged PayFast ITN with empty passphraseShop payment flags
5.13.43Accepted in our testAccepted when shop API was enabled
5.13.49Accepted in our testAccepted when shop API was enabled
5.13.53Accepted in our testOriginal routes absent

On November 12, the v5-stable branch pointed to the 5.13.49 revision, which still contained the shop routes. Operators should check their deployed version and route configuration.

What maintainers and operators should change

PayFast notifications should fail closed. Invoice Ninja should require a configured passphrase before enabling the gateway or accepting ITNs, verify every notification signature, and use PayFast’s supported server-side validation where applicable. Payment identifiers and matching amounts are transaction data, not proof of origin.

Shop integrations need a credential that is not present in a public page. Public invoice creation should accept only the fields needed to create an order. It should never pass paid, amount_paid, email actions, redirect settings, or company-default changes into a trusted internal action service.

Operators using PayFast should configure a strong passphrase now and confirm that forged or malformed ITNs receive a rejection. Operators on releases that still contain the shop routes should disable enable_shop_api unless they have a reviewed business need for it, then upgrade to a release where the original routes are absent.

Disclosure timeline

  • September 23, 2026: Reported the findings through Invoice Ninja’s published contact email address with a 45-day disclosure window.
  • November 7, 2026: The 45-day window ended. We had not received a reply.
  • November 12, 2026: Tested the latest release, Invoice Ninja 5.13.53, and the current v5-stable revision, 5.13.49. The PayFast issue remained present in 5.13.53. The original shop routes were absent from 5.13.53 but remained present in 5.13.49.
  • November 14, 2026: No vendor reply had been received as of publication.

We have not published the standalone reproduction scripts or full HTTP transcripts. Maintainers can contact Fenko for reproduction code and supporting evidence, or to coordinate a fix or advisory.