Skip to content

Latest commit

 

History

History
12 lines (6 loc) · 450 Bytes

vulnerable-code-17.md

File metadata and controls

12 lines (6 loc) · 450 Bytes

SecurityExplained S-29: Vulnerable Code Snippet - 17

Vulnerable Code:

Vulnerable Code

Solution:

As per @SonarSource, isPrivileged() will always return true because casting an int to an int-based enum never throws an exception, even if there is no enum member corresponding to that number. To make the check correct, it has to return PrivRoles.IsDefined((PrivRoles) role).

Code Credits: SonarSource