How to Check HTML Text for SSRF Threats in Go

Cloudmersive
1 min readJun 25, 2021

--

Cyber attacks are becoming more frequent and varied in nature, and server-side request forgery is another type of threat that is beyond your standard computer virus. These threats occur when a malicious user attempts to access unsafe local or network paths in a server environment. To protect your server from these attacks happening via HTML injection, you can use the following API in Go to scan your HTML text.

In order to call the function, you will need to add your HTML text input request and API key into the below example code:

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/validate/text-input/html/check/ssrf"
method := "POST"
payload := strings.NewReader(`"<string>"`)client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

With this added layer of protection to complement your basic anti-virus software, you will be able to provide superior security for yourself, your business, and your users.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet