-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing from the agent not working for encrypted ASN.1 SSH keys #6788
Comments
By the way, GUI tests for the ssh-agent feature (#4468) might prevent such an issue |
This is a good quick fix but I wonder if this is a regression or not. Ideally it would at least check if it needs to do that. When adding keys the public part is kept in memory for automatic removal but when removing manually it needs to indeed do the decryption for old keys as it doesn't know which key it is without that. |
I justed downloaded 2.6.6 and things are working, so it seems indeed a regression. I can have a bisect when I find time. |
git bisect reports:
|
Damn then that is on me |
This line seems the key change 80809ac#diff-f78b949db9ddb2bc843cb02fdb2290fd08cd6d52986d1544e970b4be743f19d8L458 If I add it back (with a different function due to refactoring), the issue is gone diff --git a/src/sshagent/KeeAgentSettings.cpp b/src/sshagent/KeeAgentSettings.cpp
index 73c1bbc6..c8e60e39 100644
--- a/src/sshagent/KeeAgentSettings.cpp
+++ b/src/sshagent/KeeAgentSettings.cpp
@@ -478,7 +478,7 @@ bool KeeAgentSettings::toOpenSSHKey(const QString& username,
return false;
}
- if (key.encrypted() && decrypt) {
+ if (key.encrypted() && (decrypt || key.publicKey().isEmpty())) {
if (!key.openKey(password)) {
m_error = key.errorString();
return false; Do you remember the reason for removing that condition? |
Oof, there is no reason could have been left over from testing an idea. Good find! |
Contents of id_rsa-encrypted-asn1 are from TestOpenSSHKey::testDecryptRSAAES128CBC(). Closes #6788
Overview
For encrypted ASN.1 SSH keys, the public key is not available before decryption. On the other hand, the GUI does not request the decryption for key removals [1][2]. As a result, removing such keys from the agent does not work.
[1]
keepassxc/src/gui/entry/EditEntryWidget.cpp
Line 734 in 089c8df
[2]
keepassxc/src/gui/DatabaseWidget.cpp
Line 651 in 089c8df
Steps to Reproduce
ssh-keygen -m PEM -f test_key
)Expected Behavior
The key is no longer in the agent
Actual Behavior
The key is still in the agent, and there is an error message:
Context
The simplest fix is decrypting the key before removing it from the agent
I'm not sure if there is a better fix - maybe decrypting the key only when needed?
Environment
KeePassXC - Version 2.7.0-snapshot
Build Type: Snapshot
Revision: 089c8df
Qt 5.15.2
Debugging mode is disabled.
Operating system: Arch Linux
CPU architecture: x86_64
Kernel: linux 5.10.54-1-lts
Enabled extensions:
Cryptographic libraries:
Desktop Env: LXQt
Windowing System: X11
ssh-agent is from openssh 8.6p1
The text was updated successfully, but these errors were encountered: