Skip to content

Commit 4dc88ed

Browse files
committed
fixup! docs: update security best practices for current threat model
1 parent 07dc2d5 commit 4dc88ed

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

apps/site/pages/en/learn/getting-started/security-best-practices.md

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ guidelines on how to secure a Node.js application.
2727
## Threat List
2828

2929
The Node.js [threat model][] defines what is or is not considered a
30-
*vulnerability in Node.js itself*. Some of the topics below are not
30+
_vulnerability in Node.js itself_. Some of the topics below are not
3131
vulnerabilities in Node.js core according to that model, but they are still
32-
important *application-level* threats that you should account for when building
32+
important _application-level_ threats that you should account for when building
3333
and operating Node.js software.
3434

3535
### Denial of Service of HTTP server (CWE-400)
@@ -198,7 +198,7 @@ According to the Node.js [threat model][], scenarios that require a malicious
198198
third-party module are **not** considered vulnerabilities in Node.js core,
199199
because Node.js treats the code it is asked to run (including dependencies)
200200
as trusted. However, malicious or compromised dependencies remain one of the
201-
most critical *application-level* risks for Node.js users and should be
201+
most critical _application-level_ risks for Node.js users and should be
202202
treated as such.
203203

204204
Currently, in Node.js, any package can access powerful resources such as
@@ -416,27 +416,11 @@ Assuming the following directory structure:
416416
If server.js uses `require('./auth')` it will follow the module resolution
417417
algorithm and load _auth_ instead of _auth.js_.
418418

419-
**Mitigations**
420-
421-
Using the [policy mechanism with integrity checking][] can avoid the above
422-
threat. Configure a policy manifest that:
423-
424-
- Pins the expected integrity of the modules your application should load.
425-
- Maps resolution of dependencies (for example, ensuring `./auth` resolves to
426-
the exact `auth.js` file you expect).
427-
428-
With such a policy enabled, attempts to load unexpected files or files whose
429-
content has changed will fail integrity checks instead of being silently
430-
accepted.
431-
432-
Note, it's always recommended the use of `--policy-integrity` to avoid policy mutations.
433-
434419
## Node.js Permission Model
435420

436421
Node.js provides a **permission model**
437422
that can be used to restrict what a given process is allowed to do at runtime.
438-
This model complements the Node.js [threat model][] and the policy mechanism
439-
described above by enforcing least-privilege at the runtime level.
423+
This model complements the Node.js [threat model][].
440424

441425
When enabled (for example, using the `--permission` flag), the
442426
permission model lets you selectively allow or deny access to sensitive
@@ -452,7 +436,7 @@ untrusted configuration, or unexpected behavior in your own code, since even
452436
trusted code will be prevented from performing actions outside the permissions
453437
you have explicitly granted.
454438

455-
Refer to the Node.js permissions documentation for up-to-date flags and
439+
Refer to the [Node.js permissions documentation][] for up-to-date flags and
456440
options.
457441

458442
## Experimental Features in Production
@@ -484,6 +468,7 @@ You can also collaborate with other projects and security experts through the [O
484468
[unpublish the package]: https://docs.npmjs.com/unpublishing-packages-from-the-registry
485469
[CWE-444]: https://cwe.mitre.org/data/definitions/444.html
486470
[RFC7230]: https://datatracker.ietf.org/doc/html/rfc7230#section-3
471+
[Node.js permissions documentation]: https://nodejs.org/api/permissions.html#permission-model
487472
[policy mechanism]: https://nodejs.org/api/permissions.html#policies
488473
[typosquatting]: https://en.wikipedia.org/wiki/Typosquatting
489474
[Mitigations for lockfile poisoning]: https://blog.ulisesgascon.com/lockfile-posioned
@@ -496,7 +481,6 @@ You can also collaborate with other projects and security experts through the [O
496481
[CVE-2018-16487]: https://www.cve.org/CVERecord?id=CVE-2018-16487
497482
[scrypt]: https://nodejs.org/api/crypto.html#cryptoscryptpassword-salt-keylen-options-callback
498483
[Module Resolution Algorithm]: https://nodejs.org/api/modules.html#modules_all_together
499-
[policy mechanism with integrity checking]: https://nodejs.org/api/permissions.html#integrity-checks
500484
[experimental-features]: #experimental-features-in-production
501485
[`Socket`]: https://socket.dev/
502486
[OpenSSF]: https://openssf.org/

0 commit comments

Comments
 (0)