jcmturner / gokrb5

Pure Go Kerberos library for clients and services
Apache License 2.0
729 stars 249 forks source link

Java clients fail to authenticate against servers using `gokrb5` #447

Open bendemott opened 3 years ago

bendemott commented 3 years ago

I'm triggering this line of code and getting gssapi.StatusContinueNeeded response, when attempting to authenticate from any Java Kerberos client.

        if m.Equal(gssapi.OID(gssapi.OIDKRB5)) || m.Equal(gssapi.OID(gssapi.OIDMSLegacyKRB5)) {
            if n.mechToken == nil && n.MechTokenBytes == nil {
                return false, gssapi.Status{Code: gssapi.StatusContinueNeeded}
            }

Any help or suggestions of what to try are greatly appreciated

I believe the Java Spnego payload is VALID, but perhaps the gokrb5 library is reading the payload improperly causing the error above.

Java Client

Valid and Invalid Spnego Payloads

Valid Spnego Payload (Python Client / native GSS API)

{
    "MessageType": "SPNEGO InitialContextToken",
    "Data": {
        "thisMech": "SPNEGO (1.3.6.1.5.5.2)",
        "innerContextToken": {
            "MessageType": "SPNEGO NegTokenInit",
            "Data": {
                "mechTypes": [
                    "Kerberos (1.2.840.113554.1.2.2)"
                ],
                "reqFlags": null,

                "mechToken": {
                    "MessageType": "SPNEGO InitialContextToken",
                    "Data": {
                        "thisMech": "Kerberos (1.2.840.113554.1.2.2)",
                        "innerContextToken": {
                            "MessageType": "AP-REQ (14)",
                            "Data": {
                                "pvno": 5,
                                "msg-type": "AP-REQ (14)",
                                "ap-options": {
                                    "raw": 0,
                                    "flags": []
                                },
                                "ticket": {
                                    "tkt-vno": 5,
                                    "realm": "EXAMPLE.COM",
                                    "sname": {
                                        "name-type": "NT-SRV-HST (3)",
                                        "name-string": [
                                            "vaultsvc",
                                            "vault.example.com"
                                        ]
                                    },
                                    "enc-part": {
                                        "etype": "AES256_CTS_HMAC_SHA1_96 (18)",
                                        "kvno": 1,
                                        "cipher": "B1112B-----"
                                    }
                                },
                                "authenticator": {
                                    "etype": "AES256_CTS_HMAC_SHA1_96 (18)",
                                    "kvno": null,
                                    "cipher": "EC9B85----"
                                }
                            },
                            "RawData": "01006E82-----"
                        }
                    },
                    "RawData": "6082028B-----"
                },
                "mechListMIC": null
            },
            "RawData": "A08202AA----"
        }
    },
    "RawData": "608202----"
}

Invalid Spnego Payload (Java Client)

{
    "MessageType": "SPNEGO InitialContextToken",
    "Data": {
        "thisMech": "SPNEGO (1.3.6.1.5.5.2)",
        "innerContextToken": {
            "MessageType": "SPNEGO NegTokenInit",
            "Data": {
                "mechTypes": [
                    "Kerberos (1.2.840.113554.1.2.2)"
                ],
                "reqFlags": {
                    "raw": 0,
                    "flags": [
                        "delegFlag (0)"
                    ]
                },
                "mechToken": {
                    "MessageType": "SPNEGO InitialContextToken",
                    "Data": {
                        "thisMech": "Kerberos (1.2.840.113554.1.2.2)",
                        "innerContextToken": {
                            "MessageType": "AP-REQ (14)",
                            "Data": {
                                "pvno": 5,
                                "msg-type": "AP-REQ (14)",
                                "ap-options": {
                                    "raw": 0,
                                    "flags": []
                                },
                                "ticket": {
                                    "tkt-vno": 5,
                                    "realm": "EXAMPLE.COM",
                                    "sname": {
                                        "name-type": "NT-UNKNOWN (0)",
                                        "name-string": [
                                            "vaultsvc",
                                            "vault.example.com"
                                        ]
                                    },
                                    "enc-part": {
                                        "etype": "AES256_CTS_HMAC_SHA1_96 (18)",
                                        "kvno": 1,
                                        "cipher": "759DC530----"
                                    }
                                },
                                "authenticator": {
                                    "etype": "AES256_CTS_HMAC_SHA1_96 (18)",
                                    "kvno": null,
                                    "cipher": "DC58A7CC5F----""
                                }
                            },
                            "RawData": "01006E820----"
                        }
                    },
                    "RawData": "608202----"
                },
                "mechListMIC": null
            },
            "RawData": "A08202----"
        }
    },
    "RawData": "6082029----"
}
qerub commented 2 years ago

I think this is the same as https://github.com/jcmturner/gokrb5/issues/390 that was fixed with https://github.com/jcmturner/gokrb5/pull/406.

bendemott commented 1 year ago

Correct, this is fixed in 406