-
Notifications
You must be signed in to change notification settings - Fork 5k
[Packetbeat] rpc fragment bounds checking #47803
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
Conversation
🤖 GitHub commentsJust comment with:
|
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
Pinging @elastic/sec-linux-platform (Team:Security-Linux Platform) |
This test caused a crash prior to this PR
pcap captured when running the following:
```bash
nc -l 12049 >/dev/null
```
and in a different shell
```python
import socket, struct, time
dest = ("127.0.0.1", 12049)
frag_header = struct.pack("!I", 0x80000001)
payload = b"\x00"
with socket.create_connection(dest, timeout=5) as sock:
sock.sendall(frag_header + payload)
time.sleep(0.2)
```
Co-authored-by: Mykola Kmet <[email protected]>
f2ace09 to
9d28242
Compare
- add return for consistency - add failure case unit tests
54bee27 to
df18985
Compare
df18985 to
326fb60
Compare
|
@mykola-elastic I had to push some changes to xdr.go in order to appease the linter's complaints about overflows. Could probably use another once over. Thanks. |
* nfs xdr sanitization
* Add integration test
This test caused a crash prior to this PR
pcap captured when running the following:
```bash
nc -l 12049 >/dev/null
```
and in a different shell
```python
import socket, struct, time
dest = ("127.0.0.1", 12049)
frag_header = struct.pack("!I", 0x80000001)
payload = b"\x00"
with socket.create_connection(dest, timeout=5) as sock:
sock.sendall(frag_header + payload)
time.sleep(0.2)
```
* Add changelog fragment
* Update changelog/fragments/1764181634-rpc_fragment_sanitization.yaml
Co-authored-by: Mykola Kmet <[email protected]>
* review suggestions
- add return for consistency
- add failure case unit tests
* Appease the linter
---------
Co-authored-by: Mykola Kmet <[email protected]>
(cherry picked from commit afbccd1)
* nfs xdr sanitization
* Add integration test
This test caused a crash prior to this PR
pcap captured when running the following:
```bash
nc -l 12049 >/dev/null
```
and in a different shell
```python
import socket, struct, time
dest = ("127.0.0.1", 12049)
frag_header = struct.pack("!I", 0x80000001)
payload = b"\x00"
with socket.create_connection(dest, timeout=5) as sock:
sock.sendall(frag_header + payload)
time.sleep(0.2)
```
* Add changelog fragment
* Update changelog/fragments/1764181634-rpc_fragment_sanitization.yaml
Co-authored-by: Mykola Kmet <[email protected]>
* review suggestions
- add return for consistency
- add failure case unit tests
* Appease the linter
---------
Co-authored-by: Mykola Kmet <[email protected]>
(cherry picked from commit afbccd1)
* nfs xdr sanitization
* Add integration test
This test caused a crash prior to this PR
pcap captured when running the following:
```bash
nc -l 12049 >/dev/null
```
and in a different shell
```python
import socket, struct, time
dest = ("127.0.0.1", 12049)
frag_header = struct.pack("!I", 0x80000001)
payload = b"\x00"
with socket.create_connection(dest, timeout=5) as sock:
sock.sendall(frag_header + payload)
time.sleep(0.2)
```
* Add changelog fragment
* Update changelog/fragments/1764181634-rpc_fragment_sanitization.yaml
Co-authored-by: Mykola Kmet <[email protected]>
* review suggestions
- add return for consistency
- add failure case unit tests
* Appease the linter
---------
Co-authored-by: Mykola Kmet <[email protected]>
(cherry picked from commit afbccd1)
* nfs xdr sanitization
* Add integration test
This test caused a crash prior to this PR
pcap captured when running the following:
```bash
nc -l 12049 >/dev/null
```
and in a different shell
```python
import socket, struct, time
dest = ("127.0.0.1", 12049)
frag_header = struct.pack("!I", 0x80000001)
payload = b"\x00"
with socket.create_connection(dest, timeout=5) as sock:
sock.sendall(frag_header + payload)
time.sleep(0.2)
```
* Add changelog fragment
* Update changelog/fragments/1764181634-rpc_fragment_sanitization.yaml
* review suggestions
- add return for consistency
- add failure case unit tests
* Appease the linter
---------
(cherry picked from commit afbccd1)
Co-authored-by: Nicholas Berlin <[email protected]>
Co-authored-by: Mykola Kmet <[email protected]>
* nfs xdr sanitization
* Add integration test
This test caused a crash prior to this PR
pcap captured when running the following:
```bash
nc -l 12049 >/dev/null
```
and in a different shell
```python
import socket, struct, time
dest = ("127.0.0.1", 12049)
frag_header = struct.pack("!I", 0x80000001)
payload = b"\x00"
with socket.create_connection(dest, timeout=5) as sock:
sock.sendall(frag_header + payload)
time.sleep(0.2)
```
* Add changelog fragment
* Update changelog/fragments/1764181634-rpc_fragment_sanitization.yaml
* review suggestions
- add return for consistency
- add failure case unit tests
* Appease the linter
---------
(cherry picked from commit afbccd1)
Co-authored-by: Nicholas Berlin <[email protected]>
Co-authored-by: Mykola Kmet <[email protected]>
* nfs xdr sanitization
* Add integration test
This test caused a crash prior to this PR
pcap captured when running the following:
```bash
nc -l 12049 >/dev/null
```
and in a different shell
```python
import socket, struct, time
dest = ("127.0.0.1", 12049)
frag_header = struct.pack("!I", 0x80000001)
payload = b"\x00"
with socket.create_connection(dest, timeout=5) as sock:
sock.sendall(frag_header + payload)
time.sleep(0.2)
```
* Add changelog fragment
* Update changelog/fragments/1764181634-rpc_fragment_sanitization.yaml
* review suggestions
- add return for consistency
- add failure case unit tests
* Appease the linter
---------
(cherry picked from commit afbccd1)
Co-authored-by: Nicholas Berlin <[email protected]>
Co-authored-by: Mykola Kmet <[email protected]>
Proposed commit message
When the NFS protocol is enabled in Packetbeat, crafted ONC RPC/NFS traffic can cause the application to panic and exit due to unchecked XDR length fields and undersized RPC records. This affects both request and reply parsing paths.
This PR adds bounds checking and ignores malformed fragments via new error propagation.
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesstresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.Author's Checklist
How to test this PR locally
There is a new test included in this PR, could revert the changes of the first commit and run the tests and see things go sideways.