Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

Foundations / Security fundamentals

Security fundamentals cheat sheet

Rank risks

TermMeaning
AssetSomething of value to protect
ThreatSomething that can cause harm
VulnerabilityA weakness that lets the threat work
Likelihood, impactEach scored 1 to 5
RiskLikelihood times impact, 1 to 25
ControlAn action that lowers likelihood, impact or both
Residual riskWhat is left after a control. Someone must accept it
Preventive, detective, correctiveA control that stops the event, finds it, or limits the harm and restores
Administrative, technical, physicalA control made of a rule, of software or hardware, or of a thing in the real world

Protect a file

TaskCommand or rule
Read the modesOwner, group, others each hold r 4, w 2, x 1
Make a file privatechmod 600 secret.txt
Hash a filesha256sum rent.txt | tee rent.sha256
Check the hashsha256sum -c rent.sha256
Back up with a datecp -a docs backup/docs-$(date +%F)
Prove the restorediff -r backup/docs-* restore-test/docs && echo "restore matches"

Prove identity and limit access

TaskCommand or rule
Hash a passwordhashlib.scrypt(password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32)
Compare in constant timehmac.compare_digest(candidate, key)
Make a one-time codehotp(key, int(now // step), digits)
Allow one permissionallowed("bo", "report:create")
Stop self-approvalallowed(user, "report:approve") and report["author"] != user
Make a file private from the start(umask 077; echo "q3 findings" > report.txt)
Give the group read accesschmod 640 report.txt
Know the mode of a new fileA file starts at 666 and a folder at 777, with the umask bits removed: 666 with 027 removed is 640
Run the access testspython3 test_rbac.py

Use cryptography

TaskCommand
Hash a fileopenssl dgst -sha256 message.txt
Encryptopenssl enc -aes-256-cbc -pbkdf2 -salt -in message.txt -out message.enc -pass env:KRPASS
Decryptopenssl enc -d -aes-256-cbc -pbkdf2 -in message.enc -pass env:KRPASS
Make a private keyopenssl genpkey -algorithm ed25519 -out private.pem
Get the public keyopenssl pkey -in private.pem -pubout -out public.pem
Signopenssl pkeyutl -sign -rawin -inkey private.pem -in message.txt -out message.sig
Verifyopenssl pkeyutl -verify -rawin -pubin -inkey public.pem -in message.txt -sigfile message.sig
Read a certificateopenssl x509 -in cert.pem -noout -subject -issuer -dates
Start a test TLS server, on your own machine onlyopenssl s_server -accept 8643 -cert cert.pem -key cert.key -www > server.log 2>&1 &
See a TLS handshake (with the server running)openssl s_client -connect 127.0.0.1:8643 -brief < /dev/null
Stop the test serverkill $!

Detect and respond

TaskCommand or rule
Count failures by addressgrep Failed auth.log | awk '{print $NF}' | sort | uniq -c | sort -rn
Run the rulepython3 detect.py
Set the ruleWINDOW = timedelta(minutes=5) and LIMIT = 5
Name the response stepsPrepare, detect, contain, eradicate, recover, learn

Model threats

TermMeaning
Trust boundaryA line where the level of trust changes
S SpoofingPretending to be someone else. Breaks authentication
T TamperingChanging data or code. Breaks integrity
R RepudiationDenying an act. Needs trustworthy logs
I Information disclosureData reaches the wrong reader. Breaks confidentiality
D Denial of serviceSystem unavailable. Breaks availability
E Elevation of privilegeDoing what you may not do. Breaks authorisation
TaskCommand
Check the threat table for gapspython3 check.py threats.md User P1 S1 F1 F2 F3

Check a baseline

TaskCommand or rule
Run the checkerpython3 baseline.py
Run it with another baselinepython3 baseline.py baseline2.json
Read the exit codeecho "exit code: $?". 1 means a failure
Close a home folderchmod 750 ~
Fail closedA check that cannot run counts as FAIL

Safety habits