NShiftKey-Rule-Guide logo NShiftKey-Rule-Guide

1. Vulnerability Description

$ wget -O trace.out http://localhost:8080/debug/pprof/trace
$ go tool trace trace.out

1

2. Vulnerability Countermeasure

3. Sample Code

Vulnerable Code

package main

import (
	"fmt"
	"log"
	"net/http"
	_ "net/http/pprof" // it's dangerous.
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "Hello World!")
	})
	log.Fatal(http.ListenAndServe(":8080", nil))
}
/debug/pprof/profile: 30-second CPU profile
/debug/pprof/heap: heap profile
/debug/pprof/goroutine?debug=1: all goroutines with stack traces
/debug/pprof/trace: take a trace