radius: verify the request Message-Authenticator - #5138
Open
KernelClint wants to merge 1 commit 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 #5138 +/- ##
=======================================
Coverage 80.63% 80.64%
=======================================
Files 390 390
Lines 96936 96946 +10
=======================================
+ Hits 78168 78183 +15
+ Misses 18768 18763 -5
🚀 New features to boost your workflow:
|
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.
Radius_amanswers RADIUS Access-Requests. A request may carry attribute 80,Message-Authenticator: an HMAC-MD5 over the request computed with the shared secret, with the
attribute's own value zeroed for the computation. It is what proves the request came from a client
holding the secret.
scapy/layers/radius.py:1589-1606collects the request's attributes into a map and moves straight on to building the response, without
ever checking that value. A request with a correct Message-Authenticator and one with a single bit
flipped in it are both answered with Access-Accept.
The change recomputes the value and compares before anything else happens:
The comparison is constant-time, and the check runs before any authentication or response
construction. Requests without attribute 80 are unaffected, as are valid ones.
The added regression sends a valid PAP request, asserts Access-Accept, then flips one bit in the
Message-Authenticator and asserts no response. Without the source change it fails.
Performance was measured on one computer, before and after the fix: an exchange took 170.9 µs
before and 182.6 µs after — 11.7 µs slower, or 6.8%. Repeat runs moved by about 5%, so this one
is larger than the test's own variation and is a real cost rather than noise.
It is worth stating plainly: that cost is one HMAC-MD5 over the request, which is the work the check
requires, and it is only paid when the attribute is present.