Skip to content

rfc2869: add Message-Authenticator (RFC 3579) sign/validate helpers#144

Open
jamiesun wants to merge 1 commit into
layeh:masterfrom
talkincode:feature/message-authenticator
Open

rfc2869: add Message-Authenticator (RFC 3579) sign/validate helpers#144
jamiesun wants to merge 1 commit into
layeh:masterfrom
talkincode:feature/message-authenticator

Conversation

@jamiesun

@jamiesun jamiesun commented Jun 8, 2026

Copy link
Copy Markdown

Summary

The library exposed accessors for the Message-Authenticator attribute (RFC 2869, type 80) but provided no way to compute or verify its HMAC-MD5 value. RFC 3579 §3.2 and RFC 5997 require validating this attribute — for example on Status-Server requests, and as part of mitigations for Blast-RADIUS style attacks — so users had to implement the HMAC by hand.

This adds opt-in helpers in rfc2869:

// Place a zeroed placeholder before encoding.
func AddMessageAuthenticator(p *radius.Packet) error

// Compute HMAC-MD5 over the encoded packet (value zeroed) and write it back.
func SignMessageAuthenticator(wire []byte, secret []byte) error

// Verify it; returns ErrNoMessageAuthenticator / ErrInvalidMessageAuthenticator.
func ValidateMessageAuthenticator(wire []byte, secret []byte) error

The computation operates on wire bytes, matching IsAuthenticRequest / IsAuthenticResponse, and is correct for Access-Request and Status-Server packets (whose own Authenticator field is the HMAC input). The output was cross-checked against an independent HMAC-MD5 implementation.

Validating responses additionally requires the original request's authenticator and interacts with Encode()'s Response-Authenticator computation; that is intentionally left to the caller and documented rather than auto-wired here, keeping this change focused on the request/Status-Server path that the issue is about.

Changes

  • rfc2869/message_authenticator.go (new): sentinel errors + AddMessageAuthenticator, SignMessageAuthenticator, ValidateMessageAuthenticator.
  • rfc2869/message_authenticator_test.go (new): sign/validate (with independent HMAC cross-check), tampered, missing, malformed.

This addresses the Message-Authenticator portion of #43.

Closes #43

The library exposed accessors for the Message-Authenticator attribute
but provided no way to compute or verify its HMAC-MD5 value. RFC 3579
and RFC 5997 require this attribute to be validated (for example, on
Status-Server requests, and as mitigation for Blast-RADIUS style
attacks), so users had to implement the HMAC themselves.

Add opt-in helpers to rfc2869:

  - AddMessageAuthenticator places a zeroed placeholder attribute on a
    packet before it is encoded.
  - SignMessageAuthenticator computes the HMAC-MD5 over the encoded
    packet (with the attribute value zeroed) and writes it back.
  - ValidateMessageAuthenticator verifies it, returning typed errors for
    the missing and mismatched cases.

The computation operates on wire bytes, matching IsAuthenticRequest /
IsAuthenticResponse, and is correct for Access-Request and Status-Server
packets. The output was cross-checked against an independent HMAC-MD5
implementation.

Closes layeh#43

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Server and client do not verify presence or validity of certain attributes

1 participant