-
Notifications
You must be signed in to change notification settings - Fork 10
fix http event data bleed #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,7 +227,10 @@ static __always_inline int process_packet(struct syscall_trace_exit *ctx, char * | |
| dataevent->sock_fd = packet->sockfd; | ||
|
|
||
| bpf_probe_read_str(&dataevent->syscall, sizeof(dataevent->syscall), syscall); | ||
| bpf_probe_read_user(&dataevent->buf, min_size(total_size, MAX_DATAEVENT_BUFFER), (void *)packet->buf); | ||
|
|
||
| __u64 buf_copy_len = min_size(total_size, MAX_DATAEVENT_BUFFER); | ||
| dataevent->buf_len = (__u16)buf_copy_len; | ||
| bpf_probe_read_user(&dataevent->buf, buf_copy_len, (void *)packet->buf); | ||
|
Comment on lines
+231
to
+233
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate payload copy success before publishing At Line 233 and Line 323, Also applies to: 322-323 🤖 Prompt for AI Agents |
||
|
|
||
| dataevent->timestamp_raw = bpf_ktime_get_boot_ns(); | ||
|
|
||
|
|
@@ -316,6 +319,7 @@ static __always_inline int process_msg(struct syscall_trace_exit *ctx, char *sys | |
| if (copy_len > MAX_DATAEVENT_BUFFER) | ||
| copy_len = MAX_DATAEVENT_BUFFER; | ||
|
|
||
| dataevent->buf_len = (__u16)copy_len; | ||
| bpf_probe_read_user(&dataevent->buf, copy_len, iov.iov_base); | ||
| bpf_probe_read_str(&dataevent->syscall, sizeof(dataevent->syscall), syscall); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,6 +116,10 @@ func (e *StructEvent) GetBuf() []byte { | |
| return e.Buf | ||
| } | ||
|
|
||
| func (e *StructEvent) GetBufLen() uint16 { | ||
| return uint16(len(e.Buf)) | ||
| } | ||
|
Comment on lines
+119
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested fix type StructEvent struct {
Addresses []string `json:"addresses,omitempty" yaml:"addresses,omitempty"`
Args []string `json:"args,omitempty" yaml:"args,omitempty"`
AttrSize uint32 `json:"attrSize,omitempty" yaml:"attrSize,omitempty"`
Buf []byte `json:"buf,omitempty" yaml:"buf,omitempty"`
+ BufLen uint16 `json:"bufLen,omitempty" yaml:"bufLen,omitempty"`
CapName string `json:"capName,omitempty" yaml:"capName,omitempty"`
...
}
func (e *StructEvent) GetBufLen() uint16 {
- return uint16(len(e.Buf))
+ if e.BufLen > 0 {
+ return e.BufLen
+ }
+ return uint16(len(e.Buf))
}🤖 Prompt for AI Agents |
||
|
|
||
| func (e *StructEvent) GetCapability() string { | ||
| return e.CapName | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fail closed when
buf_lenis zero or invalid.On Line 180 and Line 183,
buf_len == 0(or out-of-range) falls back to the full buffer, which can reintroduce stale-data parsing. For this bug class, safer behavior is returning an empty slice when length metadata is invalid/unset.🔧 Proposed fix
func GetValidBuf(event utils.HttpRawEvent) []byte { buf := event.GetBuf() - if n := event.GetBufLen(); n > 0 && int(n) <= len(buf) { - return buf[:n] - } - return buf + n := int(event.GetBufLen()) + if n <= 0 || n > len(buf) { + return buf[:0] + } + return buf[:n] }🤖 Prompt for AI Agents