Skip to content
Tutorials Center
My learning

Topics

Lesson 79 of 80 ยท Practice and Review

Cybersecurity Cheat Sheet

A one-page cybersecurity cheat sheet: core principles, which crypto to choose, OWASP defenses, security headers and incident response steps, with runnable lookups.

This is the page to keep open while you design, code or review. It teaches nothing new. It condenses the whole course into tables and short rules you can scan in seconds: the principles behind every decision, which cryptographic tool fits which job, the standard defense for each common web flaw, the headers to send, and the steps to follow when something goes wrong.

Each section points back to the lesson that explains the reasoning. A rule of thumb is a starting point, not a verdict, so when a rule surprises you, follow the link and read why it exists.

Principles at a glance

Principle One-line rule Lesson
Confidentiality Only authorized parties can read the data CIA triad
Integrity Unauthorized changes are prevented or detected CIA triad
Availability Authorized users can reach the system when needed CIA triad
Least privilege Grant the minimum access for the minimum time Access control models
Defense in depth Several independent layers, so one failure is not fatal CIA triad
Fail safe When something breaks, deny access and fail closed Secure coding principles
Never trust input Validate on the server, at every trust boundary Input validation
Risk Likelihood times impact decides what to fix first Threats and risk
Zero trust Verify every request; location on the network proves nothing Firewalls and zero trust

STRIDE helps you ask "what can go wrong?" for each part of a design: Spoofing, Tampering, Repudiation, Information disclosure, Denial of service, Elevation of privilege. See Threat modeling.

Which crypto tool for which job

The most common mistake is picking the wrong kind of tool. Encoding hides nothing, hashing cannot be reversed, and encryption needs a key you must protect.

Goal Use Avoid
Store a password Argon2id, scrypt or bcrypt, with a unique salt MD5, SHA-1, plain SHA-256, encryption
Check a file was not corrupted SHA-256 or SHA-3 MD5, SHA-1 for anything security related
Detect tampering with a message you both handle HMAC-SHA-256, compared in constant time A bare hash, == on secrets
Keep data secret (same key on both sides) AES-GCM or ChaCha20-Poly1305 (authenticated encryption) ECB mode, unauthenticated CBC, your own cipher
Exchange keys or sign data with strangers ECDH / X25519 and Ed25519 or ECDSA, RSA 2048+ Textbook RSA, short keys
Secure traffic in transit TLS 1.2 or 1.3 with valid certificates Disabling certificate checks
Generate tokens, keys, nonces The operating system's CSPRNG (secrets, os.urandom) random, timestamps, counters
Hold keys and secrets A vault or KMS, rotation, no secrets in git Config files in the repository

Details: Cryptography in plain language, Hashing, HMAC, Symmetric encryption, Public-key crypto, TLS, Randomness and keys, Password storage.

Here is the table above as a small lookup you can extend with your own team's standards:

Python A crypto chooser

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

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

OWASP-style web flaws and their defenses

For each flaw there is one primary defense that works by design, and a few extras. Prefer the primary one.

Flaw Primary defense Extras
Broken access control, IDOR Check ownership and role on the server for every request; deny by default Unguessable IDs (not a defense on their own), tests per role
Cryptographic failures TLS everywhere, strong password hashing, no custom crypto Encrypt sensitive fields, rotate keys
SQL injection Parameterized queries Least-privilege database accounts, ORM
XSS Context-aware output encoding CSP, sanitizer for rich text, HttpOnly cookies
CSRF SameSite cookies plus anti-CSRF tokens Check Origin, require re-authentication for big actions
Insecure design Threat model before building Abuse cases, secure design reviews
Security misconfiguration Hardened, repeatable configuration Remove defaults and debug modes, scan regularly
Vulnerable components Inventory, update, pin and scan dependencies SBOM, signed releases
Authentication failures MFA or passkeys, rate limiting, safe session handling Breached-password checks
Integrity failures Verify signatures; never unpickle untrusted data Safe formats such as JSON
Logging and monitoring gaps Log security events centrally, alert on patterns Protect logs from tampering
SSRF Allow-list destinations, block internal address ranges Network egress rules

See OWASP Top 10, SQL injection, XSS, CSRF and CORS, SSRF and deserialization, and API security.

Security headers to send

Header Typical value
Strict-Transport-Security max-age=31536000; includeSubDomains
Content-Security-Policy default-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'
X-Content-Type-Options nosniff
Referrer-Policy strict-origin-when-cross-origin
Permissions-Policy camera=(), microphone=(), geolocation=()
Cookies Secure; HttpOnly; SameSite=Lax (or Strict)

Roll out CSP with Content-Security-Policy-Report-Only first. Details are in HTTP security headers.

Authentication and sessions in one list

  • Hash passwords with a slow, salted algorithm; compare in constant time. Length matters more than odd character rules (Password strength).
  • Offer MFA, preferably phishing-resistant passkeys (MFA and passkeys).
  • Session IDs are random, long, rotated at login and invalidated at logout. JWTs must be verified (signature, exp, aud) with the algorithm you expect, never the one the token claims (Sessions and tokens).
  • OAuth 2.0 public clients use the authorization code flow with PKCE and a state value (OAuth and SSO).
  • Authorization is separate from authentication and is checked on every request (Access control models).

Incident response at a glance

flowchart LR
    P["1. Prepare<br/>runbooks, contacts, logs"] --> D["2. Detect and analyze<br/>confirm, scope, severity"]
    D --> C["3. Contain<br/>isolate, revoke access"]
    C --> E["4. Eradicate<br/>remove cause, patch"]
    E --> R["5. Recover<br/>restore, monitor"]
    R --> L["6. Learn<br/>review, fix process"]
    L --> P

The cycle follows the NIST model. Lessons learned feed the next round of preparation.

When an alert looks real:

  1. Write down the time and keep every action in a log.
  2. Preserve evidence before you clean up: copies of logs, memory and disk images when appropriate, with hashes (Digital forensics basics).
  3. Contain first, for example by disabling an account, revoking tokens or isolating a host. Do not power machines off without a reason; memory holds clues.
  4. Rotate credentials and keys that could have been exposed.
  5. Communicate through the channels in your plan, to the people who need to know, in plain facts.
  6. Review what happened without blame, and fix the cause (Incident response).

Numbers help prioritize vulnerabilities. CVSS gives a 0 to 10 base score: 0.1 to 3.9 low, 4.0 to 6.9 medium, 7.0 to 8.9 high, 9.0 to 10.0 critical. Combine it with exposure and business impact (Vulnerability management).

Python A triage helper

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

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The adjusted score is a simple teaching rule, not a standard. Real programs add exploit availability, compensating controls and agreed deadlines.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. You need to store user passwords. Which choice is correct?

    Passwords need a deliberately slow, salted one-way hash. Fast hashes are cheap to brute-force, encryption can be reversed with the key, and Base64 is only an encoding.
  2. 2. Which defense is the primary fix for SQL injection?

    Parameterized queries keep data separate from the SQL command, so input can never change the query's structure. The other measures are at best extras.
  3. 3. A server must be sure a message was not changed and came from someone with the shared secret. What fits?

    A bare hash can be recomputed by an attacker after changing the message. HMAC needs the secret key, so only key holders can produce a valid tag.
  4. 4. During an incident, what should you do before cleaning up an affected machine?

    Cleaning first destroys the evidence you need to find the cause and scope. Contain, preserve, then eradicate, and keep a log of every action.
  5. 5. What does the primary CSP directive frame-ancestors 'none' protect against?

    frame-ancestors lists who may embed your page. 'none' forbids all embedding, which blocks clickjacking.

Summary

  • Decide with the principles: least privilege, defense in depth, fail closed, never trust input, and risk as likelihood times impact.
  • Pick the tool by the job: slow salted hashes for passwords, HMAC for message authentication, authenticated encryption for secrecy, TLS for transport, the OS random source for secrets.
  • Use the primary defense for each web flaw: parameterized queries, output encoding, server-side access checks, SameSite plus tokens, allow-lists.
  • Send the standard headers and set cookies with Secure, HttpOnly and SameSite.
  • In an incident, preserve evidence, contain, eradicate, recover and learn, and prioritize fixes by severity plus exposure.

You have reached the end of the Cybersecurity tutorial. Revisit any chapter from the course home, or test yourself again with Practice: Fundamentals and Cryptography.