Roadmaps / JavaScript / Phase 4
Phase 4 of 4 · Study weeks 13-16
Security, tests and shipping
This phase makes the last checkpoint possible: a service you can defend, test, observe and upgrade.
Topics every week
- Week 138 h
- SSRF and DNS rebinding
- XSS and Content Security Policy
- Prototype pollution
- Regular expression denial of service
Hand inAn attack table of 12 rows, each with a test that fails before the fix
- Week 148 h
- Lockfiles and
npm ci - Provenance and
npm audit signatures - Install scripts and a dependency budget
- Node's permission model (check its status for your version)
Hand inA dependency audit that removes at least two packages and says what each cost
- Lockfiles and
- Week 158 h
node:test- Property-based tests with
fast-check - Mocking
fetchwith Undici's mock agent - Coverage that means something
Hand inA test suite that catches each seeded fault, with a mutation spot check
- Week 168 h
- Structured logs and tracing
- Graceful shutdown on
SIGTERM - Service level objectives and alerts
- A Node upgrade policy
Hand inCheckpoint 4, the runbook and the upgrade memo
Practice projects
- Practice 1, the safe-fetch guard (Week 13): resolve the host, check the address after resolution, connect to that address and recheck on every redirect. Done when: eight attack cases pass, including the resolver stub that changes its answer.
- Practice 2, pollution and backtracking (Week 13): write a vulnerable merge function and a vulnerable regular expression, exploit both, then fix them. Done when: the exploit test fails before the fix and passes after, and a 30-character input that took over 1 s now takes under 5 ms.
- Practice 3, the dependency audit (Week 14): list every direct dependency with its reason, install scripts and what removing it would cost. Done when: two packages are gone and the test suite still passes.
- Optional, a fuzz run: fuzz the URL and header parser for 10 minutes. Done when: the run finds no crash, or you fix each one it finds with a test.
GitHub repos to study
Existence, last commit and README notices were checked on 22 Nov 2026 by shallow clone. Every repository below had a commit in the last six months. Archive status comes from the README, not from the GitHub setting, so look again before you rely on one.
| Repo | What to read | Week |
|---|---|---|
| OWASP/CheatSheetSeries | The SSRF, XSS and prototype pollution sheets, as a checklist | 13 |
| nodejs/undici | Agent and connect options, where address pinning goes | 13 |
| npm/cli | How npm ci, provenance and signature checks work | 14 |
| dubzzz/fast-check | Property-based testing: arbitraries and shrinking | 15 |
| pinojs/pino | A fast structured logger: read how it avoids blocking the loop | 16 |
Milestone checkpoint
Run Checkpoint 4. Build the attack table first and watch every row fail. Add the guard, the limits and the lockfile checks, then run the 10-minute load test at 200 requests a second against the targets. Add the SIGTERM test. Hand in the attack table, the load report, the runbook (what an on-call engineer does for a stall, a leak and a flood of bad hosts), ADR-6 (what the guard allows and what it rejects) and the upgrade memo (which Node line you run and when you move).
Check yourself
Answer each question in your head first, then open it to check.
Why is checking the hostname before the fetch not enough to stop SSRF?
DNS can return a different address at connect time, and a redirect can point inward. Check the resolved address at connect, and again on every redirect.What is prototype pollution, and what is one defence?
Merging untrusted keys such as__proto__changesObject.prototypefor the whole process. Reject those keys, useMaporObject.create(null), and validate input against a schema.What does
npm audit signaturestell you, and what does it not?It checks registry signatures and provenance attestations for installed packages. It does not tell you the code is safe or the maintainer trustworthy.In what order should a service shut down on
SIGTERM?Stop accepting new connections, finish in-flight work, close pools and connections, flush logs, then exit. Orchestrators usually sendSIGKILLafter a grace period.When do property tests beat example tests?
When a rule holds over a large input space, such as a parser that must round-trip, and you cannot list the interesting cases by hand.