API Security: The Complete Guide to Securing APIs for SOC 2, ISO 27001, PCI DSS, and HIPAA Compliance
APIs are now the primary attack surface for modern SaaS companies. Not the web application. Not the network perimeter. Not employee endpoints. APIs.
Gartner predicted that by 2025 API attacks would become the most frequent attack vector for enterprise web applications. That prediction arrived ahead of schedule. The 2025 Verizon Data Breach Investigations Report confirmed that API-related incidents accounted for a greater share of web application breaches than any other vector, and the trend has only accelerated. Salt Security's State of API Security Report found that 94% of organizations experienced an API security incident in production within the previous 12 months. The median company now exposes over 300 APIs, and most security teams cannot produce a complete inventory of them.
Compliance frameworks have responded. SOC 2 auditors now ask pointed questions about how APIs enforce authentication, authorization, and rate limiting. ISO 27001:2022 introduced specific controls for application security that map directly to API design decisions. PCI DSS 4.0 significantly expanded requirements for web-facing application security, including APIs that handle cardholder data. HIPAA enforcement actions increasingly reference unsecured APIs as the mechanism through which protected health information was exposed.
If your organization builds, consumes, or exposes APIs -- and virtually every SaaS company does -- API security is no longer an engineering concern you can delegate entirely to the development team. It is a compliance requirement with specific controls, evidence expectations, and audit implications.
This guide covers every dimension of API security that matters for compliance: the threat landscape, the specific framework requirements, the technical controls, and the evidence auditors expect to see.
What Is API Security?
API security is the discipline of protecting application programming interfaces from unauthorized access, data exposure, abuse, and exploitation throughout their entire lifecycle -- from design and development through deployment, operation, and deprecation.
An API (application programming interface) is a defined contract that allows one software system to communicate with another. REST APIs, GraphQL endpoints, gRPC services, webhooks, and WebSocket connections are all APIs. When your frontend calls your backend, that is an API call. When a customer integrates with your platform, they are using your API. When your application communicates with AWS, Stripe, Twilio, or any other third-party service, those are API calls. APIs are the connective tissue of modern software.
Why APIs Are the Number One Attack Surface for Modern SaaS
Three structural factors make APIs uniquely vulnerable:
1. APIs expose business logic directly. A traditional web application has a user interface that constrains what actions a user can take. An API has no such constraint. The API endpoint that processes a payment, retrieves a medical record, or modifies a user's permissions is directly accessible to anyone who knows the URL and can craft an HTTP request. The business logic layer is the attack surface.
2. APIs are designed for programmatic access. This is their purpose, but it also means attackers can automate exploitation at machine speed. A human attacker clicking through a web form is slow. An attacker scripting requests against an API endpoint can attempt thousands of operations per second -- brute-forcing authentication, enumerating resources, or exfiltrating data in bulk.
3. API sprawl outpaces security visibility. The average SaaS company's API surface area grows faster than the security team's ability to inventory and monitor it. Internal APIs, partner APIs, public APIs, shadow APIs (endpoints that exist but are not documented), and zombie APIs (deprecated endpoints that still respond) create an attack surface that most organizations cannot fully enumerate.
The consequence is that APIs combine maximum exposure with minimum visibility. This is why API security now sits at the center of compliance audits for any organization that builds or operates software.
The OWASP API Security Top 10 (2023)
The Open Worldwide Application Security Project (OWASP) published its API Security Top 10 specifically because traditional web application security frameworks did not adequately address API-specific risks. The 2023 edition reflects the current API threat landscape and serves as the de facto reference standard that auditors, penetration testers, and security teams use to evaluate API security posture.
Understanding each risk is essential for both security and compliance, because auditors increasingly reference the OWASP API Top 10 when evaluating API-related controls.
API1:2023 -- Broken Object Level Authorization (BOLA)
BOLA occurs when an API fails to verify that the requesting user is authorized to access the specific object they are requesting. An attacker changes an object identifier in a request -- for example, modifying /api/v1/accounts/1234 to /api/v1/accounts/1235 -- and the API returns the other user's data because it checks whether the user is authenticated but not whether they are authorized to access that specific account.
BOLA is the most prevalent API vulnerability. It is easy to exploit, difficult to detect with automated scanning alone, and often results in bulk data exposure.
Compliance impact: Directly violates SOC 2 CC6.1 (logical access controls), ISO 27001 A.8.3 (information access restriction), HIPAA access controls, and PCI DSS Requirement 7 (restrict access by business need-to-know).
API2:2023 -- Broken Authentication
Authentication vulnerabilities in APIs include weak token validation, missing authentication on sensitive endpoints, improper JWT implementation (accepting unsigned tokens, failing to validate the iss or aud claims), API keys transmitted without TLS, and credential stuffing attacks against login endpoints that lack rate limiting.
Compliance impact: Violates authentication requirements across all four major frameworks. SOC 2 CC6.1, ISO 27001 A.8.5 (secure authentication), HIPAA 164.312(d) (person or entity authentication), PCI DSS Requirement 8 (identify users and authenticate access).
API3:2023 -- Broken Object Property Level Authorization
This vulnerability occurs when an API allows users to read or modify object properties they should not have access to. For example, a user updates their profile and includes "role": "admin" in the request body, and the API blindly applies all submitted properties -- a pattern known as mass assignment. Alternatively, the API returns more data fields than the user should see (excessive data exposure).
Compliance impact: Violates least-privilege principles required by SOC 2 CC6.3, ISO 27001 A.8.3, and PCI DSS Requirement 7.
API4:2023 -- Unrestricted Resource Consumption
APIs that do not limit how many requests a client can make, how much data a single request can return, or how many concurrent operations a user can initiate are vulnerable to denial of service, resource exhaustion, and brute-force attacks. This includes missing rate limits, unbounded pagination, and endpoints that allow expensive queries without cost controls.
Compliance impact: Threatens system availability, which is a named Trust Services Criterion in SOC 2 (A1.2) and a key concern under ISO 27001 A.8.6 (capacity management).
API5:2023 -- Broken Function Level Authorization
This vulnerability exists when API endpoints fail to enforce proper function-level authorization. A regular user discovers an administrative endpoint (/api/admin/users) and can access it because the API only checks whether the user is authenticated, not whether they have the admin role. Horizontal privilege escalation (accessing another user's functions) and vertical privilege escalation (accessing admin functions) both fall under this category.
Compliance impact: Directly contradicts role-based access control requirements. SOC 2 CC6.1/CC6.3, ISO 27001 A.8.3/A.5.15, HIPAA 164.312(a)(1), PCI DSS Requirement 7.
API6:2023 -- Unrestricted Access to Sensitive Business Flows
Some API abuse does not require exploiting a technical vulnerability. Attackers abuse legitimate business flows -- purchasing limited-inventory items via automated scripts, creating fake accounts at scale, scraping competitive pricing data, or gaming referral programs. The API is functioning as designed; the problem is that no controls exist to detect or prevent automated abuse of business-critical flows.
Compliance impact: While not a direct violation of a single control, this risk surfaces in SOC 2 CC7.2 (monitoring for anomalous activity) and ISO 27001 A.8.16 (monitoring activities).
API7:2023 -- Server Side Request Forgery (SSRF)
SSRF vulnerabilities occur when an API accepts a URL or resource identifier from the user and fetches it server-side without validating or restricting the target. An attacker supplies an internal URL (http://169.254.169.254/latest/meta-data/) and the API server fetches it, potentially exposing cloud instance metadata, internal services, or credentials.
Compliance impact: SSRF can expose internal infrastructure and credentials, violating network segmentation and access control requirements across all frameworks.
API8:2023 -- Security Misconfiguration
This is a broad category covering missing security headers, verbose error messages that expose stack traces or internal details, unnecessary HTTP methods enabled (TRACE, OPTIONS revealing too much), default credentials on API management platforms, overly permissive CORS policies, and missing TLS enforcement.
Compliance impact: SOC 2 CC6.1 (configuration management), ISO 27001 A.8.9 (configuration management), PCI DSS Requirement 2 (apply secure configurations).
API9:2023 -- Improper Inventory Management
Organizations cannot secure what they do not know exists. This risk covers APIs that are not inventoried, documented, or monitored -- including older API versions still running in production, endpoints deployed directly by development teams without security review, and third-party API integrations that are not tracked.
Compliance impact: Asset management is a foundational control. ISO 27001 A.5.9 (inventory of information and other associated assets), SOC 2 CC3.1 (risk assessment), and PCI DSS Requirement 12.5.1 (maintain inventory of system components) all require organizations to know what they are protecting.
API10:2023 -- Unsafe Consumption of APIs
When your application consumes third-party APIs, those integrations introduce risk. If your application trusts data from a third-party API without validation, an attacker who compromises the third party (or who performs a man-in-the-middle attack) can inject malicious data into your system. This risk is particularly relevant for organizations with extensive partner integrations.
Compliance impact: Relates to third-party risk management requirements. SOC 2 CC9.2 (risk from business partners), ISO 27001 A.5.19-A.5.23 (supplier relationships), PCI DSS Requirement 12.8 (manage service providers).
Related: For vulnerability management across your entire stack, see our Vulnerability Management Program Guide.
Why Compliance Frameworks Care About API Security
API security is not a standalone compliance domain. It intersects with authentication, access control, data protection, monitoring, and change management -- which means API-related evidence surfaces in dozens of individual controls across every major framework. Here are the specific control references.
SOC 2 Trust Services Criteria
| Control | Description | API Security Relevance |
|---|---|---|
| CC6.1 | Logical access security software, infrastructure, and architectures | API authentication, authorization, and access controls |
| CC6.6 | Security measures against threats outside system boundaries | API gateway controls, input validation, WAF/API firewall |
| CC6.7 | Restricting transmission of data to authorized users | API encryption in transit, mTLS, token-based access |
| CC7.1 | Detect and monitor for vulnerabilities | API security testing, vulnerability scanning of APIs |
| CC7.2 | Monitor system components for anomalies | API monitoring, anomaly detection, abuse detection |
| CC8.1 | Authorize, design, develop, test, and implement changes | Secure API development lifecycle, change management for API deployments |
SOC 2 does not mention "APIs" by name -- it is principles-based. But every control above applies directly to APIs, and your auditor will evaluate API security within the scope of these criteria.
For a comprehensive overview, see our SOC 2 Compliance Guide.
ISO 27001:2022 Annex A Controls
| Control | Description | API Security Relevance |
|---|---|---|
| A.8.5 | Secure authentication | API authentication mechanisms (OAuth 2.0, JWT, mTLS) |
| A.8.9 | Configuration management | API gateway configuration, security header enforcement |
| A.8.25 | Secure development lifecycle | Secure API design, threat modeling, security testing |
| A.8.26 | Application security requirements | API security requirements defined before development begins |
| A.8.28 | Secure coding | Input validation, output encoding, injection prevention in APIs |
| A.8.29 | Security testing in development and acceptance | SAST, DAST, and API-specific security testing |
ISO 27001:2022 significantly strengthened application security controls, and APIs fall squarely within scope. Certification auditors will expect to see that API security requirements are defined (A.8.26), implemented through secure coding practices (A.8.28), and validated through testing (A.8.29).
For detailed ISO 27001 implementation guidance, see our ISO 27001 Certification Guide.
PCI DSS 4.0
| Requirement | Description | API Security Relevance |
|---|---|---|
| 6.2 | Bespoke and custom software is developed securely | Secure API design and development practices |
| 6.3 | Security vulnerabilities are identified and addressed | API vulnerability scanning, penetration testing of APIs |
| 6.4 | Public-facing web applications are protected against attacks | API gateway, WAF, rate limiting for payment-facing APIs |
| 6.5 | Changes to all system components are managed securely | API versioning, deployment controls, change management |
| 8.3 | Strong authentication for users and administrators | API authentication (multi-factor where applicable) |
| 8.6 | Use of application and system accounts is strictly managed | API key management, service account controls |
PCI DSS 4.0 raised the bar significantly for web-facing application security, and APIs that process, transmit, or store cardholder data are fully in scope. Requirement 6.4 now requires automated technical solutions for public-facing web applications (which includes APIs) that continuously detect and prevent web-based attacks.
For a deep dive, see our PCI DSS Compliance Guide.
HIPAA Security Rule
| Standard | Specification | API Security Relevance |
|---|---|---|
| 164.312(a)(1) | Access control | API authorization controls for endpoints serving ePHI |
| 164.312(c)(1) | Integrity | Input validation, data integrity checks on API requests/responses |
| 164.312(d) | Person or entity authentication | API authentication for systems accessing ePHI |
| 164.312(e)(1) | Transmission security | TLS/mTLS for APIs transmitting ePHI |
| 164.312(b) | Audit controls | API audit logging for all ePHI access |
Any API endpoint that touches electronic protected health information (ePHI) -- whether serving it, receiving it, or transmitting it -- is subject to the full weight of the HIPAA Security Rule. Healthcare SaaS companies with patient-facing APIs or provider integration APIs must treat API security as a HIPAA compliance requirement, not a best practice.
For healthcare-specific guidance, see our HIPAA Compliance Guide.
API Authentication and Authorization
Authentication (verifying identity) and authorization (verifying permissions) are the two most consequential API security controls. Every compliance framework requires both, and the majority of API breaches involve a failure in one or the other.
Authentication Mechanisms
OAuth 2.0 with OpenID Connect (OIDC) is the industry standard for API authentication in modern SaaS applications. OAuth 2.0 handles authorization (delegated access via access tokens), while OIDC adds an identity layer (ID tokens). Use the Authorization Code flow with PKCE for user-facing applications and the Client Credentials flow for machine-to-machine communication. Never use the Implicit flow -- it has been deprecated due to security weaknesses.
JSON Web Tokens (JWT) are the most common token format for API authentication. They are self-contained, enabling stateless verification without a database lookup for every request. However, JWT security depends entirely on correct implementation:
- Always validate the signature (reject unsigned tokens and tokens signed with
alg: none) - Validate the
iss(issuer) andaud(audience) claims - Enforce short expiration times (15-60 minutes for access tokens)
- Use asymmetric signing (RS256/ES256) instead of symmetric (HS256) for APIs consumed by external clients
- Never store sensitive data in JWT payloads -- they are base64-encoded, not encrypted
API keys are appropriate for identifying calling applications (not users) and for rate limiting. They are not authentication credentials in the compliance sense because they do not verify the identity of a person or entity. Treat API keys as application identifiers, not security tokens. Always transmit them in headers (not query strings, which end up in server logs and browser histories) and implement rotation capabilities.
Mutual TLS (mTLS) provides certificate-based authentication for machine-to-machine API communication. Both the client and server present certificates and validate each other's identity. mTLS is the strongest authentication mechanism for service-to-service communication and is increasingly expected by auditors for internal API traffic in high-security environments. It is particularly relevant for PCI DSS and HIPAA compliance.
Authorization: RBAC for APIs
Authentication tells you who is making the request. Authorization tells you what they are allowed to do. For API security, implement role-based access control (RBAC) or attribute-based access control (ABAC) at both the endpoint level and the object level.
Endpoint-level authorization: Each API endpoint should enforce role checks. An endpoint that retrieves financial reports should verify that the calling user has the finance:read permission, not just that they are authenticated.
Object-level authorization: Every request that accesses a specific resource must verify that the authenticated user is authorized to access that specific resource instance. This is the control that prevents BOLA (API1:2023). It is not enough to verify that a user has the accounts:read permission; you must verify that they have permission to read account ID 1234 specifically.
For a comprehensive treatment of access control models, see our Access Control Policy Guide.
API Input Validation and Injection Prevention
Every data element that enters your system through an API is untrusted input. API input validation is the control that prevents injection attacks, data corruption, and business logic abuse. Auditors evaluating ISO 27001 A.8.28 (secure coding) and PCI DSS 6.2 (secure development) will specifically look for evidence of input validation practices in your API layer.
Validation Strategy
Schema validation is the first line of defense. Define a strict schema for every API endpoint using OpenAPI (Swagger) specifications, JSON Schema, or Protocol Buffers. Reject any request that does not conform to the schema before it reaches application logic. This includes validating:
- Data types (string, integer, boolean, array)
- Required fields
- String length limits (minimum and maximum)
- Numeric ranges
- Allowed values (enumerations)
- Date/time formats
- Array size limits
- Nested object depth limits
Content-type validation. Reject requests that do not include a correct Content-Type header. An API endpoint that expects application/json should reject requests with text/xml or no content type. This prevents content-type confusion attacks.
Injection prevention. Parameterized queries and prepared statements prevent SQL injection. Output encoding prevents XSS when API responses are rendered in browsers. For APIs that accept file uploads, validate file types, enforce size limits, and scan for malware before processing.
Business logic validation. Schema validation catches malformed input. Business logic validation catches semantically invalid input -- a negative dollar amount, a date of birth in the future, a quantity of 999,999 when the business rule maximum is 100. These validations must be enforced server-side; never rely on client-side validation for security.
What Auditors Expect
Auditors do not evaluate your validation code line by line. They evaluate whether you have:
- A documented secure coding standard that includes input validation requirements
- Evidence that input validation is enforced (code reviews, SAST scan results)
- API security testing results showing that injection attempts are blocked
- A defined process for handling validation failures (reject and log, not accept and sanitize)
API Rate Limiting, Throttling, and Abuse Prevention
Rate limiting is an API security control that restricts how many requests a client can make within a defined time window. It prevents brute-force attacks, denial of service, data scraping, and automated abuse of business flows. It is directly relevant to SOC 2 availability criteria (A1.2), ISO 27001 A.8.6 (capacity management), and PCI DSS Requirement 6.4 (protect public-facing web applications).
Rate Limiting Strategies
Per-client rate limits restrict the total number of requests a specific API key, user, or IP address can make within a time window. Example: 1,000 requests per minute per API key. This prevents any single client from consuming disproportionate resources.
Per-endpoint rate limits apply different limits to different endpoints based on their sensitivity and cost. A search endpoint might allow 100 requests per minute, while a password reset endpoint should allow no more than 5 requests per 15 minutes.
Sliding window vs. fixed window. Fixed window rate limiting (reset every minute on the clock) creates burst vulnerabilities at window boundaries. Sliding window rate limiting distributes the limit more evenly. Use sliding windows for security-sensitive endpoints.
Graduated response. Rather than immediately blocking requests that exceed the limit, implement a graduated response: slow down responses (throttling), then return 429 Too Many Requests with a Retry-After header, then temporarily block the client if abuse continues.
Abuse Prevention Beyond Rate Limiting
Rate limiting stops volumetric abuse, but sophisticated attackers operate below rate limits. Additional controls include:
- Bot detection: Fingerprinting, behavioral analysis, and CAPTCHA challenges for endpoints vulnerable to automated abuse
- Anomaly detection: Baseline normal API usage patterns and alert on deviations (unusual endpoints, unusual data volumes, unusual geographic origin)
- Business flow protection: Implement controls specific to high-value business flows. A checkout API might require proof-of-work or enforce minimum time between cart creation and purchase completion
Evidence for Auditors
Rate limiting evidence includes: documented rate limiting policy, API gateway configuration showing rate limits per endpoint, monitoring dashboards showing rate limit enforcement (how many 429 responses were returned), and incident records where rate limiting prevented or mitigated an attack.
API Encryption: TLS, mTLS, and Payload Encryption
Encryption in transit is a non-negotiable API security requirement for every compliance framework. SOC 2 CC6.7, ISO 27001 A.8.24, HIPAA 164.312(e)(1), and PCI DSS Requirement 4 all require that sensitive data is encrypted during transmission.
TLS Configuration
All API traffic -- external and internal -- must use TLS 1.2 or higher. TLS 1.0 and 1.1 have been formally deprecated by RFC 8996, and no compliance framework considers them acceptable.
Configuration requirements:
- Minimum version: TLS 1.2; prefer TLS 1.3 where supported
- Cipher suites: Use only strong cipher suites. Disable CBC-mode ciphers (vulnerable to padding oracle attacks), RC4, 3DES, and export ciphers. Prefer AEAD ciphers (AES-GCM, ChaCha20-Poly1305)
- Certificate management: Use certificates from a trusted CA with a minimum 2048-bit RSA key or 256-bit ECC key. Implement automated certificate renewal (Let's Encrypt, AWS Certificate Manager, or equivalent) to prevent expiration-related outages
- HSTS: Enable HTTP Strict Transport Security with a minimum
max-ageof one year to prevent downgrade attacks
Mutual TLS (mTLS)
For service-to-service API communication -- particularly in microservices architectures -- mTLS provides bidirectional authentication in addition to encryption. Both the client and server present X.509 certificates and validate each other's identity before the TLS handshake completes. Service meshes (Istio, Linkerd) automate mTLS for internal traffic.
mTLS is particularly relevant for:
- APIs that handle PCI cardholder data between internal services
- Healthcare APIs transmitting ePHI between microservices
- Zero-trust architectures where network location is not a trust signal
Payload Encryption
TLS protects data in transit at the transport layer. Payload encryption (also called application-layer or message-level encryption) encrypts specific fields within the API request or response body. This provides defense-in-depth: even if TLS is terminated at a load balancer or API gateway, sensitive fields remain encrypted.
Consider payload encryption for: payment card numbers (PCI DSS), social security numbers, protected health information (HIPAA), and authentication credentials. JWE (JSON Web Encryption) and field-level encryption are common implementation patterns.
For a complete treatment of encryption requirements, see our Encryption at Rest and in Transit Compliance Guide.
API Logging, Monitoring, and Audit Trails
API logging is where security operations and compliance evidence converge. Every compliance framework requires audit trails that capture who accessed what, when, and from where. APIs are the primary mechanism through which data is accessed in modern systems, which makes API logs the most important source of audit evidence.
What to Log
For compliance purposes, every API request must generate a log entry containing:
| Data Element | Purpose | Framework Reference |
|---|---|---|
| Timestamp (UTC, ISO 8601) | Establishes when the event occurred | All frameworks |
| Request ID / Correlation ID | Enables tracing a request across services | SOC 2 CC7.2, ISO 27001 A.8.15 |
| Authenticated identity (user ID, service account) | Establishes who made the request | HIPAA 164.312(b), PCI DSS 10.2 |
| Source IP address | Enables geographic and network analysis | PCI DSS 10.2.1, SOC 2 CC7.2 |
| HTTP method and endpoint path | Establishes what action was attempted | All frameworks |
| Request parameters (redacted) | Context for the action; sensitive values must be masked | PCI DSS 10.2, ISO 27001 A.8.15 |
| Response status code | Establishes whether the action succeeded or failed | All frameworks |
| Response time | Performance monitoring, anomaly detection | SOC 2 A1.2 |
| Authorization decision (allowed/denied) | Access control audit trail | SOC 2 CC6.1, HIPAA 164.312(b) |
| Data classification of accessed resource | Context for sensitivity of the action | ISO 27001 A.5.12, HIPAA 164.312(b) |
What Not to Log
Never log the following in API logs:
- Passwords or authentication credentials
- Full credit card numbers (log only the last four digits per PCI DSS)
- Full social security numbers
- API keys or bearer tokens (log a hash or the last four characters)
- Protected health information beyond what is necessary for the audit trail
Logging sensitive data creates a new compliance exposure: your log storage becomes a target and falls within PCI DSS or HIPAA scope.
Log Integrity and Retention
Audit logs must be tamper-proof. Auditors will verify that:
- Logs are written to a centralized, append-only log store (not local files on application servers that developers can modify)
- Log retention meets framework requirements (SOC 2: typically one year; PCI DSS: one year with three months immediately available; HIPAA: six years for documentation)
- Access to log management systems is restricted and audited
- Log integrity is verifiable (checksums, immutable storage, or write-once-read-many configurations)
Monitoring and Alerting
Logging without monitoring is evidence collection without security value. Implement alerts for:
- Authentication failures exceeding a threshold (brute-force detection)
- Authorization failures (potential BOLA or privilege escalation attempts)
- Unusual API usage patterns (spike in requests, access to unusual endpoints, data exfiltration patterns)
- Requests from unexpected geographic locations or IP ranges
- API errors exceeding baseline rates (may indicate an ongoing attack or misconfiguration)
Related: For incident response procedures when API monitoring detects an incident, see our Incident Response Plan Guide.
API Security Testing: SAST, DAST, and Fuzzing
API security testing validates that the controls described in the preceding sections are actually implemented and effective. Every compliance framework requires security testing, and APIs must be included in the testing scope.
Static Application Security Testing (SAST)
SAST tools analyze source code without executing it. For API security, SAST identifies:
- Hardcoded credentials and API keys in source code
- SQL injection vulnerabilities (string concatenation in database queries)
- Missing authentication or authorization checks on API endpoints
- Insecure cryptographic implementations
- Insecure deserialization patterns
SAST should run on every pull request in your CI/CD pipeline. This makes it a preventive control: vulnerabilities are caught before they reach production.
Dynamic Application Security Testing (DAST)
DAST tools test running APIs by sending crafted requests and analyzing responses. For API security, DAST validates:
- Authentication bypass attempts (accessing endpoints without credentials)
- Authorization bypass (accessing resources belonging to other users)
- Injection attacks against live endpoints
- Security header presence and configuration
- TLS configuration and certificate validation
DAST runs against deployed APIs (typically in a staging environment that mirrors production). API-specific DAST tools that understand OpenAPI specifications are more effective than generic web application scanners for API testing.
API Fuzzing
Fuzzing sends randomized, malformed, and unexpected input to API endpoints to discover crashes, errors, memory leaks, and unhandled edge cases. API fuzzing is particularly effective at discovering:
- Input validation gaps (unexpected data types, boundary conditions)
- Business logic errors triggered by unusual input combinations
- Error handling weaknesses that expose internal details
Integration into CI/CD
For compliance purposes, security testing must be automated, repeatable, and documented. The most effective approach integrates testing directly into the CI/CD pipeline:
- Pre-merge: SAST and secrets scanning run on every pull request. Failures block the merge.
- Post-merge, pre-deploy: DAST runs against the staging environment after deployment. Critical findings block production promotion.
- Post-deploy: Continuous DAST or API monitoring validates production API security on an ongoing basis.
- Periodic: Full API penetration testing (manual, by qualified testers) at least annually or after significant API changes.
This approach produces the continuous testing evidence that SOC 2 CC7.1, ISO 27001 A.8.29, and PCI DSS 6.3 require. Each test run generates a timestamped report that becomes an audit artifact.
For CI/CD pipeline security implementation, see our DevSecOps Compliance Guide.
API Gateway Security: Centralized Policy Enforcement
An API gateway is a reverse proxy that sits between API consumers and backend services, providing a centralized enforcement point for security policies. In compliance terms, the API gateway is where many of the controls discussed in this guide are operationally enforced.
Core Security Functions
A properly configured API gateway enforces:
- Authentication: Validate tokens (JWT verification, OAuth 2.0 introspection) at the gateway rather than in each individual microservice. This ensures consistent authentication enforcement across all endpoints and reduces the risk that a single service implements authentication incorrectly.
- Authorization: Enforce coarse-grained authorization (role checks, scope validation) at the gateway. Fine-grained, object-level authorization remains the responsibility of individual services.
- Rate limiting: Apply per-client and per-endpoint rate limits centrally.
- Input validation: Enforce schema validation (request size limits, content-type checks, JSON schema validation) before requests reach backend services.
- TLS termination: Handle TLS termination and optionally re-encrypt traffic to backend services (TLS bridging) or enforce mTLS between the gateway and internal services.
- Request/response transformation: Strip sensitive headers, redact sensitive response fields for lower-privilege clients, and enforce consistent error response formats that do not leak internal details.
- Logging: Generate consistent, structured access logs for every API request.
API Gateway as a Compliance Control Point
From an audit perspective, the API gateway provides a single location where auditors can verify that security policies are configured and enforced. Rather than auditing authentication logic in 50 individual microservices, the auditor examines the gateway configuration. This centralization dramatically simplifies compliance evidence collection.
Common API gateway platforms include Kong, Apigee (Google), AWS API Gateway, Azure API Management, and open-source options like Tyk and KrakenD. The choice of platform matters less than the configuration. An API gateway with default settings provides minimal security. A properly configured gateway with authentication, rate limiting, schema validation, and logging enforced for every route is a significant compliance asset.
What Auditors Expect
Auditors evaluating API gateway controls will look for:
- Gateway configuration documentation showing which policies are applied to which API routes
- Evidence that the gateway is the only path to backend APIs (direct access is blocked by network controls)
- Logs showing the gateway is actively enforcing policies (rejected requests, rate-limited requests)
- Change management records for gateway configuration changes
Related: For network-level controls that complement API gateway security, see our Network Segmentation Compliance Guide.
API Versioning and Deprecation: Security Implications
API versioning is typically discussed as an engineering concern -- backward compatibility, developer experience, migration paths. But it has direct security and compliance implications that most organizations overlook.
The Zombie API Problem
When a new version of an API is deployed, the old version often remains running. Sometimes this is intentional (to support clients who have not migrated). Sometimes it is accidental (no one remembered to decommission it). These "zombie APIs" are a significant security risk because:
- They may lack security controls that were added in newer versions
- They may not be included in current monitoring and alerting
- They may not receive security patches
- They may not be included in penetration testing scope
The OWASP API Top 10 lists Improper Inventory Management (API9:2023) as a top risk specifically because of this pattern. Auditors evaluating asset management controls (ISO 27001 A.5.9, SOC 2 CC3.1) will check whether your API inventory is complete and whether deprecated versions have been properly decommissioned.
Versioning Strategy for Security
A security-aware versioning strategy includes:
- API inventory: Maintain a complete inventory of all API versions currently deployed, including the environments they run in and the clients that consume them.
- Deprecation policy: Define maximum lifespans for deprecated API versions. A common approach: announce deprecation at least 6 months before end-of-life, disable new client registrations immediately, and decommission the version on a published date.
- Security parity: Until a deprecated version is decommissioned, it must receive security patches. A deprecated API version with a known vulnerability is an audit finding.
- Monitoring continuity: Deprecated API versions must remain in scope for logging, monitoring, and alerting until they are fully decommissioned.
- Client migration tracking: Track which clients are still using deprecated versions and actively manage their migration. Auditors may ask for evidence that you are managing the deprecation lifecycle, not just announcing it.
API Security Checklist for Compliance
This checklist consolidates the controls discussed throughout this guide into a single reference. It is organized by security domain and mapped to the compliance frameworks that require each control.
Authentication
- All API endpoints require authentication (no unauthenticated access to data or business logic)
- OAuth 2.0 with PKCE is used for user-facing API authentication
- Client Credentials flow is used for machine-to-machine authentication
- JWT tokens are validated completely (signature, issuer, audience, expiration)
- Access tokens have short expiration times (15-60 minutes)
- API keys are transmitted in headers, never in query strings or URLs
- API keys are rotatable and have defined expiration policies
- mTLS is implemented for service-to-service communication in high-security contexts
- Frameworks: SOC 2 CC6.1, ISO 27001 A.8.5, HIPAA 164.312(d), PCI DSS 8.3
Authorization
- Object-level authorization is enforced on every endpoint that accesses a specific resource
- Function-level authorization prevents horizontal and vertical privilege escalation
- RBAC or ABAC is implemented with least-privilege principles
- Mass assignment is prevented through explicit allowlisting of modifiable properties
- Admin API endpoints are separated and protected with additional controls
- Frameworks: SOC 2 CC6.1/CC6.3, ISO 27001 A.8.3/A.5.15, HIPAA 164.312(a)(1), PCI DSS 7
Input Validation
- Schema validation is enforced on all API endpoints (data types, lengths, formats)
- Content-Type header validation rejects unexpected content types
- Parameterized queries prevent SQL injection
- Output encoding prevents XSS in API responses rendered by browsers
- File uploads are validated for type, size, and content
- Request body size limits are enforced
- Frameworks: ISO 27001 A.8.28, PCI DSS 6.2, SOC 2 CC6.6
Rate Limiting and Abuse Prevention
- Per-client rate limits are enforced on all endpoints
- Sensitive endpoints (authentication, password reset) have stricter rate limits
- 429 responses include Retry-After headers
- Anomalous usage patterns trigger alerts
- Bot detection is implemented for endpoints vulnerable to automated abuse
- Frameworks: SOC 2 A1.2, ISO 27001 A.8.6, PCI DSS 6.4
Encryption
- All API traffic uses TLS 1.2 or higher
- Strong cipher suites only; weak ciphers are disabled
- HSTS is enabled for public-facing APIs
- mTLS is implemented for internal service-to-service APIs (where applicable)
- Sensitive fields use payload encryption in addition to TLS
- Certificates are managed with automated renewal
- Frameworks: SOC 2 CC6.7, ISO 27001 A.8.24, HIPAA 164.312(e)(1), PCI DSS 4
Logging and Monitoring
- Every API request generates a structured log entry
- Logs include identity, action, timestamp, source, and outcome
- Sensitive data is redacted from logs (passwords, tokens, card numbers, PHI)
- Logs are stored in a centralized, tamper-proof log management system
- Log retention meets framework requirements (minimum one year)
- Alerts are configured for authentication failures, authorization failures, and anomalies
- Log access is restricted and audited
- Frameworks: SOC 2 CC7.2, ISO 27001 A.8.15/A.8.16, HIPAA 164.312(b), PCI DSS 10
Security Testing
- SAST runs on every pull request and blocks merges on critical findings
- DAST or API-specific security scanning runs regularly against deployed APIs
- API fuzzing is performed periodically
- API penetration testing is conducted at least annually by qualified testers
- Testing results are documented and remediation is tracked
- Frameworks: ISO 27001 A.8.29, PCI DSS 6.3, SOC 2 CC7.1
API Inventory and Lifecycle
- A complete inventory of all APIs (internal, external, partner) is maintained
- Deprecated API versions have a defined end-of-life date
- Deprecated versions receive security patches until decommissioned
- Decommissioned APIs are confirmed non-functional (not just undocumented)
- OpenAPI specifications are maintained for all active APIs
- Frameworks: ISO 27001 A.5.9, SOC 2 CC3.1, PCI DSS 12.5.1
API Gateway
- All external API traffic routes through an API gateway
- The gateway enforces authentication, rate limiting, and schema validation
- Direct access to backend services is blocked by network controls
- Gateway configuration changes follow change management procedures
- Gateway logs are integrated with centralized log management
- Frameworks: SOC 2 CC6.6, ISO 27001 A.8.9, PCI DSS 6.4
Frequently Asked Questions
What is the difference between API security and web application security?
Web application security and API security overlap, but they are not the same. Traditional web application security focuses on browser-based threats: XSS, CSRF, clickjacking, session hijacking, and other attacks that exploit the browser as a client. API security focuses on programmatic access: broken authorization at the object and function level, authentication token management, rate limiting, input validation without a UI layer, and the challenges of machine-to-machine communication. APIs lack the inherent constraints of a browser-rendered interface, which means they require a different security model. OWASP maintains separate Top 10 lists for web applications and APIs precisely because the threat profiles are distinct.
Which compliance framework has the strictest API security requirements?
PCI DSS 4.0 has the most prescriptive requirements for APIs that handle cardholder data. It mandates specific technical controls (automated web application protection, vulnerability scanning, penetration testing, secure development training) with defined frequencies and evidence requirements. ISO 27001:2022 is the most comprehensive in scope, covering API security within a broader information security management system. SOC 2 provides the most flexibility because it is principles-based, but that flexibility means your auditor has wide latitude to determine what "sufficient" API security looks like. HIPAA is the least prescriptive technically but carries the highest penalties for breaches involving protected health information exposed through API vulnerabilities.
Do internal APIs need the same security controls as public APIs?
Yes, with adjustments. The zero-trust security model holds that network location is not a trust signal. An internal API that serves sensitive data should enforce authentication (mTLS for service-to-service, or token-based for internal applications), authorization, logging, and encryption in transit. The difference is typically in the authentication mechanism (mTLS or service mesh identity rather than OAuth 2.0) and the rate limiting strategy (internal rate limits may be higher). From a compliance perspective, auditors will check that internal APIs handling sensitive data are not relying solely on network perimeter controls for security.
How do we handle API key management for compliance?
API key management for compliance requires: a centralized system for issuing, tracking, and revoking API keys; defined expiration policies (keys should not be perpetual); automated rotation capabilities; storage of keys in a secrets manager (never in source code, environment variables visible to unauthorized users, or configuration files in version control); auditing of key creation, usage, and revocation events; and an immediate revocation process for compromised keys. PCI DSS 8.6 specifically requires that application and system accounts (including API service accounts) are managed with the same rigor as interactive user accounts.
What should we do when we discover an API vulnerability in production?
Follow your incident response plan. Specifically: assess the severity and determine whether the vulnerability has been exploited (check API logs for indicators of compromise); contain the exposure (this may mean temporarily disabling the vulnerable endpoint, deploying a rate limit, or adding a WAF rule); remediate the vulnerability through a patch deployed through your standard change management process (or an expedited emergency change process if the severity warrants it); verify the fix through testing; and document the entire timeline. For compliance purposes, the documentation matters as much as the fix. Auditors will want to see that you detected the vulnerability, responded within your defined SLAs, and produced a root cause analysis to prevent recurrence.
How often should APIs be penetration tested?
At minimum, annually. PCI DSS requires penetration testing at least once every 12 months and after any significant infrastructure or application changes. ISO 27001 A.8.29 requires security testing in development and acceptance, which should include API-specific penetration testing. SOC 2 does not prescribe a frequency, but annual penetration testing has become a de facto expectation among SOC 2 auditors. Beyond the annual cadence, API penetration testing should be triggered by significant changes: new API endpoints, new authentication mechanisms, major architectural changes, or the addition of endpoints that handle new categories of sensitive data.
Can an API gateway replace application-level security controls?
No. An API gateway is a critical security layer, but it cannot replace application-level controls. The gateway handles coarse-grained enforcement: authentication token validation, rate limiting, schema validation, TLS termination, and request routing. It cannot enforce object-level authorization (verifying that user A is authorized to access resource 1234), business logic validation (verifying that a transfer amount does not exceed the account balance), or data-level access controls. Think of the API gateway as the security perimeter and application-level controls as the security within the perimeter. Both are required, and auditors understand the distinction.
How does API security relate to zero trust architecture?
API security is a core component of zero trust. The zero trust principle -- "never trust, always verify" -- applies directly to API design. Every API request, regardless of its network origin, must be authenticated and authorized. Every response must include only the data the requester is entitled to receive. Every communication channel must be encrypted. Every access event must be logged. In practice, implementing zero trust for APIs means: eliminating implicit trust based on network location (no "internal APIs do not need authentication"); enforcing identity-based access for every request; implementing least-privilege authorization at the object level; encrypting all traffic including internal; and monitoring every API interaction for anomalies. Organizations pursuing zero trust maturity will find that robust API security is not a separate initiative -- it is a prerequisite.
Secure Your APIs, Satisfy Your Auditors
API security is no longer an engineering best practice you can address informally. It is a compliance requirement with specific controls mapped to specific framework criteria. Every SOC 2 audit, ISO 27001 certification assessment, PCI DSS evaluation, and HIPAA risk analysis will examine how your APIs handle authentication, authorization, input validation, encryption, logging, and testing.
The challenge is not implementing any single control -- it is implementing all of them consistently across every API endpoint, maintaining evidence that they are operating effectively, and ensuring that nothing falls through the cracks as your API surface area grows.
That is exactly what QuickTrust automates. Our platform continuously monitors your API security controls, maps each one to the specific framework requirements you are pursuing, collects audit evidence automatically, and alerts you when gaps appear. Whether you are preparing for your first SOC 2 audit, maintaining ISO 27001 certification, or managing compliance across multiple frameworks simultaneously, QuickTrust ensures your API security posture is documented, demonstrable, and audit-ready.
Start your free QuickTrust assessment and see how your API security controls map to SOC 2, ISO 27001, PCI DSS, and HIPAA requirements -- before your auditor does.
Related Resources
- The Complete SOC 2 Compliance Guide for SaaS Startups
- ISO 27001 Certification: The Complete Implementation Guide
- HIPAA Compliance for Healthcare SaaS Companies
- PCI DSS Compliance: The Complete Guide
- Encryption at Rest and in Transit: The Complete Compliance Guide
- Access Control Policy: The Complete Guide
- Vulnerability Management Program Guide
- DevSecOps for Compliance: CI/CD Pipeline Security
- Incident Response Plan: How to Build One That Passes Every Audit
- Information Security Policy: The Complete Guide