You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-81Lines changed: 36 additions & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,19 @@ ESLint rules for Node Security
6
6
7
7
This project will help identify potential security hotspots, but finds a lot of false positives which need triage by a human.
8
8
9
-
###Installation
9
+
## Installation
10
10
11
-
`npm install --save-dev eslint-plugin-security` or `yarn add eslint-plugin-security --dev`
11
+
```sh
12
+
npm install --save-dev eslint-plugin-security
13
+
```
14
+
15
+
or
16
+
17
+
```sh
18
+
yarn add --dev eslint-plugin-security
19
+
```
12
20
13
-
###Usage
21
+
## Usage
14
22
15
23
Add the following to your `.eslintrc` file:
16
24
@@ -31,86 +39,33 @@ Add the following to your `.eslintrc` file:
31
39
npm run-script cont-int
32
40
```
33
41
34
-
###Tests
42
+
## Tests
35
43
36
44
```sh
37
45
npm test
38
46
```
39
47
40
-
### Rules
41
-
42
-
#### `detect-unsafe-regex`
43
-
44
-
Locates potentially unsafe regular expressions, which may take a very long time to run, blocking the event loop.
45
-
46
-
More information: [Regular Expression DoS and Node.js](docs/regular-expression-dos-and-node.md)
47
-
48
-
#### `detect-buffer-noassert`
49
-
50
-
Detect calls to [`buffer`](https://nodejs.org/api/buffer.html) with `noAssert` flag set.
51
-
52
-
From the Node.js API docs: "Setting `noAssert` to true skips validation of the `offset`. This allows the `offset` to be beyond the end of the `Buffer`."
53
-
54
-
#### `detect-child-process`
55
-
56
-
Detect instances of [`child_process`](https://nodejs.org/api/child_process.html) & non-literal [`exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
57
-
58
-
More information: [Avoiding Command Injection in Node.js](docs/avoid-command-injection-node.md)
59
-
60
-
#### `detect-disable-mustache-escape`
61
-
62
-
Detects `object.escapeMarkup = false`, which can be used with some template engines to disable escaping of HTML entities. This can lead to Cross-Site Scripting (XSS) vulnerabilities.
63
-
64
-
More information: [OWASP XSS](<https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)>)
65
-
66
-
#### `detect-eval-with-expression`
67
-
68
-
Detects `eval(variable)` which can allow an attacker to run arbitrary code inside your process.
69
-
70
-
More information: [What are the security issues with eval in JavaScript?](http://security.stackexchange.com/questions/94017/what-are-the-security-issues-with-eval-in-javascript)
71
-
72
-
#### `detect-no-csrf-before-method-override`
73
-
74
-
Detects Express `csrf` middleware setup before `method-override` middleware. This can allow `GET` requests (which are not checked by `csrf`) to turn into `POST` requests later.
75
-
76
-
More information: [Bypass Connect CSRF protection by abusing methodOverride Middleware](docs/bypass-connect-csrf-protection-by-abusing.md)
77
-
78
-
#### `detect-non-literal-fs-filename`
79
-
80
-
Detects variable in filename argument of `fs` calls, which might allow an attacker to access anything on your system.
81
-
82
-
More information: [OWASP Path Traversal](https://www.owasp.org/index.php/Path_Traversal)
83
-
84
-
#### `detect-non-literal-regexp`
85
-
86
-
Detects `RegExp(variable)`, which might allow an attacker to DOS your server with a long-running regular expression.
87
-
88
-
More information: [Regular Expression DoS and Node.js](docs/regular-expression-dos-and-node.md)
89
-
90
-
#### `detect-non-literal-require`
91
-
92
-
Detects `require(variable)`, which might allow an attacker to load and run arbitrary code, or access arbitrary files on disk.
93
-
94
-
More information: [Where does Node.js and require look for modules?](http://www.bennadel.com/blog/2169-where-does-node-js-and-require-look-for-modules.htm)
95
-
96
-
#### `detect-object-injection`
97
-
98
-
Detects `variable[key]` as a left- or right-hand assignment operand.
99
-
100
-
More information: [The Dangers of Square Bracket Notation](docs/the-dangers-of-square-bracket-notation.md)
101
-
102
-
#### `detect-possible-timing-attacks`
103
-
104
-
Detects insecure comparisons (`==`, `!=`, `!==` and `===`), which check input sequentially.
105
-
106
-
More information: [A lesson in timing attacks](https://codahale.com/a-lesson-in-timing-attacks/)
107
-
108
-
#### `detect-pseudoRandomBytes`
109
-
110
-
Detects if `pseudoRandomBytes()` is in use, which might not give you the randomness you need and expect.
111
-
112
-
More information: [Randombytes vs pseudorandombytes](http://stackoverflow.com/questions/18130254/randombytes-vs-pseudorandombytes)
113
-
114
-
#### `detect-new-buffer`
115
-
116
-
Detect instances of new Buffer(argument) where argument is any non-literal value.
|[detect-disable-mustache-escape](docs/rules/detect-disable-mustache-escape.md)| Detects "object.escapeMarkup = false", which can be used with some template engines to disable escaping of HTML entities. | ✅ |
60
+
|[detect-eval-with-expression](docs/rules/detect-eval-with-expression.md)| Detects "eval(variable)" which can allow an attacker to run arbitrary code inside your process. | ✅ |
61
+
|[detect-new-buffer](docs/rules/detect-new-buffer.md)| Detects instances of new Buffer(argument) where argument is any non-literal value. | ✅ |
|[detect-non-literal-fs-filename](docs/rules/detect-non-literal-fs-filename.md)| Detects variable in filename argument of "fs" calls, which might allow an attacker to access anything on your system. | ✅ |
64
+
|[detect-non-literal-regexp](docs/rules/detect-non-literal-regexp.md)| Detects "RegExp(variable)", which might allow an attacker to DOS your server with a long-running regular expression. | ✅ |
65
+
|[detect-non-literal-require](docs/rules/detect-non-literal-require.md)| Detects "require(variable)", which might allow an attacker to load and run arbitrary code, or access arbitrary files on disk. | ✅ |
66
+
|[detect-object-injection](docs/rules/detect-object-injection.md)| Detects "variable[key]" as a left- or right-hand assignment operand. | ✅ |
67
+
|[detect-possible-timing-attacks](docs/rules/detect-possible-timing-attacks.md)| Detects insecure comparisons (`==`, `!=`, `!==` and `===`), which check input sequentially. | ✅ |
68
+
|[detect-pseudoRandomBytes](docs/rules/detect-pseudoRandomBytes.md)| Detects if "pseudoRandomBytes()" is in use, which might not give you the randomness you need and expect. | ✅ |
69
+
|[detect-unsafe-regex](docs/rules/detect-unsafe-regex.md)| Detects potentially unsafe regular expressions, which may take a very long time to run, blocking the event loop. | ✅ |
Copy file name to clipboardExpand all lines: docs/bypass-connect-csrf-protection-by-abusing.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ This issue was found and reported to us by [Luca Carettoni](http://twitter.com/_
8
8
9
9
Connect, methodOverride middleware
10
10
11
-
### Description:
11
+
### Description
12
12
13
13
**Connect's "methodOverride" middleware allows an HTTP request to override the method of the request with the value of the "\_method" post key or with the header "x-http-method-override".**
Connect's CSRF middleware does not check csrf tokens in case of idempotent verbs (GET/HEAD/OPTIONS, see lib/middleware/csrf.js). As a result, it is possible to bypass this security control by sending a GET request with a POST MethodOverride header or key.
27
27
28
-
### Example:
28
+
### Example
29
29
30
30
```sh
31
31
GET / HTTP/1.1
32
32
[..]
33
33
_method=POST
34
34
```
35
35
36
-
### Mitigation Factors:
36
+
### Mitigation Factors
37
37
38
38
Disable methodOverride or make sure that it takes precedence over other middleware declarations.
# Detects calls to "buffer" with "noAssert" flag set (`security/detect-buffer-noassert`)
2
+
3
+
⚠️ This rule _warns_ in the ✅ `recommended` config.
4
+
5
+
<!-- end auto-generated rule header -->
6
+
7
+
Detect calls to [`buffer`](https://nodejs.org/api/buffer.html) with `noAssert` flag set.
8
+
9
+
From the Node.js API docs: "Setting `noAssert` to true skips validation of the `offset`. This allows the `offset` to be beyond the end of the `Buffer`."
# Detects "object.escapeMarkup = false", which can be used with some template engines to disable escaping of HTML entities (`security/detect-disable-mustache-escape`)
2
+
3
+
⚠️ This rule _warns_ in the ✅ `recommended` config.
4
+
5
+
<!-- end auto-generated rule header -->
6
+
7
+
This can lead to Cross-Site Scripting (XSS) vulnerabilities.
8
+
9
+
More information: [OWASP XSS](<https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)>)
# Detects "eval(variable)" which can allow an attacker to run arbitrary code inside your process (`security/detect-eval-with-expression`)
2
+
3
+
⚠️ This rule _warns_ in the ✅ `recommended` config.
4
+
5
+
<!-- end auto-generated rule header -->
6
+
7
+
More information: [What are the security issues with eval in JavaScript?](http://security.stackexchange.com/questions/94017/what-are-the-security-issues-with-eval-in-javascript)
0 commit comments