Harden SecKeyCopyExternalRepresentation against sensitive keys#99840
Harden SecKeyCopyExternalRepresentation against sensitive keys#99840vcsjones merged 3 commits intodotnet:mainfrom
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.