无法修复Microservices体系结构中使用API网关模式时出现的veracode cwe id 918缺陷(SSRF)
社区首页
>
问答首页
>
无法修复Microservices体系结构中使用API网关模式时出现的veracode cwe id 918缺陷(SSRF)
问
无法修复Microservices体系结构中使用API网关模式时出现的veracode cwe id 918缺陷(SSRF)
EN
Stack Overflow用户
提问于
2020-06-13 11:10:43
回答 1
查看 2.7K
关注 0
票数 3
我在一个
Micro services
体系结构中使用
Micro services
,在这个体系结构中,
Front End Angular app
为我的
API Gateway
项目创建了一个
HTTP request
,这是一个简单的
ASP.net Core 3.1 Web API
项目。目前我只有两个
micro services
和一个
API Gateway
,它们都是
ASP.net Core 3.1 Web API
项目的类型。
API Gateway
项目拥有我的
micro services
的所有控制器。
API Gateway
的目的仅仅是接收来自
Front end
的请求,并将
HTTP Request
发送到适当的
Micro service
。
现在,在我的
AccountController.cs
的
API Gateway
项目中,我有以下代码
/// <summary>
/// Gets the detail of an account by its id
/// </summary>
/// <param name="organizationId">Id of the Organization of which the account belongs to</param>
/// <param name="accountId">Id of Account of which information is being requested</param>
/// <returns>Account's Details</returns>
[HttpGet("{organizationId}/{accountId}")]
public async Task<IActionResult> GetAccountAsync(Guid organizationId, Guid accountId)
_uri = new Uri(uriString: $"{_configurationService.AccountAPI}GetAccount/{organizationId}/{accountId}");
using var result = await _client.GetAsync(_uri);
var content = await result.Content.ReadAsStringAsync();
return Ok(content.AsObject<MessageResponse<AccountDetailVM>>());
}
/// <summary>
/// Gets the detail of an account by its id
/// </summary>
/// <param name="organizationId">Id of the Organization of which the account belongs to</param>
/// <param name="accountId">Id of Account of which information is being requested</param>
/// <returns>Account's Details</returns>
[HttpGet("{organizationId}/{accountId}")]
public async Task<IActionResult> GetAccountAsync(Guid organizationId, Guid accountId)
if (organizationId != Guid.Empty && accountId != Guid.Empty)
string url = HttpUtility.UrlEncode($"{_configurationService.AccountAPI}GetAccount/{organizationId}/{accountId}");
using var result = await _client.GetAsync(url);
var content = await result.Content.ReadAsStringAsync();
return Ok(content.AsObject<MessageResponse<AccountDetailVM>>());
return BadRequest();
}
/// <summary>
/// Gets the detail of an account by its id
/// </summary>
/// <param name="organizationId">Id of the Organization of which the account belongs to</param>
/// <param name="accountId">Id of Account of which information is being requested</param>
/// <returns>Account's Details</returns>
[HttpGet("{organizationId}/{accountId}")]
public async Task<IActionResult> GetAccountAsync(Guid organizationId, Guid accountId)
if (organizationId != Guid.Empty && accountId != Guid.Empty)
var httpClient = new HttpClient();
//Appended the parameters in base address to
//to fix veracode flaw issue
httpClient.BaseAddress = new Uri($"{_configurationService.AccountAPI}GetAccount/{organizationId}/{accountId}");
//passing empty string in GetStringAsync to make sure
//veracode doesn't treat it like modifying url
var content = await httpClient.GetStringAsync("");