c# - API 滥用 - 安全漏洞问题 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;
}
}
推荐阅读
- python - 使用 python 发布请求添加新设备时,数据包跟踪器网络控制器中出现错误 500
- firebase - @firebase/database: FIREBASE INTERNAL ERROR: Server Error: The specified payload is too large, please request a location with less data
- python - 制作具有透明像素的 .png 文件
- laravel - 如何在刀片模板中使用预加载 webpack 插件
- flutter - 无法打开设置文件的设置通用类缓存“
- modelica - 如何防止 Modelica 中不必要的事件检测?
- javascript - (承诺中)TypeError:无法读取 null 的属性“0”
- flutter - 将 3000 多张图片上传到 Firebase Storage Flutter
- python - 如何解决python中的IndexError
- django - 如果连续插入多个模型,如何在数据库中实现事务回滚?