Skip to content

Latest commit

 

History

History
13 lines (7 loc) · 564 Bytes

vulnerable-code-17.md

File metadata and controls

13 lines (7 loc) · 564 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

Follow Twitter Thread