Add Kerberos service authentication tracing - #21729
Conversation
|
Thanks for your pull request! As part of our landing process, we manually verify that all modules work as expected. We've added the |
a036b84 to
8283a98
Compare
There was a problem hiding this comment.
Pull request overview
Extends Kerberos tracing through service authentication while separating token parsing, serialization, and presentation.
Changes:
- Adds AP-REQ, GSS/SPNEGO, response-token, and mutual-authentication trace events.
- Adds dedicated parsers, serializers, presenters, and comprehensive RSpec coverage.
- Updates trace option wording and removes temporary trace context from authentication results.
Impact Analysis:
- Blast radius: Medium—shared Kerberos authentication and tracing used by multiple protocol clients.
- Data and contract effects: Adds subscriber events and trace output; no storage changes. Redaction and mutual-authentication accuracy require fixes.
- Rollback and test focus: No irreversible effects; prioritize metadata redaction and verified AP-REP result handling.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/msf/core/exploit/remote/kerberos/client.rb |
Updates trace option wording. |
lib/msf/core/exploit/remote/kerberos/service_authenticator/base.rb |
Emits service-authentication events and manages trace context. |
lib/msf/core/exploit/remote/kerberos/service_authenticator/options.rb |
Updates trace option description. |
lib/rex/proto/kerberos/gss_token_parser.rb |
Parses GSS and SPNEGO trace metadata. |
lib/rex/proto/kerberos/kerberos_logger_subscriber.rb |
Routes and formats new trace events. |
lib/rex/proto/kerberos/kerberos_readable_text_presenter.rb |
Adds labels for trace fields. |
lib/rex/proto/kerberos/kerberos_subscriber.rb |
Adds subscriber callback APIs. |
lib/rex/proto/kerberos/kerberos_trace_serializer.rb |
Serializes Kerberos objects for tracing. |
lib/rex/proto/kerberos/service_authentication_trace_presenter.rb |
Presents AP-REQ and response traces. |
spec/lib/msf/base/serializer/readable_text_spec.rb |
Updates option-output expectations. |
spec/lib/msf/core/exploit/remote/kerberos/service_authenticator/base_spec.rb |
Tests authentication trace emission and cleanup. |
spec/lib/rex/proto/kerberos/gss_token_parser_spec.rb |
Tests token parsing behavior. |
spec/lib/rex/proto/kerberos/kerberos_logger_subscriber_spec.rb |
Tests trace-mode output. |
spec/lib/rex/proto/kerberos/kerberos_trace_serializer_spec.rb |
Tests serialization and redaction. |
spec/lib/rex/proto/kerberos/service_authentication_trace_presenter_spec.rb |
Tests trace presentation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Additional test pipeline started ⌛ |
|
Slice summary:
Note: build results only accessible to maintainers. |
Summary
Depends on #21717.
This PR extends
KerberosTicketTraceto cover the Kerberos service-authentication exchange after a service ticket has been selected.It builds on
Rex::Proto::Gss::KerberosToken, introduced by #21717, and adds structured tracing for AP-REQ construction, GSS-Kerberos and SPNEGO encapsulation, and service-authentication responses.Protocol-specific HTTP, SMB, LDAP, and MSSQL carrier hooks are intentionally excluded and will be submitted separately.
Functionality
The service authenticator now emits structured trace events for:
NegTokenInitencapsulationNegTokenRespresponsessuccessafter an AP-REP is parsed and decryptedfailedwhen the Kerberos response fails parsing/decryption or negotiation is rejectedincompletewhen SPNEGO negotiation succeeds but no AP-REP has been validated in that trace eventThe trace context includes, when available:
Malformed or unsupported tokens are rendered as structured parse failures without changing the existing authentication error behavior.
Trace presentation
The presentation and parsing responsibilities are separated into dedicated components:
Rex::Proto::Kerberos::GssTokenParserNegTokenInit, and SPNEGONegTokenRespmetadata.Rex::Proto::Kerberos::ServiceAuthenticationTracePresenterRex::Proto::Kerberos::KerberosTraceSerializerKerberosLoggerSubscriberis reduced to trace-mode handling, event routing, headers, colors, and output dispatch.Trace modes
The existing
KerberosTicketTracemodes are preserved:offmetadataticketfullBinary token payloads are summarized in metadata mode. Kerberos model fields, including checksums, keys, and encrypted fields, are serialized normally; printable string values may be shown, and non-printable binary strings are summarized.
Subscriber events
The Kerberos subscriber interface now supports:
on_ap_reqon_gss_tokenon_spnego_tokenon_response_tokenThese events keep service-authentication trace presentation separate from the authentication implementation.
Additional changes
KerberosTicketTraceoption description from ticket tracing to protocol tracing.Scope
This PR is limited to Kerberos service-authentication trace collection and presentation.
It does not add application-protocol carrier callbacks. HTTP, SMB, LDAP, and MSSQL integration will follow in a separate dependent PR.
Testing
The following affected test suites were run:
bundle exec rspec \ spec/lib/rex/proto/kerberos \ spec/lib/msf/core/exploit/remote/kerberos \ spec/lib/msf/base/serializer/readable_text_spec.rb