For most SaaS products, the API is the product. The web app and mobile clients are thin layers over a REST or GraphQL backend that holds every tenant's data and enforces every permission. That makes the API the most valuable target in your estate, and the place where one missing check can expose every customer you have.
API penetration testing is how you find those missing checks before someone else does. This guide covers how a SaaS API pentest should be scoped, the methodology a competent team follows, the issues that show up again and again, and the remediation patterns that keep them from coming back. It is written for CTOs and security leads who are vetting a provider and want to know what good work looks like.
API penetration testing is manual, authenticated security testing of your application programming interfaces. A tester exercises every endpoint the way a motivated attacker would: as a real logged-in user, across multiple tenants and roles, checking whether the server actually enforces the access control and validation it claims to.
It is not a vulnerability scan. A scanner can flag a weak TLS configuration or a known-vulnerable library. It cannot reason about whether a read_only user in one tenant should be able to update a billing record in another. That reasoning is the core of API testing, and it is why the work has to be done by people.
The reference framework is the OWASP API Security Top 10 (2023 edition). Every finding in a good API report maps back to it:
Redfox Cybersecurity's API penetration testing service is built around this list, with every finding mapped to its category so your engineers and auditors read it the same way.
A web application test that only clicks through the UI misses most of the API. Modern frontends call a fraction of the endpoints the backend exposes, and they only call them with the parameters the UI happens to send. Attackers do not use your UI. They read your JavaScript bundles, your mobile app, and your public docs, then call the API directly with whatever parameters they like.
Three things make SaaS APIs especially exposed:
Scope is where an API test succeeds or fails. The goal is to give testers what a determined attacker would eventually have anyway: full documentation, working credentials for every role, and at least two tenants so cross-tenant access can be tested properly.
# api-scope.yaml
base_url: https://api.staging.acme.io/v2
schema: ./openapi-v2.json
graphql: https://api.staging.acme.io/graphql
auth:
flow: oauth2_authorization_code_pkce
access_token_ttl_min: 15
refresh_rotation: true
roles: [owner, admin, member, read_only, api_client]
tenants:
- id: tenant-alpha
accounts: {owner: o@alpha.test, member: m@alpha.test, read_only: r@alpha.test}
- id: tenant-bravo
accounts: {owner: o@bravo.test, member: m@bravo.test}
side_effects:
- POST /v2/payments # sandbox processor only
- POST /v2/invitations # outbound email, use test domain
constraints:
env: staging
max_rps: 5
[cta]
The number of endpoints, roles, and tenants drives effort more than anything else. Count REST operations (each path and method pair), GraphQL queries and mutations, webhook receivers, and any gRPC or internal APIs exposed through the gateway. If you are unsure how to size it, a free 30-minute scope review with Redfox Cybersecurity turns your schema into an effort estimate and a fixed quote.
Improper inventory management (API9) is one of the easiest categories to fix before testing begins. Compare what your specification documents against what your gateway actually serves:
# Paths documented in the OpenAPI spec
jq -r '.paths | keys[]' openapi-v2.json | sort -u > documented.txt
# Paths actually requested in the last 30 days (normalize numeric and UUID IDs)
zcat /var/log/gateway/access.log*.gz \
| awk '{print $7}' | cut -d'?' -f1 \
| sed -E 's#/[0-9a-f-]{36}#/{id}#g; s#/[0-9]+#/{id}#g' \
| sort -u > observed.txt
# Routes being served that nobody documented
comm -13 documented.txt observed.txt
[cta]
Every undocumented route either gets documented and added to scope or gets removed. Old /v1/ routes with a legacy authentication model are the most common result.
A strong API engagement follows the OWASP Web Security Testing Guide and API Security Top 10, aligned with PTES and NIST SP 800-115, in five broad phases.
Testers build a complete map of the API, including endpoints that appear in client code but not in documentation. They parse the schema to understand object relationships: which objects belong to a tenant, which belong to a user, and which identifiers are guessable. That map drives the authorization testing that follows. Sequential integer IDs, short slugs, and timestamps embedded in identifiers all get noted here, because predictable IDs turn a single authorization gap into a way to walk through every customer's records one request at a time.
This phase checks how identity is established and maintained: token expiry and revocation, refresh token rotation, multi-factor enforcement, password reset and invitation flows, and how the server validates tokens. The pattern that causes the most damage is trusting a value the client controls, such as a tenant ID inside an unverified token claim or a header.
The durable fix is strict verification on the server, with identity derived from the verified token rather than from anything the client sends alongside it:
import jwt
def verify(token: str, jwks_client) -> dict:
signing_key = jwks_client.get_signing_key_from_jwt(token).key
# Pin the algorithm, audience, and issuer. Require expiry.
return jwt.decode(
token, signing_key,
algorithms=["RS256"],
audience="api.acme.io",
issuer="https://auth.acme.io/",
options={"require": ["exp", "iat", "sub", "tid"]},
)
[cta]
This is the heart of the engagement. For every endpoint, testers ask whether a lower-privilege user, or a user in another tenant, can do something they should not. The method is to capture a legitimate request as a privileged user, replay it as an unprivileged or cross-tenant user, and observe whether the boundary holds.
# As a member of tenant-bravo, request a project owned by tenant-alpha
curl -s -o /dev/null -w '%{http_code}\n' \
-H "Authorization: Bearer $BRAVO_MEMBER_TOKEN" \
https://api.staging.acme.io/v2/projects/prj_41c9e2
# Only 403 or 404 is acceptable. A 200 is a critical finding.
[cta]
Authorization fails at three levels, and a good test checks all three:
role, plan, or tenant_id?The fix that scales is moving authorization out of scattered controller code into one policy that every request passes through. Open Policy Agent is a common choice:
package api.authz
import rego.v1
default allow := false
# Users may only act on resources in their own tenant
allow if {
input.resource.tenant_id == input.subject.tenant_id
some perm in data.role_permissions[input.subject.role]
perm == sprintf("%s:%s", [input.resource.type, input.action])
}
[cta]
For property-level issues, reject unknown fields outright instead of silently binding the request body onto your model:
from pydantic import BaseModel, ConfigDict
class ProfileUpdate(BaseModel):
model_config = ConfigDict(extra="forbid") # role, tenant_id, plan rejected
display_name: str | None = None
timezone: str | None = None
notification_prefs: dict | None = None
[cta]
Testers probe for SQL and NoSQL injection, command injection, unsafe deserialization, and server-side request forgery. Modern frameworks block the classic injection cases, so findings tend to appear in raw queries, dynamic filter builders, report exports, and search features.
SSRF (API7) deserves special attention in SaaS because so many features accept a URL: webhook destinations, avatar imports, integrations, and PDF renderers. If the server fetches that URL from inside your cloud network, it can reach metadata services and internal APIs. Validate the resolved address, not just the hostname:
import ipaddress, socket
from urllib.parse import urlparse
def is_safe_destination(url: str) -> bool:
parsed = urlparse(url)
if parsed.scheme != "https" or not parsed.hostname:
return False
for info in socket.getaddrinfo(parsed.hostname, 443):
ip = ipaddress.ip_address(info[4][0])
if ip.is_private or ip.is_loopback or ip.is_link_local or ip.is_reserved:
return False
return True
[cta]
Pair this check with an egress proxy that enforces the same rules at the network layer, so a DNS change between validation and request cannot get around it.
APIs without limits can be abused for denial of service or cost amplification, which hurts SaaS businesses that pay per downstream call. Testers check pagination caps, bulk endpoints, file upload sizes, and expensive queries. Business logic testing then looks at flows unique to your product: can a free trial be restarted indefinitely, can a discount be applied twice, can an invitation be accepted by the wrong account.
Rate limits on authentication and expensive endpoints are a baseline control:
limit_req_zone $binary_remote_addr zone=auth:10m rate=10r/m;
limit_req_zone $http_authorization zone=export:10m rate=2r/m;
location /v2/auth/ {
limit_req zone=auth burst=5 nodelay;
proxy_pass http://api_upstream;
}
location /v2/exports {
limit_req zone=export burst=1;
client_max_body_size 1m;
proxy_pass http://api_upstream;
}
[cta]
If your API exposes billing, exports, or integrations, these flows are where Redfox Cybersecurity's API testers spend a large share of their hours, because no scanner understands your pricing model.
Across SaaS API engagements, a short list of issues accounts for most of the critical and high findings:
role, plan, or is_verified on themselves./projects/{id} checks ownership, but /projects/{id}/members/{member_id} only checks the member ID./v1/ routes with an older, weaker auth model.The fix is to define exactly which fields each response returns, instead of serializing database objects wholesale:
class UserPublic(BaseModel):
id: str
display_name: str
avatar_url: str | None
# password_hash, mfa_secret, internal_notes, stripe_customer_id never leave the server
@app.get("/v2/users/{user_id}", response_model=UserPublic)
def get_user(user_id: str, ctx: Ctx = Depends(auth)):
return users.get_in_tenant(user_id, ctx.tenant_id)
[cta]
Inbound webhooks should be signed with a shared secret and checked with a constant-time comparison, with a timestamp to block replays:
import hmac, hashlib, time
def verify_webhook(body: bytes, sig_header: str, ts_header: str, secret: bytes) -> bool:
if abs(time.time() - int(ts_header)) > 300:
return False
expected = hmac.new(secret, f"{ts_header}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, sig_header)
[cta]
REST testing walks predictable URLs and HTTP methods. GraphQL collapses everything into one endpoint with a flexible query language, which changes the attack surface. A single query can traverse many object types, so authorization has to be enforced on every field resolver, not only at the top-level query. Testers also look at introspection exposure, query depth and cost, aliasing and batching behavior, and verbose error messages that leak schema details.
import depthLimit from "graphql-depth-limit";
import { createComplexityLimitRule } from "graphql-validation-complexity";
const server = new ApolloServer({
schema,
introspection: process.env.NODE_ENV !== "production",
validationRules: [depthLimit(7), createComplexityLimitRule(1000)],
formatError: (err) => ({ message: err.message }), // no stack traces to clients
});
[cta]
A pentest gives you a verified snapshot. Keeping it true requires turning findings into tests. The most valuable one is an authorization matrix that runs on every pull request and asserts which roles can call which endpoints:
import pytest
MATRIX = [
("GET", "/v2/projects/{alpha_project}", "alpha_member", 200),
("GET", "/v2/projects/{alpha_project}", "bravo_member", 404),
("DELETE", "/v2/projects/{alpha_project}", "alpha_read_only", 403),
("POST", "/v2/admin/export", "alpha_member", 403),
]
@pytest.mark.parametrize("method,path,actor,expected", MATRIX)
def test_authz_matrix(client, tokens, fixtures, method, path, actor, expected):
resp = client.request(method, path.format(**fixtures),
headers={"Authorization": f"Bearer {tokens[actor]}"})
assert resp.status_code == expected
[cta]
Every confirmed finding from a pentest becomes a new row. Over time, the matrix encodes your entire permission model and catches regressions long before the next test. For teams shipping new endpoints weekly, folding API testing into a continuous testing program adds human review whenever the matrix itself changes.
With Redfox Cybersecurity, a combined web application and API test starts at $4,000 with a five business day turnaround, covering one web app and one API with authenticated roles. Every engagement includes immediate notification of critical findings, an executive summary, a technical report, a readout call, and a free retest so you can confirm fixes landed. Final pricing depends on the number of endpoints, roles, and tenants, and you receive a fixed quote within 24 hours of scoping. Teams that want API, external, and cloud testing in a single audit-ready report can scope the custom audit bundle instead.
Your API enforces every security promise your product makes, so it deserves the closest scrutiny. A good API penetration test is manual, authenticated, multi-tenant, and mapped to the OWASP API Security Top 10. It finds the cross-tenant access, mass assignment, and function-level gaps that scanners miss, and it gives your engineers reproduction steps and fixes they can ship in a sprint. Turn each finding into a regression test, and the value of the engagement compounds long after the report is delivered.
If you are ready to put an experienced tester's eyes on your API, get a quote from Redfox Cybersecurity and start with a scope review that turns your schema and tenant model into a clear, fixed-price engagement.