CodeQL tool throws the error "Uncontrolled format string" for the below code where string.Format used,
Detailed error - Passing untrusted format strings from remote data sources can throw exceptions and cause a denial of service.
public async Task<T> GetMethod<T>(string link, params object[] args)
{
using (var client = CreateClient())
{
// Getting vulnerability error "Uncontrolled format string" for below line
var response = await client.GetAsync(string.Format(link, args));
In GetAsync, the arguments will be appended with target link (url).
Example call,
GetMethod("http://baseaddress/directory?id={0}", "123");
How to overcome this issue ?