Skip to content

Commit 11ee728

Browse files
committed
Removing detection by syscall
Signed-off-by: Amit Schendel <[email protected]>
1 parent 3ef0958 commit 11ee728

File tree

1 file changed

+3
-48
lines changed

1 file changed

+3
-48
lines changed

pkg/ruleengine/v1/r1005_fileless_execution.go

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"github.com/kubescape/node-agent/pkg/ruleengine"
1010
"github.com/kubescape/node-agent/pkg/utils"
1111

12-
ruleenginetypes "github.com/kubescape/node-agent/pkg/ruleengine/types"
13-
1412
apitypes "github.com/armosec/armoapi-go/armotypes"
1513
tracerexectype "github.com/inspektor-gadget/inspektor-gadget/pkg/gadgets/trace/exec/types"
1614
)
@@ -24,11 +22,10 @@ var R1005FilelessExecutionRuleDescriptor = RuleDescriptor{
2422
ID: R1005ID,
2523
Name: R1005Name,
2624
Description: "Detecting Fileless Execution",
27-
Tags: []string{"syscall", "fileless", "execution"},
25+
Tags: []string{"fileless", "execution"},
2826
Priority: RulePriorityHigh,
2927
Requirements: &RuleRequirements{
3028
EventTypes: []utils.EventType{
31-
utils.SyscallEventType,
3229
utils.ExecveEventType,
3330
},
3431
},
@@ -41,11 +38,10 @@ var _ ruleengine.RuleEvaluator = (*R1005FilelessExecution)(nil)
4138

4239
type R1005FilelessExecution struct {
4340
BaseRule
44-
alreadyNotified bool
4541
}
4642

4743
func CreateRuleR1005FilelessExecution() *R1005FilelessExecution {
48-
return &R1005FilelessExecution{alreadyNotified: false}
44+
return &R1005FilelessExecution{}
4945
}
5046

5147
func (rule *R1005FilelessExecution) Name() string {
@@ -59,54 +55,13 @@ func (rule *R1005FilelessExecution) DeleteRule() {
5955
}
6056

6157
func (rule *R1005FilelessExecution) ProcessEvent(eventType utils.EventType, event interface{}, _ objectcache.ObjectCache) ruleengine.RuleFailure {
62-
if eventType == utils.SyscallEventType {
63-
return rule.handleSyscallEvent(event.(*ruleenginetypes.SyscallEvent))
64-
} else if eventType == utils.ExecveEventType {
58+
if eventType == utils.ExecveEventType {
6559
return rule.handleExecveEvent(event.(*tracerexectype.Event))
6660
}
6761

6862
return nil
6963
}
7064

71-
func (rule *R1005FilelessExecution) handleSyscallEvent(syscallEvent *ruleenginetypes.SyscallEvent) ruleengine.RuleFailure {
72-
if rule.alreadyNotified {
73-
return nil
74-
}
75-
76-
if syscallEvent.SyscallName == "memfd_create" {
77-
rule.alreadyNotified = true
78-
ruleFailure := GenericRuleFailure{
79-
BaseRuntimeAlert: apitypes.BaseRuntimeAlert{
80-
AlertName: rule.Name(),
81-
InfectedPID: syscallEvent.Pid,
82-
FixSuggestions: "If this is a legitimate action, please consider removing this workload from the binding of this rule",
83-
Severity: R1005FilelessExecutionRuleDescriptor.Priority,
84-
},
85-
RuntimeProcessDetails: apitypes.ProcessTree{
86-
ProcessTree: apitypes.Process{
87-
Comm: syscallEvent.Comm,
88-
Gid: &syscallEvent.Gid,
89-
PID: syscallEvent.Pid,
90-
Uid: &syscallEvent.Uid,
91-
},
92-
ContainerID: syscallEvent.Runtime.ContainerID,
93-
},
94-
TriggerEvent: syscallEvent.Event,
95-
RuleAlert: apitypes.RuleAlert{
96-
RuleDescription: fmt.Sprintf("Fileless execution detected: syscall memfd_create executed in: %s", syscallEvent.GetContainer()),
97-
},
98-
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{
99-
PodName: syscallEvent.GetPod(),
100-
},
101-
RuleID: rule.ID(),
102-
}
103-
104-
return &ruleFailure
105-
}
106-
107-
return nil
108-
}
109-
11065
func (rule *R1005FilelessExecution) handleExecveEvent(execEvent *tracerexectype.Event) ruleengine.RuleFailure {
11166
execFullPath := getExecFullPathFromEvent(execEvent)
11267
execPathDir := filepath.Dir(execFullPath)

0 commit comments

Comments
 (0)