Bug 1472 - Authentication options not cleared in privileged process
Summary: Authentication options not cleared in privileged process
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: -current
Hardware: All Linux
: P2 normal
Assignee: Assigned to nobody
URL: https://bugs.launchpad.net/ubuntu/+so...
Keywords:
Depends on:
Blocks: V_5_1
  Show dependency treegraph
 
Reported: 2008-05-27 02:55 AEST by Colin Watson
Modified: 2008-07-22 12:24 AEST (History)
1 user (show)

See Also:


Attachments
call auth_clear_options in privileged process (4.97 KB, patch)
2008-05-27 02:55 AEST, Colin Watson
no flags Details | Diff
clear key options in monitor on failed auth attempt (969 bytes, patch)
2008-06-13 07:43 AEST, Darren Tucker
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Watson 2008-05-27 02:55:23 AEST
Created attachment 1509 [details]
call auth_clear_options in privileged process

https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/161047 reports a problem with forced commands when used with public-key authentication but expecting password authentication also to work without the forced command. Briefly, it may be reproduced on a single machine as follows:

1) Move all but one of your keys out of the way in ~/.ssh so that the client won't find them.

2) Apply a forced command to this key in ~/.ssh/authorized_keys; command="echo hello" will do.

3) If you are running ssh-agent, remove all identities from it with 'ssh-add -D'.

4) Connect to localhost. When prompted for the public key passphrase, press Enter; then enter your normal password when prompted to do so. Observe that "hello" is printed and no shell is given.

I believe that the problem here is that, if authentication fails after calling auth_rsa_key_allowed or user_key_allowed in the privileged process, authentication options are only cleared in the monitor rather than in the privileged process. The obvious fix seems to be to clear them in both processes. This is implemented by the attached patch.

This is only reproducible if the last key offered by the client is the one with the forced command, since auth_parse_options calls auth_clear_options on entry and that's called in the privileged process.
Comment 1 Darren Tucker 2008-06-13 07:43:54 AEST
Created attachment 1516 [details]
clear key options in monitor on failed auth attempt

The monitor already knows whether or not the authentication succeeds, so an extra monitor call seems unnecessary.  Does this patch also resolve the problem?
Comment 2 Darren Tucker 2008-06-13 23:57:52 AEST
Patch #1516 has been applied and will be in the next release.

Thanks.
Comment 3 Damien Miller 2008-07-22 12:24:51 AEST
Mass update RESOLVED->CLOSED after release of openssh-5.1