Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve Heap inspection vulnerability for MVC viewmodel?

Checkmarx reported a Heap inspection vulnerability regarding having a string for a Password property. This property is part of a model, which gets bound when submitting a login form. Is there a way in ASP.NET MVC to use anything else other than regular string to bind password from the form?

So far I have tried changing the property type to char [] or SecureString, but in that case the form doesn't bind the data to it.

public class LoginModel
{
    [Required]
    [Display(Name = "User name")]
    public string UserName { get; set; }

    [Required]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }

    [Display(Name = "Remember me?")]
    public bool RememberMe { get; set; }
}
like image 728
Dasha Finch Avatar asked Oct 29 '22 16:10

Dasha Finch


1 Answers

Rename password field to something else... like "alienSecurity" and that's it CheckMarx will not able to catch it :)

like image 97
Rushikesh Joshi Avatar answered Nov 15 '22 04:11

Rushikesh Joshi