msrpce: commit only an accepted presentation context - #5139
Open
KernelClint wants to merge 3 commits into
Open
Conversation
AI-Assisted: yes (GPT-5.6-Cyber)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5139 +/- ##
=======================================
Coverage 80.63% 80.64%
=======================================
Files 390 390
Lines 96936 96948 +12
=======================================
+ Hits 78168 78185 +17
+ Misses 18768 18763 -5
🚀 New features to boost your workflow:
|
The test relied on the name already being present in the campaign namespace. That holds locally but not in CI, where the class reaches the decorator without its interface registration and DCERPC_Server.answer() rejects it. AI-Assisted: yes (GPT-5.6-Cyber)
register_dcerpc_interface() returns early when the interface is already registered, before it binds opnum and intf onto the request classes. A second import of the module therefore leaves its module-level names unbound, which is what CI hit and a local run did not. Reading the classes back out of the registry gives the objects that were bound. AI-Assisted: yes (GPT-5.6-Cyber)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A DCE/RPC bind proposes one or more presentation contexts, each naming an interface (the abstract
syntax) and an encoding (the transfer syntax). The server accepts or rejects each one independently
and says so in its response.
Scapy selects the session's interface from the bind contexts at
scapy/layers/dcerpc.py:2847-2864without regard to the transfer syntax, while
scapy/layers/msrpce/rpcserver.py:326-372decides acceptance separately. A bind proposing an unsupported transfer syntax is answered with a
provider rejection, and the interface it named is nonetheless left selected on the session — so a
following request reaches that interface's registered handler.
The change tracks which context was actually accepted and commits only that one, restoring the
previous interface when none was:
A bind that proposes a supported transfer syntax behaves exactly as before; the regression keeps the
ordinary NDR 2.0 path as its control.
The added regression sends a bind with an unsupported transfer syntax, asserts the rejection, then
sends a request and asserts the handler is not reached. Without the source change it fails.
Performance was measured on one computer, before and after the fix: a normal bind and call took
116.1 µs before and 116.4 µs after. Repeat runs moved by about 2%, so that difference is smaller
than the test can distinguish.