-
Notifications
You must be signed in to change notification settings - Fork 18k
os/exec: (*Cmd).Run
doesn't return when TCP connection attached to I/O
#73675
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
Comments
(*Cmd).Run
doesn't return when TCP connection attached to I/O
Hm... I wonder if there's a deadlock when CC @neild maybe for insights into how the net package might be involved specifically. |
I poked at this a little more and I think I understand more of what's going on. The data is all getting successfully passed along (I can interact with the remote shell no problem) but what's happening is that This is actually documented, except it's documented on
(It's also documented on Given the compatibility promise, I'm not sure there's much we can do here to make your script work out-of-the-box. There is a workaround though. I see that if I pass
|
I am not certain there's anything else to do here, so closing optimistically. Let me know if you disagree. |
Using |
Go version
go version go1.24.3 linux/amd64
Output of
go env
in your module/workspace:What did you do?
For detection test purposes we are trying to use this script to test a reverse shell written in Go language:
What did you see happen?
The script does not terminate (nor print
echo "[*] Done!"
).I have verified that the
bash
subprocess correctly terminates upon receivingexit
command from the other end (nc
), however the parent Go program keeps hanging for some reason.Only when I kill
nc
, go program exits.This is a problem because we are not able to automate the test correctly.
What did you expect to see?
The script correctly prints
echo "[*] Done!"
and terminates.Note: this scheme works well with other reverse shell implementations, e.g. python:
The text was updated successfully, but these errors were encountered: