Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
express-sanitized-escaped
Advanced tools
Express middleware for the sanitizer module using Caja's HTML Sanitizer and HTML escape using htmlencode. Forked from express-sanitize-escape as the original package is no longer maintained
npm install express-sanitize-escape
Place this directly after all express.use(bodyParser) middlewares and before any express middleware that accesses query or body parameters, e.g.:
var bodyParser = require('body-parser');
var express = require('express');
var expressSanitized = require('express-sanitize-escape');
app.use(bodyParser.urlencoded);
app.use(bodyParser.json);
app.use(expressSanitized.middleware()); // this line follows app.use(bodyParser.json) or the last body parser middleware
The above sanitizes req.body
and req.query
. In order to sanitize req.params
as well, pass in an express router or app to expressSanitized.sanitizeParams
,
along with the names of the params to sanitize, e.g.:
var express = require('express');
var expressSanitized = require('express-sanitize-escape');
var router = express.router();
expressSanitized.sanitizeParams(router, ['id','name']);
router.get('/:id', function(req, res, next)
{
// req.params.id is now sanitized.
...
});
router.get('/:name', function(req, res, next)
{
// req.params.name is now sanitized.
...
});
The string
'<script>document.write('cookie monster')</script> download now'
will be sanitized to ' download now'.
and
< > ' " &
will be escaped to < > ' " &
This is a basic implementation of Caja-HTML-Sanitizer with the specific purpose of mitigating against persistent XSS risks. And node-htmlencode to escape all html entities
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.
This module was inspired by express-sanitizer and express-sanitized. The difference here is: This middleware automatically sanitizes post and query values parameter. And automatically html escapes all strings.
exports.middleware so app.use(expressSanitized())
is now app.use(expressSanitized.middleware())
expressSanitized.htmlDecodeBody()
Copyright (c) 2016 Finger Food Studios justin@fingerfoodstudios.com, MIT License
FAQs
Express middleware for the sanitizer module using Caja's HTML Sanitizer and HTML escape using htmlencode. Forked from express-sanitize-escape as the original package is no longer maintained
We found that express-sanitized-escaped 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.