- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试调用网络服务。此网络服务调用取决于用户输入的 URL。
URL 如下所示:
https://someurl.com/somefunction/{userinput}
我的函数是这样的
public async Task<Data> GetData(string input)
{
try
{
Address = BaseAddress; // https://someurl.com/somefunction/{userinput}
Address = Address.Replace("{userinput}", input);
....
WebService ws = await base.GetData(httpClient, serverIPaddress);
....
}
}
我从 Fortify 收到安全错误
Server-Side Request Forgery (Input Validation and Representation, Data Flow)
The function GetAsync() on line 122 initiates a network connection to a third-party system using user-controlled data for resource URI. An attacker may leverage this vulnerability to send a request on behalf of the application server since the request will originate from the application server's internal IP address.
建议如下:
建议:
Do not establish network connections based on user-controlled data and ensure that the request is being sent to the expected destination. If user data is necessary to build the destination URI, use a level of indirection: create a list of legitimate resource names that a user is allowed to specify, and only allow the user to select from the list. With this approach the input provided by the user is never used directly to specify the resource name.
In some situations this approach is impractical because the set of legitimate resource names is too large or too hard to keep track of. Programmers often resort to blacklisting in these situations. Blacklisting selectively rejects or escapes potentially dangerous characters before using the input. However, any such list of unsafe characters is likely to be incomplete and will almost certainly become out of date. A better approach is to create a whitelist of characters that are allowed to appear in the resource name and accept input composed exclusively of characters in the approved set.
Also, if required, make sure that the user input is only used to specify a resource on the target system but that the URI scheme, host, and port is controlled by the application. This way the damage that an attacker is able to do will be significantly reduced.
但问题是我确实需要根据用户提供的数据更改 {userinput}
。 {userinput}
将是一个具有特定最大长度的字符串。如何解决这个问题?
最佳答案
经过如此多的研究和尝试尝试,我终于通过将输入附加到 BaseAddress
示例代码看起来像
public async Task<Data> GetData(string input)
{
try
{
var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri($"https://someurl.com/somefunction/{input}");
var content = await httpClient.GetStringAsync("");
return JsonConvert.DeserializeObject<Data>(content);
}
}
关于c# - 服务器端请求伪造强化修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57158070/
我对 FakeItEasy(或其他模拟对象,因为我相信它们非常相似)有疑问。以下是我的 puesdocode: public class Service { public void Check
我想使用鼠标/键盘伪造操作(或触摸)事件。当我尝试使用以下方法引发事件时: RoutedEventArgs e = new RoutedEventArgs(ManipulationStartedEve
出于某种原因,我的 SVN 存储库的本地副本停止将父目录识别为工作副本。我通常会通过再次 checkout 到另一个文件夹并用我更改的文件覆盖新的工作副本来解决此问题。然后我会从新文件夹中进行提交。
我正在尝试设置我的开发实例,以便我可以伪造一些我拥有的网址。我的网站有许多网址,根据您访问的网址,我的网站的行为会因域的不同而有所不同。 我编辑了我的 C:\WINDOWS\system32\driv
当用户登录并选中“记住我”框时,我会为它生成一个 key (md5 上非常随机的数字)并保存在它的 cookie 上。如果用户未登录,我的代码会检查“记住我的 key ”cookie,如果它与用户匹配
有没有办法强制 Oracle 也“看到”一个表和相关索引比它们实际更大? 换句话说,有没有办法“伪造”数据库统计信息,因此基于成本的优化器会在几乎为空的数据库上做出决策,这更接近于在真实的大型生产数据
这是我使用 tsqlt 的第一天,所以你可能会看到一些含糊的陈述。 我正在尝试测试一个具有 Try Catch Block 的存储过程,但测试中的实际语句是插入和更新命令。 现在我想测试如果出现 Er
我从mockito开始,想知道如何假装添加观察者。我想编写一个测试来确保观察者计数在函数调用后增加。 示例测试代码: MyClassUnderTest instance = new MyClassUn
我是一名 C# 游戏开发人员,我有一个安全功能,我的服务器动态创建一个包含一些 key 的 DLL,并将这个 DLL 上传到 amazon s3,然后向人们提出挑战随机的。当客户收到此质询时,他们有
我正在尝试“伪造”一个 Canvas ,目的是将这个伪造的 Canvas 交给一个可能是任意的框架,以对所有直线、曲线和 moveTo 进行后处理。 为了解决这个问题,我尝试了这段代码,它确实有效,但
我的应用程序需要 SQL Server 2000 作为数据库存储。我真的不想使用 SQL Server 2000,但我可以改用 MySQL Server。 应用程序使用 ODBC 连接到 SQL Se
我有一个下拉菜单,需要一个带有左右边距的滚动条。我正在使用-webkit-scrollbar,但据我所知,它只支持沿滚动轴的边距,所以我一直在用容器内元素的右边距来近似水平边距,并在外部 div,如您
作为我学生小组业余项目的一部分,我正在创建微 Controller 有线网络的模拟,以测试我们编写的算法。每个 Controller 都连接到多个数据端口,每个端口都有一个输入和输出流。我通过给每个端
我已经在 Forge 中安装了自定义 SSL 证书。现在我的网站宕机了 -_-。 Site is not available connection refused 我已经重新启动了我的服务器,但没有任
我正在开发具有 ListView 和详细 View 的应用程序,并且我从 ListView 到详细 View 设置动画。在执行此操作时,我想在某个阶段隐藏状态栏(最好同时在后台显示 ListView
我想用它在 MS-Test 单元测试中伪造 System.Net.Mail.SmtpClient。为此,我添加了一个 System.dll 的 Fakes Assembmly。然后我创建一个 Shim
在我的 Playframework 2.4 项目中,我有这样的方法: public static Result resetValue(int client) { String received
这是我渲染场景的过程: 绑定(bind) MSAA x4 GBuffer(4 种颜色附件、位置、法线、颜色和无光照颜色(仅天空盒。我还有一个深度组件/纹理)。 绘制天空盒 绘制地理 将所有颜色和深度分
我不太确定 $_SESSION 在 PHP 中是如何工作的。我假设它是浏览器上的 cookie 与服务器上的唯一 key 匹配。是否可以伪造并绕过仅使用 session 来识别用户的登录。 如果 $_
大家好,我是沙漠尽头的狼。 本文首发于 Dotnet9 ,介绍使用 Lib.Harmony 库拦截第三方 .NET 库方法,达到不修改其源码并能实现修改方法逻辑、预期行为的效果,并
我是一名优秀的程序员,十分优秀!