CRITICAL
Rule Definition
Many web applications do not properly protect sensitive data, such as credit cards, tax IDs, and authentication credentials. Attackers may steal or modify such weakly protected data to conduct credit card fraud, identity theft, or other crimes. Sensitive data deserves extra protection such as encryption at rest or in transit, as well as special precautions when exchanged with the browser.
To avoid connection to an unsecured source, you have to make sure that all HTTP communications are encrypted.
Remediation
Ensure you have enable Strict-Transport-Security header that enforces secure (HTTP over SSL/TLS) connections to the server.
Violation Code Sample
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send("<html><body>hello world<script type='text/javascript'>alert('got you')</script></body></html>");
});
app.listen(3000);
Fixed Code Sample
// with helmet : Helmet’s HSTS is a relatively simple middleware that will set the Strict-Transport-Security header.
import { Express } from '../../src/express'
var app = express();
import * as hsts from 'hsts'
app.use(hsts())
/or with helmet
import * as helmet from "helmet";
app.use(helmet());
// or more specifically
app.use(helmet.hsts());
app.get('/', function(req, res){
res.send("<html><body><p>hello world</p><script type='text/javascript'>alert('got you')</script></body><html>");
});
app.listen(3000);
Reference
https://expressjs.com/en/advanced/best-practice-security.html
https://www.owasp.org/index.php/Top_10_2013-A5-Security_Misconfiguration
https://www.owasp.org/index.php/Top_10-2017_A6-Security_Misconfiguration
Related Technologies
Technical Criterion
CWE-319 - Cleartext Transmission of Sensitive Information
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.