-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Harden SecKeyCopyExternalRepresentation against sensitive keys #99840
Conversation
The previous approach relied on examining the error code returned from SecKeyCopyExternalRepresentation when a key needed to be exported with a password. Apple has changed the error code which resulted in breaking the detection of sensitive values. This change looks for the kSecAttrIsSensitive attribute on a key which according to the Apple documentation, "When set to kCFBooleanTrue, the item can only be exported in an encrypted format". This should be less brittle change checking for the error code.
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
I will check it tomorrow morning. There were some odd cases around the old CSSM keys and I don’t quite remember them all. Thanks for looking into it! |
Yeah, that's why my initial PR was just "handle the new error code" since I would have way more confidence with that in a backport. The way I see it we have a few of options.
|
This comment was marked as outdated.
This comment was marked as outdated.
I did some sanity check first to make sure that the assumptions are correct:
To summarize, it's safe to skip |
The previous approach relied on examining the error code returned from SecKeyCopyExternalRepresentation when a key needed to be exported with a password. Apple has changed the error code which resulted in breaking the detection of sensitive values.
This change looks for the kSecAttrIsSensitive attribute on a key which according to the Apple documentation, "When set to kCFBooleanTrue, the item can only be exported in an encrypted format". This should be less brittle change checking for the error code.