What is Web Security?
The attacker's mindset, threat modelling, and why security is every developer's job
Skills taught: websecurity.threat-model, websecurity.attacker-mindset, websecurity.cia-triad, websecurity.attack-surface
Security is a developer problem
The majority of security breaches aren't caused by nation-state hackers exploiting zero-day vulnerabilities — they're caused by common coding mistakes that have been understood and documented for decades. SQL injection was first described in 1998. XSS attacks were systematically catalogued in the early 2000s. Yet both still appear in production code every year. Web security isn't a specialisation you hand off to a 'security team' — it's a set of patterns every developer must know, like how to handle async code or how to write a database query.
The CIA Triad
- CIA Triad
- The three goals of information security: Confidentiality (data is only readable by authorised parties), Integrity (data has not been tampered with), and Availability (the system is accessible when needed). Every security control protects one or more of these three properties.
CONFIDENTIALITY:
Threat: attacker reads your database (user passwords, PII, credit cards)
Controls: encryption at rest, access control, least privilege
Broken by: SQL injection, path traversal, misconfigured S3 bucket
INTEGRITY:
Threat: attacker modifies data (changes order total, forges a review)
Controls: input validation, digital signatures, audit logs, CSRF tokens
Broken by: CSRF, parameter tampering, broken access control
AVAILABILITY:
Threat: system becomes unreachable (site is down, users can't pay)
Controls: rate limiting, DDoS protection, backups, redundancy
Broken by: DoS attacks, resource exhaustion, ransomware
Threat modelling — think like an attacker
Before writing security controls, ask:
1. WHAT ARE WE BUILDING?
Draw a data flow diagram: browser → API → database
Mark trust boundaries (where data crosses from untrusted to trusted)
2. WHAT CAN GO WRONG? (STRIDE categories)
S — Spoofing: attacker pretends to be someone else
T — Tampering: attacker modifies data or code
R — Repudiation: attacker denies having done something
I — Information Disc: attacker reads data they shouldn't see
D — Denial of Service: attacker makes the system unavailable
E — Elevation of Privilege: attacker gains more access than allowed
3. WHAT ARE WE GOING TO DO ABOUT IT?
For each threat: mitigate (fix it), accept (risk is low), transfer (insurance)
4. DID WE DO A GOOD JOB?
Test your controls. 'We added a check' doesn't mean the check works.
THE ATTACKER'S MINDSET:
'What is the application supposed to do — and what else can I make it do?'
Every input is a potential attack vector. Every API endpoint is a door.
Attackers are patient, creative, and not bound by your documentation.
Attack surface — what attackers target
NETWORK:
Open ports (every public port is a potential entry point)
Unencrypted traffic (HTTP instead of HTTPS)
Misconfigured firewalls
APPLICATION:
Every user input (forms, URL params, headers, file uploads)
Every API endpoint (authenticated and unauthenticated)
Third-party dependencies (your npm packages)
Authentication flows (login, password reset, OAuth)
INFRASTRUCTURE:
Exposed admin panels (pgAdmin, Kibana, Redis at a public port)
Default credentials never changed
Overly permissive cloud IAM roles
Unpatched software versions
HUMAN:
Phishing (attacker emails staff with a malicious link)
Social engineering (attacker calls support pretending to be a customer)
Insider threat (disgruntled employee)
REDUCING ATTACK SURFACE (the first line of defence):
→ Expose as little as possible (principle of least functionality)
→ Turn off what you don't use
→ Keep dependencies updated
→ Validate ALL input at every trust boundary
Tip: Security is not about being unbreakable — it's about raising the cost of attack. An attacker has limited time and resources. If your app requires 10,000 hours to breach while a competitor's takes 10 minutes, you will not be breached first. Defence-in-depth (multiple layers of protection) means that bypassing one control doesn't immediately give full access. No single control is perfect; the combination is what makes an application secure.
Frequently Asked Questions
Should I hire a security specialist or can developers handle this?
Both. Developers must know the fundamentals — writing parameterized queries, validating input, setting security headers, using HTTPS. This baseline prevents 90% of attacks. For high-risk applications (fintech, healthcare), additionally hire a penetration tester to audit the code once it's built, and a security engineer to design the architecture. Outsourcing basic security to a specialist doesn't work — the specialist isn't there when a developer writes an SQL query at 11pm.