I am facing a sensitive information exposed in VB.Net through the variable _requestedUri which results in Security issue CWE 201.
The variable contains the value like “/user/2052/question/2”, here the usage of absolute url “https://stackoverflow.com” is causing this security issue.
Dim httpWebRequest As HttpWebRequest = CType(WebRequest.Create(_requestedUri), HttpWebRequest)
httpWebRequest.Method = "POST"
httpWebRequest.ContentType = contentType
httpWebRequest.ContentLength = formData.Length
httpWebRequest.Credentials = CredentialCache.DefaultCredentials
Using requestStream As Stream = httpWebRequest.GetRequestStream()
requestStream.Write(formData, 0, formData.Length)
requestStream.Close()
End Using
Return CType(httpWebRequest.GetResponse(), HttpWebResponse)
I had tried using relative paths to create this HttpWebRequest instance but the operation requires an absolute url to create this instance.
Could you please guide me on how to assign this absolute url separtely in HttpWebRequest like the Base Address Property we use in HttpClient to assign absolute url and use relative path in Send Method?