You're the only security person on your products. That means prevention (chapter 6) isn't enough: you also need to know when something is happening, and to have a plan when it does. This chapter is that plan.
The mindset
Attackers need to succeed once. Defenders need to notice one of the many steps an attacker takes. Every attack leaves traces: failed logins, odd requests, new admin accounts, unusual data volume. Detection is about collecting the traces and looking at them.
Logging: what to record
You can't investigate what you didn't log. For each app, log at least:
| Event | Fields |
|---|---|
| Login success / failure | time, account, trusted client IP, user agent, reason |
| Authorization denied (401/403) | time, account, route, method |
| Sensitive actions | password reset, role change, user delete, export, impersonation: who, to whom, what changed |
| Rate-limit and captcha blocks | IP, account |
| 5xx errors | route, error id (not the stack trace to the user) |
| Admin access | every admin page view or API call |
Pulse already persists 401/403/5xx, captcha rejections and IP blocks to pulse_logs.error_events, and Maeve has an impersonation audit and a traffic log. Good foundations.
What not to log: passwords, tokens, full card or health data. Logs leak too.
Trust your fields. A log that records a client-controlled X-Forwarded-For value as "the IP" can be filled with lies. Log both the trusted IP and the raw header.
Detection: turning logs into alerts
Start with a handful of high-signal rules rather than hundreds of noisy ones:
- Many failed logins for one account from many IPs (credential stuffing).
- Many failed logins from one IP across many accounts (spraying).
- Any change to
access_levelor entitlement fields not made by a known admin. - A new admin account, or an admin login from a new country or device.
- Large or unusual data exports.
- A burst of 403s from one account (someone probing access control).
- Requests to paths that don't exist in your app (
/wp-admin,/.env,/.git/config): scanners. Usually noise, but useful context.
The industry format for portable detection rules is Sigma (YAML that converts to any SIEM's query language). Here's the shape:
title: Pulse role change by non-admin
logsource: { product: pulse, category: audit }
detection:
selection:
action: user.update
changed_field: access_level
filter_admin:
actor_role: fen_admin
condition: selection and not filter_admin
level: high
You don't need a SIEM to begin. A scheduled SQL query that emails you when a rule matches is a perfectly good detection system for a small team.
-- Daily: accounts with 10+ failed logins from 5+ IPs in the last 24h
SELECT username, count(*) AS failures, count(DISTINCT ip) AS ips
FROM pulse_logs.error_events
WHERE kind = 'login_failed' AND created_at > now() - interval '24 hours'
GROUP BY username HAVING count(*) >= 10 AND count(DISTINCT ip) >= 5;
(Adjust names to your real schema.)
The SOC analyst's triage loop
When an alert fires:
- Is it real? Check the raw events. Many alerts are a user who forgot a password.
- What's the scope? Which accounts, which data, since when?
- Is it ongoing? If yes, contain first and investigate second.
- Write it down as you go, with timestamps.
Incident response
The standard phases (NIST SP 800-61) are: Preparation โ Detection & Analysis โ Containment โ Eradication โ Recovery โ Post-incident activity. The Practice Lab's Security & breach response track drills the same loop.
Preparation (do this now, calmly)
- A one-page runbook per app: how to disable an account, revoke all sessions, rotate the JWT secret and database credentials, take the app offline, and restore from backup.
- Know where the logs are and how long they're kept.
- Know your obligations. Health data (Maeve, and potentially Pulse depending on what it holds) can bring HIPAA or state breach-notification duties; contracts may set their own deadlines. Write down who you must tell and how fast.
- Test a backup restore at least once.
During an incident
- Contain: disable the affected accounts, revoke sessions, block the source, close the vulnerable route if needed. Keep systems running if you can, because evidence lives in memory and logs.
- Preserve: export the relevant logs before retention deletes them. Note every action you take, with the time.
- Scope: what did the attacker touch? Query the audit logs for the accounts and time window.
- Eradicate: fix the bug, rotate every credential the attacker could have seen.
- Recover: restore known-good data where needed, re-enable carefully, watch closely.
- Notify as required.
After
A blameless write-up: timeline, root cause, what detected it (or why nothing did), and one change that makes it impossible next time. Then add a test and a detection rule for it.
Phishing and accounts: the human side
Most breaches still start with stolen credentials. For yourself, as the person with the keys:
- Hardware security key or authenticator-app MFA on GitHub, Azure, Supabase, your domain registrar and email.
- A password manager, unique passwords everywhere.
- Separate admin accounts from day-to-day ones where the platform allows.
- Treat any "urgent" email asking you to log in or approve something with suspicion; go to the site directly instead of clicking.
Practice
- TryHackMe SOC Level 1 path (chapter 4).
- Blue Team Labs Online (by Security Blue Team, the BTL1 people) has investigation challenges.
- CyberDefenders has free blue-team challenges with real packet captures and logs.
- Your own logs: once a week, read a day of Pulse and Maeve logs for ten minutes. You'll learn what "normal" looks like, which is what makes "abnormal" jump out.
Check yourself
- Name three events every app should log, and one thing it must never log.
- Why should containment usually come before deep investigation?
- Write, in plain words, a detection rule for "a user's role changed and the change wasn't made by an admin".