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
<ahref="https://helmetjs.github.io/">Helmet</a> is a collection of middleware functions for securing Express apps. It sets various HTTP headers to guard against common web vulnerabilities.
6
+
7
+
This query detects Helmet misconfigurations that can lead to security vulnerabilities, specifically:
8
+
9
+
<ul>
10
+
<li>Disabling frame protection</li>
11
+
<li>Disabling Content Security Policy</li>
12
+
</ul>
13
+
14
+
Content Security Policy (CSP) helps spot and prevent injection attacks such as Cross-Site Scripting (XSS).
15
+
16
+
Removing frame protections exposes an application to attacks such as clickjacking, where an attacker can trick a user into clicking on a button or link on a targeted page when they intended to click on the page carrying out the attack.
17
+
</p>
18
+
</overview>
19
+
<recommendation>
20
+
<p>
21
+
To help mitigate these vulnerabilities, ensure that the following Helmet functions are not disabled, and are configured appropriately to your application:
22
+
<ul>
23
+
<li><code>frameguard</code></li>
24
+
<li><code>contentSecurityPolicy</code></li>
25
+
</ul>
26
+
</p>
27
+
</recommendation>
28
+
<example>
29
+
<p>
30
+
The following code snippet demonstrates Helmet configured in an insecure manner:
31
+
<codeclass="language-javascript">
32
+
const helmet = require('helmet');
33
+
app.use(helmet({
34
+
frameguard: false,
35
+
contentSecurityPolicy: false
36
+
}));
37
+
</code>
38
+
</p>
39
+
<p>
40
+
In this example, the defaults are used, which enables frame protection and a default Content Security Policy.
41
+
42
+
<codeclass="language-javascript">
43
+
app.use(helmet());
44
+
</code>
45
+
46
+
You can also enable a custom Content Security Policy by passing an object to the <code>contentSecurityPolicy</code> key. For example, taken from the <ahref="https://helmetjs.github.io/#content-security-policy">Helmet docs:
* @name Insecure configuration of Helmet security middleware
3
+
* @description The Helmet middleware is used to set security-related HTTP headers in Express applications. This query finds instances where the middleware is configured with important security features disabled.
0 commit comments