API滥用-安全漏洞问题MVC APP

API Abuse- Security Vulnerability Issue MVC APP

Fortify 的工具报告了以下代码的“API 滥用 - 批量分配:不安全的 Binder 配置” 感谢有人帮助我识别了以下代码中的安全漏洞下面的代码。下面的代码用于在全局上下文中创建应用程序会话,我们是否有任何其他最佳方法来实现与 OWASP 标准相同的会话

public class SessionKeys
{
    public const string AppHistory = "my_History ";       
}

public class AppSession : IAppSession
{
    public AppHistoryViewModel AppHistory 
    {
        get
        {
            AppHistoryViewModel appHistory  = null;

            if ((HttpContext.Current != null) && (HttpContext.Current.Session[SessionKeys.AppHistory] != null))
            {
                appHistory  = HttpContext.Current.Session[SessionKeys.AppHistory] as AppHistoryViewModel;
            }

            return appHistory;   
        }
        set
        {
            if (HttpContext.Current != null)
            {
                HttpContext.Current.Session[SessionKeys.AppHistory] = value;
            }
        }
    }
}

[UserProfileAuthorizationFilter(Order = 0)]
public class MyController : BaseController
{
    #region Setter Injection

    private IAppSession _appSession;

    public IAppSession AppSession
    {
        get { return _appSession ?? (_appSession = new AppSession()); }
        set
        {
            if (_appSession == null)
            {
                _appSession = value;
            }
        }
    }

    #endregion
}

谢谢!!

从 AppHistoryViewModel 中删除 setter 属性 后它起作用了。

我从代码中删除了以下几行,我在 sonarQube 报告中看不到漏洞

 set
        {
            if (HttpContext.Current != null)
            {
                HttpContext.Current.Session[SessionKeys.AppHistory] = value;
            }
        }