Bug 1127992

Summary: aggressive kinit timeout causes AS_REQ resent and subsequent OTP auth failure
Product: [Fedora] Fedora Reporter: Fraser Tweedale <ftweedal>
Component: krb5Assignee: Roland Mainz <rmainz>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: dpal, nalin, nathaniel, pkis, rharwood, rmainz
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1127995 (view as bug list) Environment:
Last Closed: 2015-06-29 21:58:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1127995    
Attachments:
Description Flags
backport of TCP timeout patch to krb5-1.11/f20.
none
proposed patch for 1.11 none

Description Fraser Tweedale 2014-08-08 04:28:13 UTC
Created attachment 925060 [details]
backport of TCP timeout patch to krb5-1.11/f20.

Description of problem:

When performing OTP authentication with `kinit', an aggressive timeout causes, with >50% likelihood (in my environment, YMMV), a second transmission of the AS_REQ request.

When using HOTP authentication, if a response to the second request (which necessarily fails) is received and processed ahead of the response to the first request, `kinit' fails (and the ticket in the successful response is discarded).


Version-Release number of selected component (if applicable):

krb5-workstation-1.11.5-10


How reproducible:

In my setup, resent occurs >50% of time, and failure occurs in the majority of these cases.


Steps to Reproduce:
1. Use `kinit' to perform a preauthenticated ticket request, using krb5-1.11.5. (I have mainly be using the FreeIPA web UI, since it take care of getting the armor cache).
2. Observe that, with high probability, multiple requests are received by KDC, and one of these fails when HOTP is used.  Example /var/log/krb5kdc.log:

Aug 08 00:12:38 ipa-2.ipa.local krb5kdc[28303](info): AS_REQ (6 etypes {18 17 16 23 25 26}) 192.168.122.141: NEEDED_PREAUTH: HTTP/ipa-2.ipa.local for krbtgt/IPA.LOCAL, Additional pre-authentication required
Aug 08 00:12:39 ipa-2.ipa.local krb5kdc[28302](info): AS_REQ (6 etypes {18 17 16 23 25 26}) 192.168.122.141: ISSUE: authtime 1407471159, etypes {rep=18 tkt=18 ses=18}, HTTP/ipa-2.ipa.local for krbtgt/IPA.LOCAL
Aug 08 00:12:39 ipa-2.ipa.local krb5kdc[28303](info): AS_REQ (6 etypes {18 17 16 23 25 26}) 192.168.122.141: ISSUE: authtime 1407471159, etypes {rep=18 tkt=18 ses=18}, HTTP/ipa-2.ipa.local for krbtgt/IPA.LOCAL
Aug 08 00:12:39 ipa-2.ipa.local krb5kdc[28302](info): AS_REQ (6 etypes {18 17 16 23 25 26}) 192.168.122.141: NEEDED_PREAUTH: bresc for krbtgt/IPA.LOCAL, Additional pre-authentication required
Aug 08 00:12:39 ipa-2.ipa.local krb5kdc[28303](info): closing down fd 13
Aug 08 00:12:40 ipa-2.ipa.local krb5kdc[28303](info): preauth (otp) verify failure: Generic preauthentication failure
Aug 08 00:12:40 ipa-2.ipa.local krb5kdc[28303](info): AS_REQ (6 etypes {18 17 16 23 25 26}) 192.168.122.141: PREAUTH_FAILED: bresc for krbtgt/IPA.LOCAL, Preauthentication failed
Aug 08 00:12:41 ipa-2.ipa.local krb5kdc[28302](info): AS_REQ (6 etypes {18 17 16 23 25 26}) 192.168.122.141: ISSUE: authtime 1407471159, etypes {rep=18 tkt=18 ses=18}, bresc for krbtgt/IPA.LOCAL
Aug 08 00:12:41 ipa-2.ipa.local krb5kdc[28303](info): closing down fd 13


Actual results:

Multiple preauthenticated AS_REQ requests from kinit to KDC, one of which fails due to HOTP token counter increment, causing authentication failure.  Occurs with high probability.

Expected results:

A single preauthenticated AS_REQ request from kinit to KDC (or more specifically, a reasonable timeout prior to retry).  Assuming correct credentials, client receives ticket.


Additional info:

Backport of krb5 commit f423c28 (Dynamically expand timeout when TCP connects) was undertaken, but did not resolve issue; the Fedora package patch that was used is attached.

Recent comment by Greg Hudson on the original upstream ticket may be relevant: http://krbdev.mit.edu/rt/Ticket/Display.html?id=7604

This problem does not occur in krb5-1.12 on f21.

Comment 1 Nalin Dahyabhai 2014-08-08 14:28:32 UTC
Do you have the client trace log (obtained by running the client with KRB5_TRACE set to /dev/stderr in its environment)?

Comment 2 Nalin Dahyabhai 2014-08-08 20:45:17 UTC
Is your test server configured to not listen for UDP clients?  That's the only way I can get the suggested behavior with 1.12 when I'm running kinit on the server itself (granted, using enc-timestamp rather than otp).

Comment 3 Nalin Dahyabhai 2014-08-08 20:46:12 UTC
Created attachment 925299 [details]
proposed patch for 1.11

Comment 4 Fraser Tweedale 2014-08-20 03:09:16 UTC
The proposed patch does not work for me - either on its own or in conjunction with my initial backport patch - I still get the two requests in quick succession.

My server listens on UDP and TCP.  If I force it to listen on TCP only** everything works fine, even without any of these patches.

** actually, I couldn't work out how to do this, so I instead force it to listen to a nonstandard UDP port, resulting in the client connecting via TCP.

Comment 5 Nalin Dahyabhai 2014-08-21 12:19:18 UTC
(In reply to Fraser Tweedale from comment #4)
> The proposed patch does not work for me - either on its own or in
> conjunction with my initial backport patch - I still get the two requests in
> quick succession.
> 
> My server listens on UDP and TCP.  If I force it to listen on TCP only**
> everything works fine, even without any of these patches.

I'm rather surprised that 1.12 behaves any differently, then.  Can you run your test under strace so that we can double-check the timeout values that are being passed to poll()?

It's a quirk of how the configuration parsing is done, but you can set the port number to 0 to turn off UDP at the server.

Comment 6 Fedora Admin XMLRPC Client 2014-10-06 16:38:07 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 7 Fedora End Of Life 2015-05-29 12:35:02 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 8 Fedora End Of Life 2015-06-29 21:58:34 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.