53 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2020-06-30 12:50:28 +02:00
include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
In Express.js application the code is sensitive if the https://www.npmjs.com/package/dns-prefetch-control[dns-prefetch-control] middleware is disabled or used without the recommended value:
2020-06-30 12:50:28 +02:00
----
const express = require('express');
const helmet = require('helmet');
2020-06-30 12:50:28 +02:00
let app = express();
app.use(
helmet.dnsPrefetchControl({
allow: true // Sensitive: allowing DNS prefetching is security-sensitive
})
);
2020-06-30 12:50:28 +02:00
----
== Compliant Solution
2021-01-27 13:42:22 +01:00
In Express.js application the https://www.npmjs.com/package/dns-prefetch-control[dns-prefetch-control] or https://www.npmjs.com/package/helmet[helmet] middleware is the standard way to implement ``++X-DNS-Prefetch-Control++`` header:
2022-02-04 17:28:24 +01:00
[source,javascript]
2020-06-30 12:50:28 +02:00
----
const express = require('express');
const helmet = require('helmet');
2020-06-30 12:50:28 +02:00
let app = express();
app.use(
helmet.dnsPrefetchControl({
allow: false // Compliant
})
);
2020-06-30 12:50:28 +02:00
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
endif::env-github,rspecator-view[]