Skip to content
Tutorials Center
My learning

Topics

Lesson 53 of 53 ยท Practice and Review

Defensive Security Cheat Sheet

A one-page defensive security cheat sheet: testing methodology, OWASP Top 10 fixes, a hardening checklist, a severity guide and legal reminders in one place.

This is the page to bookmark. It condenses the whole course into short lists you can scan before a test, a code review or an interview: the order of work in a penetration test, the standard fix for each common web weakness, a hardening checklist, how to rate severity, and the legal rules that never change. Each item links back to the lesson that explains it.

Nothing here can be run against real systems from this site, so the tables are read-only. Two small JavaScript stand-ins at the end turn the severity guide and the hardening checklist into code, so you can see how a report or a dashboard might use them. They are teaching models, not real scanners.

Four habits that matter most

Authorize first Written permission and a scope.
Deny by default Allow-lists and least privilege.
Log and watch You cannot respond to what you never saw.
Patch fast Known bugs are the easiest way in.

Almost every finding in this course is a broken version of one of these four.

1 / 2

Methodology in one screen

A test follows the same arc whatever the target. See the penetration testing process for detail.

Phase Goal Typical output
Authorization Written permission, scope, rules of engagement, contacts Signed scope document (law and authorization)
Planning and threat modeling Know the assets and trust boundaries Ranked list of risks (threat modeling)
Reconnaissance Learn what is exposed Hosts, services, technologies (passive recon)
Scanning and enumeration Find candidate weaknesses Open services, versions, scanner output (port scanning)
Validation Confirm a finding is real, with the least impact Evidence and reproduction steps
Triage and rating Decide what matters first Severity per finding (vulnerability scanning)
Reporting Explain risk and fixes to two audiences Executive summary and technical findings (reporting)
Retest Check that fixes work Closed or reopened findings

Rules that apply in every phase: stay inside the scope, stop and report if you find something unexpectedly serious, avoid touching real user data, keep notes with timestamps, and protect your own evidence.

OWASP Top 10 style weaknesses and their fixes

Category names change between editions of the OWASP list, so this table groups by the underlying idea. The fix column is the standard, boring answer. See web application security basics for the overview.

Weakness What goes wrong Main fix Lesson
Broken access control Users reach objects or functions they should not (IDOR, missing role checks) Check authorization on the server for every request and every object; deny by default Authentication flaws
Cryptographic failures Sensitive data unprotected or weak algorithms TLS everywhere, standard algorithms and libraries, no custom crypto, protect keys Cryptography essentials
Injection (SQL, OS command, template) Input is interpreted as code Parameterized queries, safe APIs, input validation, least-privilege accounts SQL injection
Cross-site scripting Attacker script runs in a victim's browser Context-aware output encoding, a Content Security Policy, safe templating XSS and CSRF
Cross-site request forgery A browser is tricked into sending a state-changing request SameSite cookies, anti-CSRF tokens, re-authentication for risky actions XSS and CSRF
Insecure design The feature itself is unsafe Threat model early, abuse cases, secure design patterns Threat modeling
Security misconfiguration Default accounts, open storage, debug on, verbose errors Hardened baselines, automated configuration checks, remove what you do not use OS hardening
Vulnerable and outdated components Known bugs in libraries and software Inventory, dependency scanning, patch process Vulnerability scanning
Authentication failures Weak passwords, no rate limits, bad sessions Slow password hashes, MFA, lockout or throttling, secure session cookies Password security
Integrity failures Untrusted updates, packages or serialized data Signed artifacts, pinned dependencies, never deserialize untrusted data Secure development
Logging and monitoring failures Attacks go unnoticed Log security events centrally, alert on patterns, test your alerts Logging and SIEM
Server-side request forgery The server fetches an attacker-chosen URL Allow-list destinations, block internal address ranges, no raw redirects Server-side flaws

Related items worth knowing: path traversal and unsafe uploads (validate and normalize paths, store uploads outside the web root, check types by content), and API-specific issues such as mass assignment and missing rate limits (API security).

Hardening checklist

Use this as a starting list and adapt it to a published baseline for your platform.

Accounts and access

  • Unique accounts for people; no shared admin logins.
  • Least privilege for users, services and database accounts.
  • Multi-factor authentication for administrators and remote access.
  • Default and unused accounts removed or disabled.
  • Passwords stored with bcrypt, scrypt or Argon2, never a fast hash.

Systems and software

  • An inventory of hosts, services and versions.
  • Automatic security updates, or a measured patch schedule with a deadline per severity.
  • Only required services and ports enabled; everything else closed.
  • File permissions reviewed; no world-writable sensitive files; minimal SUID programs (privilege escalation and hardening).
  • Full disk encryption on laptops and encrypted backups.

Network

  • Segmentation between user, server and management networks (network defenses).
  • Default-deny firewall rules, reviewed regularly.
  • TLS with current versions on every external service; HSTS on websites.
  • WPA3 or WPA2 Enterprise for wireless, with guest traffic separated (wireless security).
  • Email protection with SPF, DKIM and DMARC (malware and social engineering).

Applications

  • Parameterized queries, output encoding, and server-side authorization checks.
  • Secure cookie flags: Secure, HttpOnly, and SameSite.
  • Security headers such as Content-Security-Policy and X-Content-Type-Options.
  • Secrets in a secret manager, not in source code or images (secure development).
  • Error pages that do not leak stack traces.

Cloud and containers

  • No public storage unless it is deliberately public.
  • IAM roles with narrow permissions; no long-lived keys where roles work.
  • Minimal base images, non-root containers, scanned images (cloud and container security).

Detection and response

  • Authentication, privilege changes and admin actions logged and centralized (logging and SIEM).
  • Alerts tested, and an on-call owner for them.
  • A written incident response plan with contacts, tested at least once a year (incident response).
  • Backups that are tested by restoring, and kept offline or immutable.

Severity guide

Severity should reflect impact and likelihood in your context. A common starting point is the qualitative scale used with CVSS scores:

Score Rating Typical meaning Example target for fixing
0.0 None No security impact Informational only
0.1 to 3.9 Low Limited impact or hard to exploit Next planned release
4.0 to 6.9 Medium Real impact with some conditions Within weeks
7.0 to 8.9 High Serious impact, practical to exploit Within days to a couple of weeks
9.0 to 10.0 Critical Remote, easy and severe, often unauthenticated Immediately

The fix-time column is an example, not a standard: every organization sets its own deadlines. Raise the priority when the system is internet-facing, holds sensitive data, has a public exploit, or is already being attacked. Lower it when compensating controls exist. A base score alone never replaces judgment (vulnerability scanning).

Stand-in: rating scores

This small function turns a CVSS-style base score into the qualitative rating from the table and adjusts the urgency for exposure. The adjustment rule is invented for the demo.

JS Score to rating

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The same score ends up with different urgency depending on exposure. That difference is the whole point of triage.

These never change, whatever the technique.

  • Written authorization first. Permission from someone who has the right to give it, naming the targets, the dates and the allowed activities.
  • Scope is a hard line. If a host, domain or technique is not listed, it is out of scope. Third-party services (cloud providers, payment processors) often have their own rules.
  • Minimize harm. Avoid denial of service unless explicitly allowed, never read more data than you need to prove a finding, and never keep real personal data longer than agreed.
  • Report responsibly. Tell the owner privately, give them time to fix, and follow the bug bounty or disclosure policy.
  • Stop when unsure. Pausing to ask costs a day. Crossing a legal line can cost a career.
  • Practice only in your own lab or on platforms built for it (building a lab, law and authorization).

Laws differ between countries; this is general guidance, not legal advice.

Stand-in: checklist scoring

This model scores a configuration against a hardening checklist and lists what to fix first. Real tools read actual system state; here the state is a plain object.

JS Checklist score

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What must exist before any testing starts?

    Permission from someone entitled to give it, plus a scope, is what separates a penetration test from an attack.
  2. 2. What is the standard fix for SQL injection?

    Parameterized queries keep data separate from SQL code. Filtering quotes and hiding errors do not remove the root cause.
  3. 3. Two findings have the same CVSS base score. Which should usually be fixed first?

    Exposure and exploit availability raise real-world risk, so context changes priority even when scores match.
  4. 4. Which password storage approach belongs on the hardening checklist?

    Slow, salted password hashes make large-scale guessing expensive. Base64 is only an encoding, and fast hashes are cheap to brute-force.

Summary

  • Work in order: authorize, plan, reconnoiter, scan, validate, triage, report, retest.
  • Most web bugs have a standard fix: parameterized queries, output encoding, server-side access checks, allow-lists and tokens.
  • Harden by default: least privilege, MFA, patching, default-deny networks, centralized logs and tested backups.
  • Rate findings by impact and likelihood, then adjust for exposure and exploit availability.
  • Scope, written permission and responsible disclosure are never optional.

That is the end of the reference pages. To revisit the beginning, start again with What Ethical Hacking Is.