Skip to main content
Next Defence - Next-Gen AI Cyber Security Firm
Australia & New Zealand[email protected](02) 9064 2614
INSIGHT

An API Gateway Negative-Test Workbook for Ecommerce Teams

An ecommerce API gateway may authenticate a loyalty-service token successfully while failing to enforce what that token can do. A promotion engine that is supposed to read a narrow set of eligible discounts might.

Design negative tests around who owns the order

An ecommerce API gateway may authenticate a loyalty-service token successfully while failing to enforce what that token can do. A promotion engine that is supposed to read a narrow set of eligible discounts might instead retrieve another customer’s order, enumerate transaction identifiers or change a basket outside its intended business function. The gateway may still report successful authentication and a healthy service. This workbook concentrates on authorisation outcomes, rather than merely confirming that endpoints respond.

The example retailer has a customer application, checkout service, loyalty provider, campaign platform and a gateway in front of several order APIs. The gateway authenticates clients and applies common controls, but ownership checks may be implemented downstream by the order service. A sound assessment tests both layers; passing a gateway rule does not prove that tenant or customer boundaries are enforced within the application.

Use a staging environment with fictional customers, payment tokens that cannot settle money and isolated merchant accounts. Obtain written scope for every endpoint and test identity. Avoid querying real orders, enumerating unknown identifiers or generating traffic that could interfere with production shopping. The aim is to verify predictable denies and legitimate business flows—not to simulate an uncontrolled attack.

Map the principal, object and action

Build a matrix showing caller identity, authentication method, permitted API, permitted resource class, object owner and allowed operation. Typical identities include an end customer, a support agent, a loyalty integration, a warehouse service and a platform administrator. Record the difference between read order summary, read full delivery details, apply voucher, amend refund destination and export many orders. Each action carries a different business consequence.

Look beyond URLs. An endpoint such as GET /orders/{id} may support correct authorisation, while a bulk endpoint accepts arbitrary customer identifiers through filters or request bodies. A coupon application function may be exposed through an internal route that shares a public gateway deployment. Capture API versions and routes behind the gateway, including legacy endpoints and asynchronous jobs. The risk may sit in a queue consumer rather than the initial HTTP response.

For every rule, name the enforcing component. A gateway may check a signed token’s audience and scope; the order API should still establish that the caller is entitled to the specified record. A downstream event handler may need to validate tenant ownership again when processing a queued update. If the control depends on a header supplied by the caller, prove that the gateway removes or overwrites untrusted values before forwarding.

Construct a compact synthetic fixture

Create fictional customer A and customer B with orders that are similar except for ownership. Include a guest checkout, a refunded order, an abandoned basket and an archived order. Give the loyalty provider its own synthetic service identity and allow it only the data genuinely required for promotions. Add a separate internal support identity with narrowly defined privileges and a test account that has no orders at all.

Prepare an expected-results sheet for each principal/object pair. For example, customer A reads their order successfully but is denied customer B’s order; the promotion service receives eligibility fields but cannot read shipping address or payment metadata; a guest session cannot redeem a voucher more times than allowed; the support identity can view permitted summaries but not initiate a refund without a separate workflow. The worksheet should specify both the status-code expectation and what the server must not disclose in its body, logs or event stream.

Keep correlation IDs and an approved logging view so a reviewer can trace a single request through gateway, application and database audit events. Mask synthetic tokens in saved evidence anyway: a test environment that leaks credentials into team documents encourages unsafe habits in production.

Verify object-level and property-level controls

Start with a legitimate request for customer A’s order. Record the granted scopes and the application’s identified account. Then repeat the operation with the known synthetic identifier belonging to customer B, leaving all other inputs unchanged. The expected deny should be attributable to ownership checking, not to an accidentally malformed request. Run a comparable check through list, search, export and batch retrieval routes. Bulk endpoints need their own policy, because filtering often bypasses single-object checks.

Next test excessive data exposure. An endpoint might correctly deny another customer’s order but return fields the loyalty integration never needs on authorised orders. Compare actual JSON properties with the approved schema for that principal. Check whether filters such as include=details or nested expansions expose internal notes. The response should not include credentials, sensitive customer details or payment data beyond the use case. Client-side hiding is not an access control; the API must restrict what it sends.

Test write permissions separately. A token that can retrieve eligible promotions should not change delivery addresses, issue refunds, alter a price or update customer contact information. Use safe mock actions and negative outcomes in staging. Do not claim that a test passed because the UI lacks a button; call the authorised test route directly using the service identity to see what the server enforces.

Examine token handling and gateway assumptions

Confirm token issuer, audience, expiry and intended scope are checked at the enforcement point. Distinguish end-user tokens from machine-to-machine credentials, and ensure the latter are not implicitly granted all actions within the same tenant. Assess whether a gateway forwards a caller’s original identity accurately or substitutes an overly broad shared service account downstream. Where impersonation is legitimate, it should require a recorded purpose and an authorised path.

Inspect key rotation and the handling of expired or revoked credentials through normal configuration review. Test a known expired synthetic token and confirm it fails before the downstream business action. If an integration token remains valid long after a vendor contract ends, that lifecycle problem belongs in the risk register. Avoid treating IP allowlists as sufficient proof of caller identity; hosted integrations can share infrastructure and addresses.

Where the retailer uses multiple gateways or a direct internal endpoint, verify consistent policy. A protected public route does little if an internal service is accidentally published through another load balancer. Document the final network entry points and who owns the route catalogue.

Test business-flow abuse without generating harmful load

OWASP’s API security risk model includes object-level authorisation, object-property controls, unrestricted resource consumption and sensitive business-flow abuse. Translate those categories into the retailer’s business terms: coupon redemption, stock reservation, loyalty point transfer, refund initiation and account lookup. A valid customer may still be able to automate a business action at a harmful rate if controls are absent.

Use a small, pre-agreed number of staging requests to verify idempotency, transaction limits and rejection of duplicate event IDs. Test that a voucher already redeemed in the synthetic fixture cannot be applied again after a retry. Confirm that an order update with an older version identifier is either safely rejected or resolved by an explicit concurrency policy. These tests give better evidence than a high-volume load run that could affect a shared environment.

For rate limits, examine configuration, unit tests and controlled low-volume behaviour. Do not attempt to exhaust memory, payment provider quotas or messaging credits. Distinguish a configured threshold from a measured capacity guarantee; the latter requires a separate approved performance test.

Capture failures as reproducible product defects

A useful finding tells engineering precisely what failed: principal, token scopes, endpoint, synthetic object, expected deny, observed response, backend trace and affected release. Record business consequence separately from technical severity. A support token reading another fictional customer’s shipping address signals an access boundary failure even when no real data was exposed during the test. Do not include live customer records in a defect ticket.

Tie each finding to a product control owner and retest case. For object ownership, a fix may belong in the service’s authorisation layer; for header trust, it may require a gateway change; for leaked fields, it may require response projection and regression tests. Avoid a blanket recommendation to “add WAF rules” when the server lacks the necessary ownership model.

Release acceptance should show that negative cases fail safely and ordinary checkout still works. Re-run authorised customer journeys, loyalty fulfilment and refund controls after changes. If remediation blocks legitimate promotions, the release is not ready; if a workaround restores revenue by disabling authorisation, the security defect has returned.

Check feature flags and gradual release paths

Retail platforms commonly expose different API behaviour to pilot merchants, staff accounts or selected loyalty customers. A permission that works in a stable release can fail behind a newly enabled feature flag. Include the flag state and customer cohort in the test fixture. If the gateway directs trial users to a separate backend, confirm that the same ownership and field-level restrictions apply there. Feature rollout must not create an undocumented exception to the identity model.

Test a synthetic customer moving from trial to ordinary service and vice versa. Make sure old entitlements do not survive the cohort change, and compare the API responses when an authorised integration calls the same endpoint under both configurations. Where traffic is routed through a cached response or content delivery layer, verify that cached customer objects cannot be served to a different authenticated principal. A correct origin check cannot compensate for an incorrectly keyed shared cache.

The release manager should receive the negative-test summary alongside business conversion metrics. A successful sales campaign and a secure promotion API are both release conditions; neither establishes the other.

Keep the workbook alive with the API contract

Attach the test cases to the API definition and CI workflow. When an endpoint gains a new query parameter, role or field expansion, update the principal/object/action matrix. Sample results in production through authorised telemetry, but do not substitute production customer probing for automated nonproduction checks. Reconcile gateway route inventories with deployed service routes at each major release.

The final acceptance memo should identify the release tested, the synthetic data set, rule versions, failed and passed cases, residual exceptions, owners and the scope not assessed. A reviewer must be able to determine whether the loyalty integration truly receives only what it needs, regardless of whether the request enters through a well-configured gateway.

Sources and further reading

How Next Defence can help

Run negative API gateway tests for ecommerce objects in a controlled application security and DevSecOps review. Application owners should witness denied cross-customer requests and capture the backend authorisation decision, not just the gateway rule.

LET'S TALK

Let’s talk about your security.

Tell us what you are protecting, where you need greater visibility or what you want to achieve. We will help identify the right next step.

Talk to a Security Specialist

Describe your security requirements. Please do not submit passwords, credentials or confidential incident evidence. This form is not an emergency incident-response channel.

Form powered by HubSpot. Review our Privacy Policy. If the form doesn’t load, email [email protected].