
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
InputSanitizer is a filter used to clear all illegal strings from the data received by the API or MVC Controller.
It is based on HtmlSanitizer as an HTML-related cleaner, and also adds Regex pattern matching cleanup.
It supports data model binding in DTO mode and also supports dynamic types based on Json.
Add InputSanitize to ServiceCollection with policy in Program.cs
var policy = new InputSanitizerPolicy()
{
Name = "Default",
AllowedTags = new HashSet<string>(HtmlSanitizerDefaults.AllowedTags, StringComparer.OrdinalIgnoreCase),
AllowedSchemes = new HashSet<string>(HtmlSanitizerDefaults.AllowedSchemes, StringComparer.OrdinalIgnoreCase),
AllowedAttributes = new HashSet<string>(HtmlSanitizerDefaults.AllowedAttributes, StringComparer.OrdinalIgnoreCase),
UriAttributes = new HashSet<string>(HtmlSanitizerDefaults.UriAttributes, StringComparer.OrdinalIgnoreCase),
AllowedCssProperties = new HashSet<string>(HtmlSanitizerDefaults.AllowedCssProperties, StringComparer.OrdinalIgnoreCase),
AllowedAtRules = new HashSet<CssRuleType>(HtmlSanitizerDefaults.AllowedAtRules),
AllowedCssClasses = new HashSet<string>(HtmlSanitizerDefaults.AllowedClasses),
ExceptionMessage = "What are you doing?",
InvalidInputBehaviour = InvalidInputBehaviour.SetModelState
}
builder.Services.AddInputSanitizer(InputSanitizerPolicies.Policies);
Add To the Controller
[ApiController]
[Route("[controller]")]
[SanitizeAllInputFilter(PolicyName = "Default")] // this line HERE
public class WeatherForecastController : ControllerBase
{
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpPost(Name = "PostWeatherForecast")]
public IActionResult Post(DTOModel data) // OR public IActionResult Post(dynamic data)
{
if (!ModelState.IsValid)
{
return UnprocessableEntity(ModelState);
}
return Ok(data);
}
}
FAQs
Package Description
We found that inputsanitizer 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 flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.