Skip to content

feat: Add SASL security layer support for GSSAPI#568

Open
vrlo wants to merge 2 commits intojcmturner:masterfrom
vrlo:sasl
Open

feat: Add SASL security layer support for GSSAPI#568
vrlo wants to merge 2 commits intojcmturner:masterfrom
vrlo:sasl

Conversation

@vrlo
Copy link

@vrlo vrlo commented Oct 29, 2025

What this does

Implements SASL security layers (RFC 4752) for GSSAPI/Kerberos authentication
providing message integrity protection and confidentiality after authentication.

Follows RFC 4121 (GSS-API v2 WrapToken format), RFC 4752 (GSSAPI SASL mechanism),
and RFC 4422 (SASL framing with 4-byte length prefix).

Tested against Windows Active Directory (LDAP on port 389).

Fixes #567

Impact

This adds new APIs -- requires a minor version bump

Implementation

Three new components in v8/gssapi:

SecurityLayerSession - Session management for message wrapping/unwrapping:

session, err := gssapi.NewSecurityLayerSession(sessionKey, gssapi.SecurityLayerIntegrity, true, 65536)
wrapped, err := session.Wrap(message)
unwrapped, err := session.Unwrap(wrapped)

SASL Framing - RFC 4422 framing with 4-byte length prefix:

framedMessage, err := session.WrapWithSASLFraming(message)
unwrapped, err := session.UnwrapFromSASLFraming(data)

SecureConn - Transparent net.Conn wrapper:

secureConn := gssapi.NewSecureConn(conn, session)
// All Read/Write operations automatically protected

Testing

Production tested against Windows Active Directory:

  • Integrity layer (RRC=12) ✅
  • Confidentiality layer (RRC=28) ✅
  • LDAP search operations ✅

Compatibility

No breaking changes - all new exports:

  • SecurityLayer (type)
  • SecurityLayerSession (type)
  • SecureConn (type)
  • NewSecurityLayerSession() (function)
  • NewSecureConn() (function)

Platform agnostic, zero external dependencies, targets v8 only.

Related issues

Builds on:

Note: This implements RFC 4121 (modern GSS-API v2). For RFC 1964 (legacy), see #460.

vrlo and others added 2 commits October 29, 2025 21:09
Implements SASL security layers (RFC 4752) for GSSAPI/Kerberos authentication
providing message integrity protection and confidentiality after authentication.

Follows RFC 4121 (GSS-API v2 WrapToken format), RFC 4752 (GSSAPI SASL mechanism),
and RFC 4422 (SASL framing with 4-byte length prefix).

Tested against Windows Active Directory (LDAP on port 389).

Co-Authored-By: Claude <noreply@anthropic.com>
Refactors GSS-API wrap token header construction to eliminate code
duplication and implements proper filler byte calculation per RFC 4121
section 4.2.4 to eliminate crypto-system residue after decryption.

Adds comprehensive test to verify RFC 4121 section 4.2.4 requirement
that no crypto-system residue is present after decryption.

Co-Authored-By: Claude <noreply@anthropic.com>
@Neustradamus
Copy link

@vrlo: Thanks for your PR!

If you can look for Channel Binding too, it will be nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support SASL security layer for client GSSAPI authentication

2 participants