Prevent file descriptor leaks in user input handling#21569
Conversation
|
Thanks for your pull request! As part of our landing process, we manually verify that all modules work as expected. We've added the |
|
Additional test pipeline started ⌛ |
|
Slice summary: No test slices found. Note: build results only accessible to maintainers. |
|
Additional test pipeline started ⌛ |
|
Slice summary:
Note: build results only accessible to maintainers. |
|
Additional test pipeline started ⌛ |
|
Slice summary:
Note: build results only accessible to maintainers. |
Description
fixes leaking file descriptors
Related Issue: #21553
Breaking Changes
None
Verification Steps
Automated Tests
All 40 examples should pass. The "FD stability with real Input::Buffer instances" test directly validates that repeated init_ui calls with socket-backed buffers do not leak file descriptors.
Manual Verification — FD Leak over RPC
Reproduces the issue from #21553 using a meterpreter bind payload in Docker.
Generate a meterpreter bind payload
./msfvenom -p linux/x64/meterpreter/bind_tcp LPORT=4444 -f elf -o /tmp/mbindRun it in a Docker container
docker run --rm -d --name msf-target -p 4444:4444 -v /tmp/mbind:/mbind debian:bookworm-slim bash -c "chmod +x /mbind && /mbind"Start msfrpcd (no SSL, foreground)
./msfrpcd -P test -S -f -a 127.0.0.1Connect to the bind payload via msfrpc
./msfrpc -a 127.0.0.1 -S -P test -U msfIn the IRB shell:
rpc.call('module.execute', 'exploit', 'multi/handler', {'PAYLOAD' => 'linux/x64/meterpreter/bind_tcp', 'RHOST' => '127.0.0.1', 'LPORT' => '4444'})Wait a few seconds, confirm the session:
rpc.call('session.list')Record baseline FD count (separate terminal)
lsof -p $(pgrep -f msfrpcd) | wc -lRun repeated RPC interactions with pymetasploit3
pip install pymetasploit3lsof -p $(pgrep -f msfrpcd) | wc -lExpected (with fix): FD count remains stable (no growth after initial settling).
Before fix: FD count grows by ~4 per cycle (2 TCP sockets + 2 FIFO pipes leaked each time).
docker rm -f msf-targetTest Evidence
Environment
AI Usage Disclosure
Kiro
Pre-Submission Checklist
rubocopon new files with no new offenses (net new files only)msftidyon changed module files with no new offenses (modules only)msftidy_docson changed documentation files with no new offenses (documentation files only)documentation/modules(new modules only)lib/changes)