Kerberos Code 41: Someone’s Tweaking the Stream!
Luke Hebert
- 2 minutes read - 343 wordsIf your Java services started throwing KRB_AP_ERR_MODIFIED errors after a JDK update, the culprit is likely the referral-following behavior added in JDK 1.8.0u242. Two small configuration changes on each affected node will restore normal Kerberos authentication against Active Directory.
JDK 1.8.0u242 and later added additional Kerberos features to align with other platforms that support Kerberos. The Java team implemented referral following in accordance with RFC 6806, but this change conflicts with the way Active Directory handles those requests. During name canonicalization, the returned name on the ticket can be altered, resulting in a KRB_AP_ERR_MODIFIED failure.
See the related bug report: JDK-8230496.
Fix: Disable Kerberos Referrals
To resolve the referral issue, take the following action on all impacted nodes as appropriate for your environment:
- Edit the
java.securityfile located in the active JDK on the cluster. - Add or alter the
sun.security.krb5.disableReferralsparameter to ensure it is set totrue:
sun.security.krb5.disableReferrals=trueUnderstanding Name Canonicalization
Principal name changes are allowed in AS-REQ responses only if:
- The
canonicalizeoption was set in the AS-REQ request. - PA-REQ-ENC-PA-REP pre-authentication data was sent in the AS-REQ response (meaning the server supports the RFC 6068 FAST scheme).
- The authenticated checksum is correct.
Principal name changes are allowed in TGS-REQ responses only if:
- The
canonicalizeoption was set in the TGS-REQ request. - The
snamehas a referral value of the formkrbtgt/TO-REALM.COM@FROM-REALM.COM.
Principal name changes are not allowed in other cases, and a KRB_AP_ERR_MODIFIED exception is thrown.
Fix: Renew Lifetime Mismatch
In addition to the referral issue, the Java team also changed how renewals are handled in earlier JDK releases. If the renew_lifetime parameter is present in the krb5.conf file on the host and the values do not appropriately align with what the KDC offers, the request will fail and produce a similar error.
To resolve this, simply comment out the renew_lifetime parameter in krb5.conf:
# renew_lifetime = 7dApply both fixes on every node in the cluster. A partial rollout can leave some nodes still hitting the KRB_AP_ERR_MODIFIED error while others succeed, making the issue harder to diagnose.