Skip to content

fix(dcerpc): raise DCERPCException instead of raw errors in the transports - #2341

Open
n3rada wants to merge 1 commit into
fortra:masterfrom
n3rada:fix/dcerpc-transport-error-handling
Open

n3rada wants to merge 1 commit into
fortra:masterfrom
n3rada:fix/dcerpc-transport-error-handling

Conversation

@n3rada

@n3rada n3rada commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Hi! 👋

While looking at #1686, I noticed that when the remote side closes a DCE/RPC connection before answering, impacket crashes with a struct.error.

TCPTransport.recv() returns b'' on EOF when called without a byte count and DCERPC_v5.bind() feeds it straight into MSRPCHeader. The count path of the same method already raises DCERPCException("Connection closed by remote host"), so this just makes both paths consistent. I reproduced the issue's exact error locally with a server that reads the bind and closes the connection.

While reading transport.py I also found a few other places where a transport fails with a raw AttributeError or socket.gaierror instead of a DCERPCException, so I fixed those in the same file.

UDPTransport.recv is intentionally unchanged, since an empty datagram is valid.

@anadrianmanrique anadrianmanrique self-assigned this Oct 28, 2026
@anadrianmanrique anadrianmanrique added the in review This issue or pull request is being analyzed label Oct 28, 2026
godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 11, 2026
godylockz pushed a commit to godylockz/impacket that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in review This issue or pull request is being analyzed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants