Skip to content

Commit

Permalink
Fixing malicious source
Browse files Browse the repository at this point in the history
Signed-off-by: Ben <[email protected]>
  • Loading branch information
slashben committed Feb 23, 2025
1 parent 5c67c17 commit c92fdb0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion pkg/ruleengine/v1/r1000_exec_from_malicious_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,21 @@ func (rule *R1000ExecFromMaliciousSource) ID() string {
return R1000ID
}

func (rule *R1000ExecFromMaliciousSource) ProcessEvent(eventType utils.EventType, event utils.K8sEvent, _ objectcache.ObjectCache) ruleengine.RuleFailure {
var whitelistedProcessesForMaliciousSource = []string{
"systemd",
"docker",
"containerd",
"snap-confine",
"nginx",
"apache2",
"bash",
"dash",
"sh",
"perl",
"supervisord",
}

func (rule *R1000ExecFromMaliciousSource) ProcessEvent(eventType utils.EventType, event utils.K8sEvent, objCache objectcache.ObjectCache) ruleengine.RuleFailure {
if eventType != utils.ExecveEventType {
return nil
}
Expand All @@ -61,6 +75,16 @@ func (rule *R1000ExecFromMaliciousSource) ProcessEvent(eventType utils.EventType

var maliciousExecPathPrefixes = []string{
"/dev/shm",
"/proc/self/fd",
}

if objCache == nil {
// Running without object cache, to avoid false positives check if the process name is legitimate
for _, processName := range whitelistedProcessesForMaliciousSource {
if processName == execEvent.Comm {
return nil
}
}
}

execPath := GetExecFullPathFromEvent(execEvent)
Expand Down

0 comments on commit c92fdb0

Please sign in to comment.