Skip to content

Commit 4718bb0

Browse files
authored
Create a new 0.6.7-5 release (#2385)
* Verify FILESYSTEM_WRITE permission on copy() function (#2384) Also ensure client id is considered unsafe * Create a new 0.6.7-5 release
1 parent c6f11a7 commit 4718bb0

File tree

7 files changed

+31
-5
lines changed

7 files changed

+31
-5
lines changed

constants/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
)
2424

2525
const (
26-
VERSION = "0.6.7-4"
26+
VERSION = "0.6.7-5"
2727
ENROLLMENT_WELL_KNOWN_FLOW = "E:Enrol"
2828
MONITORING_WELL_KNOWN_FLOW = FLOW_PREFIX + "Monitoring"
2929

paths/constants.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ var (
2727
NOTEBOOK_ROOT = path_specs.NewSafeDatastorePath("notebooks").
2828
SetType(api.PATH_TYPE_DATASTORE_JSON)
2929

30-
DOWNLOADS_ROOT = path_specs.NewSafeFilestorePath("downloads").
30+
DOWNLOADS_ROOT = path_specs.NewUnsafeFilestorePath("downloads").
3131
SetType(api.PATH_TYPE_FILESTORE_DOWNLOAD_ZIP)
3232

33-
CLIENTS_ROOT = path_specs.NewSafeDatastorePath("clients").
33+
CLIENTS_ROOT = path_specs.NewUnsafeDatastorePath("clients").
3434
SetType(api.PATH_TYPE_DATASTORE_PROTO)
3535

3636
CONFIG_ROOT = path_specs.NewSafeDatastorePath("config").

services/indexing/simple.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (self *Indexer) CheckSimpleIndex(
7979
for _, keyword := range keywords {
8080
message := &emptypb.Empty{}
8181
keyword = strings.ToLower(keyword)
82-
subject := index_urn.AddChild(keyword, entity)
82+
subject := index_urn.AddUnsafeChild(keyword, entity)
8383
return db.GetSubject(config_obj, subject, message)
8484
}
8585
return errors.New("Client does not have label")

services/launcher/launcher.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ import (
138138
"www.velocidex.com/golang/velociraptor/logging"
139139
"www.velocidex.com/golang/velociraptor/paths"
140140
"www.velocidex.com/golang/velociraptor/services"
141+
"www.velocidex.com/golang/velociraptor/utils"
141142
vql_subsystem "www.velocidex.com/golang/velociraptor/vql"
142143
)
143144

@@ -539,6 +540,10 @@ func (self *Launcher) ScheduleArtifactCollectionFromCollectorArgs(
539540
return "", errors.New("Client id not provided.")
540541
}
541542

543+
if !utils.ValidateClientId(client_id) {
544+
return "", errors.New("Client id not valid.")
545+
}
546+
542547
db, err := datastore.GetDB(config_obj)
543548
if err != nil {
544549
return "", err

utils/clientid.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package utils
2+
3+
import "regexp"
4+
5+
var (
6+
// Client IDs always start with "C." or they can refer to the "server"
7+
client_id_regex = regexp.MustCompile("^(C\\.[a-z0-9]+|server)")
8+
)
9+
10+
func ValidateClientId(client_id string) bool {
11+
return client_id_regex.MatchString(client_id)
12+
}

vql/filesystem/copy.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525

2626
"github.com/Velocidex/ordereddict"
2727
"www.velocidex.com/golang/velociraptor/accessors"
28+
"www.velocidex.com/golang/velociraptor/acls"
2829
"www.velocidex.com/golang/velociraptor/artifacts"
2930
"www.velocidex.com/golang/velociraptor/utils"
3031
vql_subsystem "www.velocidex.com/golang/velociraptor/vql"
@@ -109,6 +110,14 @@ func (self *CopyFunction) Call(ctx context.Context,
109110
arg.Destination)
110111
}
111112

113+
// We are about to write on the filesystem - make sure the user
114+
// has write access.
115+
err = vql_subsystem.CheckAccess(scope, acls.FILESYSTEM_WRITE)
116+
if err != nil {
117+
scope.Log("copy: %s", err.Error())
118+
return vfilter.Null{}
119+
}
120+
112121
flags := os.O_RDWR | os.O_CREATE | os.O_TRUNC
113122
if arg.Append {
114123
flags = os.O_WRONLY | os.O_APPEND

vql/server/compress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (self *Compress) Call(ctx context.Context,
4242
scope vfilter.Scope,
4343
args *ordereddict.Dict) vfilter.Any {
4444

45-
err := vql_subsystem.CheckAccess(scope, acls.FILESYSTEM_WRITE)
45+
err := vql_subsystem.CheckAccess(scope, acls.FILESYSTEM_WRITE, acls.FILESYSTEM_READ)
4646
if err != nil {
4747
scope.Log("compress: %v", err)
4848
return vfilter.Null{}

0 commit comments

Comments
 (0)