Commit 786c5e9
fix(fido2,core): apply previewSign code-audit findings
Three audit fixes plus a regression test for the new precondition guard.
All four are concrete, well-scoped changes from Plans/codeaudit-previewsign-port.md.
1. Crypto leak (HIGH): ArkgPrimitivesOpenSsl.BlBlindPublicKey now wraps its
body in try/finally and zeroes the blinding scalar tauBytes via
CryptographicOperations.ZeroMemory. Brings tauBytes in line with the
other secret-bearing arrays in the same file (ephSkBytes, kPrime, mk,
ikmTau, prk, full) which were already zeroed.
2. API footgun (HIGH): GetAssertionParameters.AddPreviewSignByCredentialExtension
now throws InvalidOperationException with an actionable message when the
parent's allow-list is null/empty. Without this guard, customers got a
cryptic firmware "option or extension invalid" error from the YubiKey.
The required precondition is enforced at the protocol level by the
firmware (and documented in python-fido2's reference impl); the SDK
should fail fast and explain how to fix the call site.
3. Documentation lies (LOW): MakeCredentialData.GetPreviewSignGeneratedKey
and AuthenticatorData.GetPreviewSignSignature each had stale
<exception cref="NotImplementedException"> tags inherited from a draft
that were no longer accurate. Deleted.
4. Regression test: PreviewSignExtensionTests now asserts
AddPreviewSignByCredentialExtension throws InvalidOperationException with
"AllowCredential" in the message when the allow-list is empty. New helper
BuildAuthenticatorInfoWithPreviewSign supports the test without hardware.
Verification:
Yubico.YubiKey.UnitTests: 3588 PASS (3587 baseline + 1 new test)
Yubico.Core.UnitTests: 488 PASS / 21 SKIP (baseline match)
Build: 0 warnings, 0 errors
3 ARKG NativeShims tests still fail with EntryPointNotFoundException
for Native_EC_POINT_is_on_curve — expected interim state until the
Yubico.NativeShims 1.16.1-prerelease.20260428.1 NuGet package lands.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b3bf3e8 commit 786c5e9
5 files changed
Lines changed: 80 additions & 24 deletions
File tree
- Yubico.Core/src/Yubico/Core/Cryptography
- Yubico.YubiKey
- src/Yubico/YubiKey/Fido2
- tests/unit/Yubico/YubiKey/Fido2
Lines changed: 25 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 216 | + | |
231 | 217 | | |
232 | | - | |
233 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
234 | 224 | | |
235 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
236 | 243 | | |
237 | 244 | | |
238 | 245 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | 404 | | |
408 | 405 | | |
409 | 406 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
446 | 450 | | |
447 | 451 | | |
448 | 452 | | |
| |||
457 | 461 | | |
458 | 462 | | |
459 | 463 | | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
460 | 471 | | |
461 | 472 | | |
462 | 473 | | |
| |||
Lines changed: 0 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | 289 | | |
293 | 290 | | |
294 | 291 | | |
| |||
Lines changed: 44 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
182 | 201 | | |
183 | 202 | | |
184 | 203 | | |
| |||
403 | 422 | | |
404 | 423 | | |
405 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
406 | 450 | | |
407 | 451 | | |
408 | 452 | | |
| |||
0 commit comments