mirror of
https://github.com/alist-org/alist.git
synced 2026-07-21 21:14:07 +08:00
Merge pull request #9566 from orbisai0security/fix-v-001-sanitize-filepath-metacharacters
fix: sanitize shell/subprocess call in util.go
This commit is contained in:
commit
cdeed27412
@ -49,6 +49,9 @@ func sanitizeFilePath(path string) (string, error) {
|
||||
if !filepath.IsAbs(cleaned) {
|
||||
return "", fmt.Errorf("file path must be absolute: %s", path)
|
||||
}
|
||||
if strings.ContainsAny(cleaned, ";&|`$<>!\n\r\x00") {
|
||||
return "", fmt.Errorf("file path contains invalid characters: %s", path)
|
||||
}
|
||||
info, err := os.Stat(cleaned)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("file path is not accessible: %w", err)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user