Angular Unsafe Property Binding
Description
Property bindings like [innerHTML] and [src] with untrusted data enable XSS attacks when Angular's sanitizer is bypassed or insufficient.
What Shoulder detects
How to fix
Use DOMPurify to sanitize content before binding to innerHTML.
```typescript
import DOMPurify from 'dompurify';
export class UserProfileComponent {
get sanitizedBio(): string {
return DOMPurify.sanitize(this.userBio, {
ALLOWED_TAGS: ['p', 'br', 'strong', 'em'],
ALLOWED_ATTR: []
});
}
}
```
Learn more: https://shoulder.dev/learn/typescript/cwe-79/unsafe-property-binding
Applies to
Languages
References
Scan for this issue
Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=angular-unsafe-property-binding .
Real-world examples
Known CVEs in the Cross-Site Scripting (XSS) vulnerability class that this rule helps detect.