Skip to content
engineering workbench.by StudyPort Academy
Learning path
Real-World18 min

Dependency and supply-chain security

Understand the idea

The package in node_modules is code your process runs. An old version is your bug.

The idea

When your handler calls a function from a dependency, that function's source is on the call stack next to yours, including next to an check that is otherwise correct. If the installed version is the one before a fix, the bug is reachable by whatever request reaches that function. Prototype pollution in an old object-merge, a path traversal in an old static-file helper, a query operator smuggled through an old parser: the advisory is a description of code you are running. The run compares 4.17.15 with the fixed line 4.17.21. Below means vulnerable. Equal means the fix is present. A lockfile records the tarball you installed, so a later install does not silently move. A supply-chain incident is the same mechanism with a meaner edit: the tarball changed and your process will run the new bytes. Review lockfile diffs. Do not treat a green test suite as a review of those bytes, because the tests often never call the poisoned function.

What changes

What you are actually shipping
What went outHow it becomes an attackWhat changes the outcome
A version below the fixRequests reach the unfixed functionInstall the fixed release and keep the lockfile
A lockfile that driftedThe next install runs different bytes than you readReview the diff. Do not regenerate it blindly.
A script that runs on installInstall time executes it on your machine and in CIRead the lifecycle scripts before you accept the package

The command

Below the fix, and on the fix

3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.

The mistake

Check the result

old is true for 4.17.15. fixed is false for 4.17.21, meaning that version is not below the fix. The last line is the point: your process runs that code.

Guided challenge

Compare against the fixed release

The fixed line is currently 4.17.0, so 4.17.15 is treated as already safe. Compare with 4.17.21 so the old version still reports vulnerable.

Compare against the fixed release

3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.

EXPECTED RESULT

old true
fixed false

Hints 0/2

    Use all hints or make 3 failed checks (0/3).

    Free exploration

    Change this example and run it again. Each run is a new process. Nothing is saved.

    Your variation

    3s timeout · one stateless run. Node and Express use Piston when that instance accepts the job (public EMKC execute is whitelist-only; set PISTON_URL or PISTON_TOKEN). Otherwise a local Node process. MongoDB uses a fresh in-memory server per run, then it is stopped.

    Quiz

    A quick check for understanding. Retry as often as you like; your learning path stays open.

    01Why is an old dependency your vulnerability?
    02What does the fixed version change?

    Ready to call this one understood?

    Mark this lesson complete to earn 200 XP. You can always revisit it.

    Sign in to save progress
    Next lesson