Skip to content

Commit 0216617

Browse files
RafaelGSSmhdawsonfacutuescaUlisesGasconfraxken
committed
doc: add Node.js Threat Model
Co-authored-by: Michael Dawson <[email protected]> Co-authored-by: Facundo Tuesca <[email protected]> Co-authored-by: Ulises Gascon <[email protected]> Co-authored-by: Thomas Gentilhomme <[email protected]>
1 parent 5815e3e commit 0216617

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

SECURITY.md

+117
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,123 @@ Here is the security disclosure policy for Node.js
5353
the release process above to ensure that the disclosure is handled in a
5454
consistent manner.
5555

56+
## The Node.js threat model
57+
58+
Being able to cause a negative outcome in a way that requires control of the
59+
elements that are trusted by Node.js is not considered a vulnerability in
60+
Node.js.
61+
62+
Being able to cause the following through control of the elements that Node.js
63+
does not trust is considered a vulnerability:
64+
65+
* Disclosure or loss of integrity or confidentiality of data protected through
66+
the correct use of Node.js APIs.
67+
* The unavailability of the runtime, including the unbounded degradation of its
68+
performance.
69+
70+
If Node.js loads configuration files or runs code by default (without a
71+
specific request from the user), and this is not documented, it is considered a
72+
vulnerability.
73+
Vulnerabilities related to this case may be fixed by a documentation update.
74+
75+
**Node.js does NOT trust**
76+
77+
1. The data from network connections that are created through the use of Node.js
78+
APIs and which is transformed/validated by Node.js before being passed to the
79+
application. This includes:
80+
* HTTP APIs (all flavors) client and server APIs.
81+
* DNS APIs.
82+
2. Consumers of data protected through the use of Node.js APIs (for example
83+
people who have access to data encrypted through the Node.js crypto APIs).
84+
3. The file content or other I/O that is opened for reading or writing by the
85+
use of Node.js APIs (ex: stdin, stdout, stderr). In other words, if the
86+
content passing through Node.js to/from the application can trigger actions
87+
other than those documented for the APIs, the content is not trusted avoid
88+
causing those actions.
89+
90+
**Node.js trusts everything else**. As some examples this includes:
91+
92+
1. The developers and infrastructure that runs it.
93+
2. The operating system that Node.js is running under and its configuration,
94+
along with anything under control of the operating system.
95+
3. The code it is asked to run including JavaScript and native code, even if
96+
said code is dynamically loaded, e.g. all dependencies installed from the
97+
npm registry.
98+
The code run inherits all the privileges of the execution user.
99+
4. Inputs provided to it by the code it is asked to run, as it is the
100+
responsibility of the application to perform the required input validations.
101+
5. Any connection used for inspector (debugger protocol) regardless of being
102+
opened by command line options or Node.js APIs, and regardless of the remote
103+
end being on the local machine or remote.
104+
6. The file system when requiring a module.
105+
See <https://nodejs.org/api/modules.html#all-together>.
106+
107+
Any unexpected behavior from the data manipulation from Node.js Internal
108+
functions are considered a vulnerability.
109+
110+
In addition to addressing vulnerabilities based on the above, the project works
111+
to avoid APIs and internal implementations that make it “easy” for application
112+
code to use the APIs incorrectly in a way that results in vulnerabilities within
113+
the application code itself. While we don’t consider those vulnerabilities in
114+
Node.js itself and will not necessarily issue a CVE we do want them to be
115+
reported privately to Node.js first.
116+
We often choose to work to improve our APIs based on those reports and issue
117+
fixes either in regular or security releases depending on how much of a risk to
118+
the community they pose.
119+
120+
### Examples of vulneratibities
121+
122+
#### Improper Certificate Validation (CWE-295)
123+
124+
* Node.js provides APIs to validate handling of Subject Alternative Names (SANs)
125+
in certficates used to connect to an https endpoint. If certificates can be
126+
crafted which result in incorrect validation by the Node.js APIs that is
127+
considered a vulnerability.
128+
129+
#### Inconsistent Interpretation of HTTP Requests (CWE-444)
130+
131+
* Node.js provides APIs to accept http connections. Those APIs parse the
132+
headers received for a connection and pass them on to the application.
133+
Bugs in parsing those headers which can result in request smuggling are
134+
considered vulnerabilities.
135+
136+
#### Missing Cryptographic Step (CWE-325)
137+
138+
* Node.js provides APIs to encrypt data. Bugs that would allow an attacker
139+
to get the orginal data without requiring the encryption key are
140+
considered vulnerabilities.
141+
142+
#### External Control of System or Configuration Setting (CWE-15)
143+
144+
* If Node.js automatically loads a configuration file which is not documented
145+
and modification of that configuration can affect the confidentiality of
146+
data protected using the Node.js APIs this is considered a vulnerability.
147+
148+
### Examples of non-vulneratibities
149+
150+
#### Malicious Third-Party Modules (CWE-1357)
151+
152+
* Code is trusted by Node.js, therefore any scenario that requires a malicious
153+
third-party module cannot result in a vulnerability in Node.js.
154+
155+
#### Prototype Pollution Attacks (CWE-1321)
156+
157+
* Node.js trusts the inputs provided to it by application code.
158+
It is up to the application to sanitize appropriately, therefore any scenario
159+
that requires control over user input is not considered a vulnerability.
160+
161+
#### Uncontrolled Search Path Element (CWE-427)
162+
163+
* Node.js trusts the file system in the environment accessible to it.
164+
Therefore, it is not a vulnerability if it accesses/loads files from any path
165+
that is accessible to it.
166+
167+
#### External Control of System or Configuration Setting (CWE-15)
168+
169+
* If Node.js automatically loads a configuration file which is documented
170+
no scenario that requires modification of that configuration file is
171+
considered a vulnerability.
172+
56173
## Receiving security updates
57174

58175
Security notifications will be distributed via the following methods.

0 commit comments

Comments
 (0)