
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
express-sanitizer
Advanced tools
Notice: The primary dependency for this library hasn't been updated in 5 years. Before using this library, consider other options such as express-validator.
An express middleware for Caja-HTML-Sanitizer, which wraps Google Caja sanitizer.
A useful complement to the express-validator -- to fill a gap now that XSS sanitization support has been removed from that module's parent node-validator.
yarn add express-sanitizer
or
npm install --save express-sanitizer
Import the module
const expressSanitizer = require('express-sanitizer');
Mount the middleware below the express.json()
(or, prior to express v4.16, bodyParser()
) instantiation and above mounting of your routes
app.use(express.json());
// Mount express-sanitizer middleware here
app.use(expressSanitizer());
app.post('/', function(req, res, next) {
// replace an HTTP posted body property with the sanitized string
const sanitizedString = req.sanitize(req.body.propertyToSanitize);
// send the response -- res.body.sanitized = " world"
res.send({ sanitized: sanitizedString });
});
The string
'<script>hello</script> world'
will be sanitized to ' world'.
This is a basic implementation of Caja-HTML-Sanitizer with the specific purpose of mitigating against persistent XSS risks (note the borderline abandonware comments in that repo!).
This module trusts the dependencies to provide basic persistent XSS risk mitigation. A user of this package should review all packages and make their own decision on security and fitness for purpose.
Copyright (c) 2021 Mark Andrews 20metresbelow@gmail.com, MIT License
FAQs
Express middleware for the sanitizer module.
The npm package express-sanitizer receives a total of 4,405 weekly downloads. As such, express-sanitizer popularity was classified as popular.
We found that express-sanitizer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.