Skip to content

Commit 8e7ea63

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 8e7ea63

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

SECURITY.md

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

58184
Security notifications will be distributed via the following methods.

0 commit comments

Comments
 (0)