Fix abort() calls when importing malformed SSH keys#12821
Open
stoeckmann wants to merge 2 commits into
Open
Conversation
droidmonkey
reviewed
Dec 21, 2025
Comment on lines
+31
to
+33
| stream.read(tag); | ||
| if (!stream.read(tag)) { | ||
| return false; | ||
| } |
Member
There was a problem hiding this comment.
I'm wondering if this would be more clearly implemented as a preprocessor define: VALIDATE_RETURN(stream.read(tag))
#define VALIDATE_RETURN(call) if (!call) { return false; }
Contributor
Author
There was a problem hiding this comment.
I'm fine with that. Adjusted.
I/O operations might fail, so test if they succeed. While at it, use newly introduced VALIDATE_RETURN for parsePrivateHeader as well.
Values around 2 GB lead to abort() calls within Qt 5.
21858d3 to
66be8e8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ASN.1 parser code lacks some error checking, which leads to issues if the parser encounters incomplete keys. Also, if an integer is denoted to be around 2 GB in size, the subsequent array resizing leads to an abort() call within Qt 5, shutting down KeePassXC.
The fix includes adding all missing error checks and introducing a length limit of 10 MB for an integer. It is highly unlikely that this limit will ever be reached. Also,
1024 * 1024 * 10is already used as "artificial" limit within KeePassXC, in case someone wonders where this magic value comes from.Testing strategy
I have added a unit test, but it can be reproduced with KeePassXC this way:
Type of change