mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
Validate config dir path to resolve security warning (#611)
* Attempt to validate config path to resolve security warning * move above fullpath * make sure path does not reference parent dir
This commit is contained in:
parent
22c5d224bd
commit
db557e0b69
@ -1018,6 +1018,11 @@ func doShutdown(reason string) {
|
||||
|
||||
func configDirHandler(w http.ResponseWriter, r *http.Request) {
|
||||
configPath := r.URL.Path
|
||||
if !fs.ValidPath(configPath) && !strings.Contains(configPath, "..") {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(fmt.Sprintf("invalid path: %s", configPath)))
|
||||
return
|
||||
}
|
||||
configFullPath := path.Join(scbase.GetWaveHomeDir(), configPath)
|
||||
dirFile, err := os.Open(configFullPath)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user