Получение предупреждения в точке доступа безопасности в SonarQube, убедитесь, что здесь безопасно контролируется

    ClaimsPrincipal principal = new ClaimsPrincipal(identity);
    

Контроль разрешений чувствителен к безопасности. В прошлом это приводило к следующим уязвимостям:

 CVE-2018-12999
 CVE-2018-10285
 CVE-2017-7455

а предложение такое. class SecurityPrincipalDemo { class MyIdentity : IIdentity // Необходимо проверить конфиденциальные пользовательские реализации IIdentity { // ... }

class MyPrincipal : IPrincipal // Sensitive, custom IPrincipal implementations should be reviewed
{
    // ...
}
[System.Security.Permissions.PrincipalPermission(SecurityAction.Demand, Role = "Administrators")] // Sensitive. The access restrictions enforced by this attribute should be reviewed.
static void CheckAdministrator()
{
    WindowsIdentity MyIdentity = WindowsIdentity.GetCurrent(); // Sensitive
    HttpContext.User = ...; // Sensitive: review all reference (set and get) to System.Web HttpContext.User
    AppDomain domain = AppDomain.CurrentDomain;
    domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); // Sensitive
    MyIdentity identity = new MyIdentity(); // Sensitive
    MyPrincipal MyPrincipal = new MyPrincipal(MyIdentity); // Sensitive
    Thread.CurrentPrincipal = MyPrincipal; // Sensitive
    domain.SetThreadPrincipal(MyPrincipal); // Sensitive

    // All instantiation of PrincipalPermission should be reviewed.
    PrincipalPermission principalPerm = new PrincipalPermission(null, "Administrators"); // Sensitive
    principalPerm.Demand();

    SecurityTokenHandler handler = ...;
    // Sensitive: this creates an identity.
    ReadOnlyCollection<ClaimsIdentity> identities = handler.ValidateToken(…);
}

 // Sensitive: review how this function uses the identity and principal.
void modifyPrincipal(MyIdentity identity, MyPrincipal principal)
{
    // ...
}

}


person jr dones    schedule 26.01.2021    source источник


Ответы (1)


неважно. я понял это, сделав приват только для чтения

person jr dones    schedule 26.01.2021