no-angular-bypass-security-trust-html
Disallow Angular bypassSecurityTrustHtml usage that marks unvalidated HTML as trusted.
Targeted pattern scopeโ
Angular DomSanitizer bypass APIs for HTML trust.
What this rule reportsโ
Calls to bypassSecurityTrustHtml(...).
Why this rule existsโ
Bypassing Angular sanitization for HTML can introduce XSS if values are not strictly validated.
โ Incorrectโ
const trusted = sanitizer.bypassSecurityTrustHtml(userHtml);
โ Correctโ
const trusted = sanitizer.sanitize(SecurityContext.HTML, userHtml);
ESLint flat config exampleโ
import sdl from "eslint-plugin-sdl-2";
export default [
{
plugins: { sdl },
rules: {
"sdl/no-angular-bypass-security-trust-html": "error",
},
},
];
When not to use itโ
Disable only if a reviewed framework boundary must return trusted HTML and the source is strictly validated before trust conversion.
Package documentationโ
Further readingโ
Rule catalog ID: R028