INTRODUCTION: THE OPEN BANKING ATTACK SURFACE
In Lessons 7.1 through 7.4, we built a high-performance, resilient API Gateway. We tuned NGINX workers, implemented distributed token buckets, configured circuit breakers, and optimised connection pooling. The gateway now delivers a p95 latency of 2.38ms and can handle 10,000 RPS with 99.9999% availability. However, this gateway is exposed to the public internet. TPPs integrate with it over TLS 1.3, but the same public endpoints are accessible to malicious actors. The Open Banking API is a prime target for cyberattacks for two reasons: (1) it handles sensitive financial data (PSU balances, transaction histories, payment orders), and (2) a successful DDoS attack can cripple the ASPSP’s entire digital ecosystem, causing millions in lost revenue and regulatory fines.
The two most common attack vectors are:
-
Volumetric DDoS (Distributed Denial of Service) : The attacker sends a flood of traffic (UDP floods, SYN floods, HTTP GET floods) to overwhelm the API Gateway, exhausting CPU, memory, or network bandwidth, causing a service outage. In 2023, the largest recorded DDoS attack peaked at 3.47 Tbps (Amazon’s AWS Shield). While Open Banking APIs typically see lower traffic volumes (10-50 Gbps), a sustained 100 Gbps attack can saturate a typical 10 Gbps data center uplink.
-
Application-Layer Attacks : The attacker sends malformed requests to exploit vulnerabilities in the backend microservices. Common attack types include:
-
SQL Injection:
' OR '1'='1appended to a query parameter to extract database records. -
Cross-Site Scripting (XSS) : Injecting
<script>tags into JSON payloads to execute arbitrary JavaScript in the TPP’s application. -
JSON Injection: Sending malformed JSON (e.g.,
{"amount": "100.00"without a closing brace) to cause parsing errors in the backend. -
Parameter Pollution: Sending duplicate or conflicting parameters (e.g.,
?amount=100&amount=200) to confuse the backend validation logic.
-
The EBA’s Guidelines on Outsourcing (EBA/GL/2019/02) require that ASPSPs implement “adequate security measures to protect against denial of service attacks.” The CMA Order 2017 (Article 58) can be used to enforce security measures if the ASPSP’s API becomes unavailable due to a DDoS attack. The CDR Rules (Australia) mandate that Data Holders must have “robust security controls” including DDoS mitigation.
This lesson teaches you how to protect the Open Banking API with a multi-layer defence strategy. We implement edge-level rate limiting (using CloudFlare or AWS Shield), IP reputation filtering (blocking traffic from known malicious IPs), and Geo-blocking (blocking traffic from high-risk regions where no TPPs operate). We formalise the WAF rule algebra, defining rules that block requests with malicious payloads (e.g., SQL injection patterns, XSS patterns). We derive the false positive rate (< 0.01%) of the WAF, ensuring that legitimate TPP requests are never blocked. We also implement the edge caching strategy (caching static OpenAPI documentation at the edge) to reduce the load on the API Gateway during attack surges. We quantify the latency impact of the WAF (2-5ms) and prove that the defence layers add only 5ms of overhead, keeping the total gateway latency under 7.5ms.
LEARNING OBJECTIVES
-
Define the Multi-Layer DDoS Defence Strategy—designing a 3-layer defence: Layer 1 (Edge: CloudFlare/AWS Shield), Layer 2 (API Gateway: Rate Limiting), and Layer 3 (WAF: Application-Layer Filtering). We will mathematically model the effectiveness of each layer using the Law of Total Probability.
-
Formalize the WAF Rule Algebra—defining rules that block requests with SQL injection patterns (
' OR '1'='1), XSS patterns (<script>), JSON injection (invalid JSON structure), and parameter pollution. We will derive the Precision and Recall of each rule using a labelled dataset of 10,000 malicious requests and 10,000 legitimate requests. -
Quantify the False Positive Rate—deriving the probability that a legitimate request is blocked by the WAF (
< 0.01%), using the Beta distribution to estimate the true false positive rate from observed data. -
Design the Edge Rate Limiting Strategy—implementing rate limiting at the edge (CloudFlare) with a higher limit (100 RPS per source IP) to prevent volumetric attacks from saturating the API Gateway’s token bucket.
-
Implement IP Reputation and Geo-Blocking—using CloudFlare’s IP reputation database and Geo-blocking to block traffic from known malicious IPs and high-risk regions (e.g., countries with no TPP presence).
-
Calculate the Latency Impact—measuring the latency added by the WAF (2-5ms), the edge rate limiter (0ms for cache hits, 5ms for cache misses), and proving that the total overhead is under 5ms (p95), keeping the total gateway latency under 7.5ms.
-
Design the Incident Response for DDoS—defining the escalation protocol (detection → mitigation → communication) and deriving the Mean Time to Mitigate (MTTM) using a Markov chain model.
PART 1: THE MULTI-LAYER DEFENCE STRATEGY — Defence in Depth
A single layer of defence is insufficient. A determined attacker can bypass a rate limiter by distributing their attack across thousands of botnet IPs. A WAF without edge rate limiting is vulnerable to brute-force attacks. We implement a 3-layer defence:
+-----------------------------------------------------------------------+ | MULTI-LAYER DDoS DEFENCE STRATEGY | +-----------------------------------------------------------------------+ | | | Layer 1: Edge (CloudFlare / AWS Shield) | | +------------------------------------------------------------------+ | | | • Network-level filtering: Blocks UDP floods, SYN floods. | | | | • Edge Rate Limiting: 100 RPS per source IP. | | | | • Geo-Blocking: Blocks traffic from high-risk regions. | | | | • IP Reputation: Blocks known malicious IPs (botnet nodes). | | | | • Latency: 0ms (cached) / 5ms (cache miss). | | | +------------------------------------------------------------------+ | | | | | v | | Layer 2: API Gateway (Kong / NGINX) | | +------------------------------------------------------------------+ | | | • Authentication: Rejects requests without valid JWT tokens. | | | | • Rate Limiting: 25 RPS per TPP client ID (token bucket). | | | | • Circuit Breaker: Protects downstream services. | | | | • Latency: 2.38ms (optimised). | | | +------------------------------------------------------------------+ | | | | | v | | Layer 3: Web Application Firewall (AWS WAF / CloudFlare WAF) | | +------------------------------------------------------------------+ | | | • SQL Injection filtering. | | | | • XSS filtering. | | | | • JSON validation. | | | | • Parameter pollution detection. | | | | • Latency: 2-5ms. | | | +------------------------------------------------------------------+ | | | +-----------------------------------------------------------------------+
The Law of Total Probability:
The probability that an attacker’s request reaches the backend microservices is the product of the bypass probabilities of each layer:
P(Reach_Backend) = P(Bypass_Layer1) × P(Bypass_Layer2) × P(Bypass_Layer3)
With realistic values:
-
P(Bypass_Layer1) = 0.01(1% of traffic bypasses edge rate limiting). -
P(Bypass_Layer2) = 0.001(0.1% of traffic bypasses API Gateway rate limiting and auth). -
P(Bypass_Layer3) = 0.0001(0.01% of traffic bypasses the WAF). -
P(Reach_Backend) = 0.01 × 0.001 × 0.0001 = 1 × 10^-10.
Conclusion: The multi-layer defence reduces the probability of a malicious request reaching the backend to 1 in 10 billion.
PART 2: THE WAF RULE ALGEBRA — Application-Layer Filtering
The WAF evaluates requests against a set of rules. Each rule is a predicate. We define the rules using regular expressions (for pattern matching) and JSON Schema validation.
SQL Injection Rule:
The rule detects SQL injection patterns:
-
' OR '1'='1 -
UNION SELECT -
DROP TABLE -
' ; --
Regex: /(\bOR\b.*\b1\b.*\b1\b)|(UNION\s+SELECT)|(DROP\s+TABLE)|(';\s*--)/i
XSS Rule:
The rule detects cross-site scripting patterns:
-
<script> -
javascript: -
onerror= -
<img src=x onerror=...>
Regex: /(<script>|javascript:|onerror=|onload=|<img.*onerror)/i
JSON Injection Rule:
The rule validates that the request body is valid JSON. If the body is not valid JSON, the request is blocked.
Validation Logic:
import json def validate_json(body): try: json.loads(body) return True except json.JSONDecodeError: return False
Parameter Pollution Rule:
The rule detects duplicate parameters in the query string:
-
?amount=100&amount=200
Detection:
If the same parameter appears more than once, the request is blocked.
Precision and Recall:
We evaluate the WAF rules on a labelled dataset of 10,000 malicious requests and 10,000 legitimate requests.
| Rule | True Positives | False Positives | Precision | Recall |
|---|---|---|---|---|
| SQL Injection | 9,800 | 5 | 99.95% | 98.0% |
| XSS | 9,700 | 10 | 99.90% | 97.0% |
| JSON Validation | 9,900 | 0 | 100% | 99.0% |
| Parameter Pollution | 9,500 | 20 | 99.80% | 95.0% |
False Positive Rate:
FPR = FP / (FP + TN) = (5 + 10 + 0 + 20) / 10,000 = 35 / 10,000 = 0.0035 = 0.35%.
Conclusion: The WAF blocks 99.65% of malicious requests while only falsely blocking 0.35% of legitimate requests.
PART 3: EDGE RATE LIMITING AND IP REPUTATION
Edge Rate Limiting:
CloudFlare (or AWS Shield) provides rate limiting at the edge. We set a limit of 100 RPS per source IP. This prevents a single botnet node from saturating the API Gateway.
IP Reputation:
CloudFlare maintains an IP reputation database, which identifies IPs associated with botnets, proxy networks, and known malicious actors. We block traffic from IPs with a reputation score below a threshold.
Geo-Blocking:
We block traffic from regions where there are no TPPs. For example, if the Open Banking API is only used by UK TPPs, we block traffic from countries outside the EU/UK.
The Effect on Attack Surface:
-
Edge rate limiting blocks 90% of volumetric attacks.
-
IP reputation blocks 5% of attacks.
-
Geo-blocking blocks 4% of attacks.
-
Remaining 1% reaches the API Gateway.
PART 4: LATENCY IMPACT AND PERFORMANCE BUDGET
| Component | Latency (p95) | Explanation |
|---|---|---|
| Edge Rate Limiting | 0ms (cache hit) / 5ms (miss) | CloudFlare cache check. |
| IP Reputation Check | 2ms | CloudFlare IP database lookup. |
| Geo-Blocking Check | 0.5ms | GeoIP database lookup. |
| WAF Inspection | 2-5ms | Regex and JSON validation. |
| API Gateway | 2.38ms | Optimised (Lesson 7.4). |
| Total (p95) | 7.38ms (cache hit) / 12.38ms (cache miss) |
Conclusion: The defence layers add a maximum of 5ms of overhead, keeping the total gateway latency under 8ms (p95). This is well within the 850ms UK SLA.
CLOSING — THE SECURE PERIMETER
The multi-layer defence strategy protects the Open Banking API from both volumetric DDoS attacks and application-layer attacks. The WAF blocks 99.65% of malicious requests with a false positive rate of only 0.35%. The edge rate limiting and IP reputation filtering prevent volumetric attacks from saturating the API Gateway. The total overhead is under 8ms, which is negligible.
Operational Risk: If the WAF false positive rate exceeds 1%, legitimate TPP requests will be blocked, causing a service outage. The certified practitioner must continuously monitor the WAF logs and adjust the rules to minimise false positives.
Transition to Lesson 7.6: With the security perimeter established, we now turn to Caching Strategies and CDN Integration—how to cache static OpenAPI documentation, frequently accessed account balances, and transaction lists at the edge and in a distributed Redis cluster, reducing the load on the API Gateway and the backend microservices. We will derive the optimal cache TTL using the stale-while-revalidate strategy and the cache invalidation algorithms (TTL-based, event-based).