# Network Security Essentials

> Know the common attacks and defences interviewers ask about: firewalls, VPNs, DDoS, man-in-the-middle, XSS, CSRF, SQL injection and secure authentication. Free...

Canonical: https://www.internhack.in/roadmaps/tracks/cs-fundamentals/network-security-basics
Last updated: 2026-11-28

Know the common attacks and defences interviewers ask about: firewalls, VPNs, DDoS, man-in-the-middle, XSS, CSRF, SQL injection and secure authentication.

Intermediate · about 4 hours · difficulty 2/5

Learn first: [HTTP, HTTPS and TLS](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/http-and-https)

You do not need to be a security engineer, but SDE interviews and system design rounds often include a "how would you secure this?" follow-up. A clear mental model of attacks and defences is enough.

### Network-level

- **Firewalls** filter traffic by rules on IPs, ports and protocols; stateful firewalls track connections.
- **VPNs** create an encrypted tunnel so traffic appears to come from another network.
- **Man-in-the-middle (MITM)**: an attacker intercepts traffic. Defence: TLS with proper certificate validation.
- **DDoS**: flooding a service with traffic from many machines. Defences: rate limiting, CDNs, scrubbing services, autoscaling.
- **SYN flood**: exhausting half-open TCP connections; mitigated with SYN cookies.

### Application-level (the OWASP favourites)

- **SQL injection**: user input concatenated into queries. Fix with **parameterised queries**.
- **XSS**: injected scripts run in other users' browsers. Fix with output encoding and a Content Security Policy.
- **CSRF**: a malicious site triggers requests using a logged-in user's cookies. Fix with CSRF tokens and `SameSite` cookies.
- Broken authentication: store passwords with slow hashes (**bcrypt**, Argon2) plus salt, never plain or MD5.

### Principles

- **Defence in depth**, **least privilege**, and never trusting client input.
- Authentication (who are you) vs authorization (what may you do).
- Hashing vs encryption vs encoding: hashing is one-way, encryption is reversible with a key, encoding (Base64) is not security at all.

Good enough to move on: for any feature you build, you can list the top three attacks it faces and the standard fix for each.

## Key concepts

- **Firewalls and VPNs**
- **MITM and certificate validation**
- **DDoS and SYN floods**
- **SQL injection**
- **XSS and CSRF**
- **Password hashing and salting**
- **Hashing vs encryption vs encoding**
- **OWASP Top 10**

## Mini project

Take a small login and comments app you built, deliberately add SQL injection and stored XSS bugs, exploit them yourself in a local environment, then fix them with parameterised queries, output encoding and bcrypt password hashing.

## Check yourself

Why does a CSRF attack work even though the attacker never sees the victim's cookies, and how does a SameSite cookie stop it?

## Free resources

- [OWASP Top Ten](https://owasp.org/www-project-top-ten/) (OWASP)
- [OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/) (OWASP)
- [Cloudflare Learning Center: What is a DDoS attack?](https://www.cloudflare.com/learning/ddos/what-is-a-ddos-attack/) (Cloudflare)

Previous: [HTTP, HTTPS and TLS](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/http-and-https) · Next: [Relational Model and ER Design](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/relational-model-er)

## More in Computer Networks

- [How the Internet Works: OSI and TCP/IP](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/network-models)
- [IP Addressing, Subnetting and Routing](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/ip-addressing-routing)
- [Transport Layer: TCP and UDP](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/tcp-and-udp)
- [DNS](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/dns)
- [HTTP, HTTPS and TLS](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/http-and-https)
- [Network Security Essentials](https://www.internhack.in/roadmaps/tracks/cs-fundamentals/network-security-basics)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [CS Fundamentals and Placement Prep Roadmap](https://www.internhack.in/roadmaps/tracks/cs-fundamentals)
