How attackers turn a web app breach into euros — credential resale, payment data, account takeover, fraudulent transactions. The economics that drive defenses.
Attackers optimize for profit per hour. Defenses that don't change attacker economics don't reduce risk — they just shuffle which doors get opened. To build defenses that actually deter attacks, you need to understand what makes a compromise profitable and what makes it not.
This tutorial walks through the main monetization patterns for web app compromise and the specific defenses that disrupt each.
The most common monetization route, requires the least skill from the buyer.
A successful stuffing campaign returns 0.1%-1% of attempted credentials. The math works because compute is cheap and attempts are unlimited.
# Django example: enforce breached-password check on login
import hashlib
import requests
def is_breached(password: str) -> bool:
sha1 = hashlib.sha1(password.encode()).hexdigest().upper()
prefix, suffix = sha1[:5], sha1[5:]
r = requests.get(f"https://api.pwnedpasswords.com/range/{prefix}", timeout=2)
if r.status_code != 200:
return False # Fail open — don't lock users out on API issues
return any(line.startswith(suffix) for line in r.text.splitlines())
def login_view(request):
if request.method == 'POST':
password = request.POST['password']
if is_breached(password):
messages.error(request, 'This password appears in known breaches. Please use a different password.')
return redirect('password_reset')
# ...regular auth flow
The classic and still highly profitable. Attackers compromise either:
Attackers compromise either the host directly or a CDN/script you load. Inject JavaScript into the checkout page that copies form data and POSTs it to attacker-controlled infrastructure. The page works normally — customer pays, gets product. But their card is now stolen.
Famous victims: British Airways, Ticketmaster, Newegg. Losses in the hundreds of millions, plus regulatory fines.
script-src 'self' plus explicit allowlist for CDNs.<script src="..." integrity="sha384-..."> ensures the loaded content matches the expected hash.# CSP middleware in Django settings
CSP_DEFAULT_SRC = ("'self'",)
CSP_SCRIPT_SRC = ("'self'", "https://js.stripe.com", "https://cdn.jsdelivr.net")
CSP_STYLE_SRC = ("'self'", "'unsafe-inline'", "https://cdn.jsdelivr.net")
CSP_FRAME_SRC = ("https://js.stripe.com",)
CSP_CONNECT_SRC = ("'self'", "https://api.stripe.com")
CSP_REPORT_URI = "/csp-report/"
The economics shift when the target is a specific account, not a bulk credential. Attackers take over:
The attack: targeted phishing, SIM swap to bypass SMS-MFA, OAuth consent phishing, or session token theft.
Attacker doesn't want your data. They want your CPU.
The miner often doesn't even need root — runs as the application user, indistinguishable from a busy worker process. Easy to miss until the cloud bill arrives.
Less obvious than the others but extremely lucrative.
Many web apps integrate with email — sending invoices, password resets, notifications, customer communications. Compromise of the app may give attackers:
The attacker uses this to send convincing emails to your customers' AP departments, requesting that future invoices be paid to an attacker-controlled bank account.
p=reject with monitoringA specific and growing pattern: your web app loads JS/CSS from a third-party CDN or package manager. The third party gets compromised. Your users get malicious code.
Recent examples:
Mapping defense priorities to threat types:
| Defense | Disrupts |
|---|---|
| MFA (phishing-resistant) | Credential stuffing, account takeover, BEC |
| Rate limiting on auth | Credential stuffing |
| Breached password blocking | Credential stuffing |
| CSP + SRI | Magecart, supply chain JS injection |
| DMARC | Email spoofing, BEC |
| Egress filtering | Cryptominer C2, data exfiltration |
| Dependency pinning + scanning | Supply chain |
| Audit logging + anomaly alerting | All categories — your detection layer |
The combination is multiplicative. Each defense alone deters some attackers; the stack deters the ones who'd otherwise persist.
Patterns in real-world Dutch SME web app breaches:
/admin/ as needing special protectionEach is preventable with the basics from tutorial 1 plus the disruptions in this tutorial. None require nation-state-tier defenses — just consistent execution of fundamentals.
Understanding how attackers turn a technical compromise into actual money is one of the most useful things a defender can learn, because it reveals what they are really after and therefore what to protect hardest. A vulnerability is only a means to an end, and the end is almost always financial — fraud, theft, ransom, or selling access and data. Tracing the path from an initial flaw to a payout shows you which assets and capabilities are the real targets, letting you concentrate defenses where the money is rather than spreading effort evenly across things that have very different value to an attacker.
Smaller organizations are frequently targeted precisely because they often lack the layered defenses and monitoring of larger ones, while still handling money and valuable data. The common failure points are predictable: weak authentication, unpatched systems, poor separation between functions, and no monitoring to catch fraud in progress. These gaps are what let a compromise translate into a financial loss before anyone notices. Recognizing where these weaknesses typically lie — and that being small is not the same as being an unattractive target — is the first step to closing the paths that turn an intrusion into a wire fraud or a drained account.
Because monetization is a chain of steps from compromise to cash-out, you can defend at multiple points, not just at the initial vulnerability. Strong authentication and patching reduce initial access; segmentation limits movement; transaction controls and anomaly detection catch fraud before it completes; and monitoring shortens the time an attacker has to act. Even if one defense fails, another can break the chain before money is lost. Thinking about security as disrupting the attacker's path to profit — rather than only preventing the first flaw — gives you many opportunities to stop an attack, and it focuses your effort on protecting the financial outcomes attackers are ultimately chasing.
Attackers will always find the cheapest path to monetization. Your job is to make every path expensive enough that they move to another target. Perfect security is impossible. Sufficient deterrent is achievable.
Build defenses that change the economic calculation. Track them. Test them. The next eight tutorials show you how at the technical level.