Skip to content

Commit 2e796c7

Browse files
fix: avoid path traversal
Signed-off-by: Ricky Moorhouse <[email protected]>
1 parent 5304884 commit 2e796c7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

exporter.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"nets/manager"
1616
"os"
1717
"path/filepath"
18+
"strings"
1819
"time"
1920

2021
"github.com/IBM/alchemy-logging/src/go/alog"
@@ -69,7 +70,11 @@ func ReadConfig() Config {
6970
}
7071

7172
log.Log(alog.INFO, "Loading config from %s ", config_path)
72-
73+
74+
// Block paths starting with '/' or containing '..'
75+
if strings.Contains(config_path, "..") {
76+
log.Log(alog.ERROR, "invalid config path: %s", config_path)
77+
}
7378
// Open YAML file
7479
file, err := os.Open(filepath.Clean(config_path))
7580
if err != nil {

0 commit comments

Comments
 (0)