PowerShell / PowerShell/Win32-OpenSSH

When using smartcards PINs are stored in the registry by ssh-agent

Open
#2,341 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-ssh-agent Issue-Enhancement
Dominant language
No language data
Stars
8.3k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.
Steps to reproduce

Using smartcards to hold private keys for ssh, I pondered how ssh-agent was able to reload the keys after a reboot.
It seems that when using the OpenSC opensc-pkcs11.dll to load the key to ssh-agent, the call to https://github.com/PowerShell/openssh-portable/blob/0096029101a77a9b6b45c8351d46dc9b081b5756/contrib/win32/win32compat/ssh-agent/keyagent-request.c#L106 ends up storing the entered card pin in the registry.
This is then easily extracted from the registry using an elevated shell.

There is no expectation that ssh-agent should be able to hold keys over a reboot or logout, and I definitely didn't expect ssh-agent to stash my PIN away in a fairly insecure way.

Expected behavior
ssh-agent should not store entered smartcard PINs in the registry
Actual behavior
ssh-agent stores entered PINs in the registry
Error details

Environment data
> $psversiontable

Name                           Value
----                           -----
PSVersion                      5.1.22621.4391
PSEdition                      Desktop

> ssh -V
OpenSSH_for_Windows_9.8p1 Win32-OpenSSH-GitHub, LibreSSL 3.9.2
Version

OpenSSH_for_Windows_9.8p1

Visuals

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at contrib/win32/win32compat/ssh-agent/keyagent-request.c around line 106 and trace how the OpenSC opensc-pkcs11.dll path handles the entered PIN and registry storage. Reproduce the behavior on OpenSSH_for_Windows_9.8p1, then verify that ssh-agent no longer stores smartcard PINs in the registry while still handling the key-loading flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
authentication, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.