Skip to content

Commit 6d7e7f2

Browse files
committed
Check struct versions before field access
1 parent e3f6864 commit 6d7e7f2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fido2/client/windows.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def make_credential(self, options, event=None):
300300
extension_outputs: dict[str, Any] = {}
301301
if options.extensions:
302302
extensions_out = att_obj.auth_data.extensions or {}
303-
if options.extensions.get("credProps"):
303+
if obj.dwVersion >= 4 and options.extensions.get("credProps"):
304304
extension_outputs["credProps"] = {"rk": bool(obj.bResidentKey)}
305305
if "hmac-secret" in extensions_out:
306306
if obj.dwVersion >= 7:
@@ -326,7 +326,7 @@ def make_credential(self, options, event=None):
326326
if secrets[1]:
327327
results["output2"] = secrets[1]
328328
extension_outputs["hmacGetSecret"] = results
329-
if "largeBlob" in options.extensions:
329+
if obj.dwVersion >= 4 and "largeBlob" in options.extensions:
330330
extension_outputs["largeBlob"] = {
331331
"supported": bool(obj.bLargeBlobSupported)
332332
}
@@ -467,11 +467,11 @@ def get_assertion(self, options, event=None):
467467

468468
extension_outputs: dict[str, Any] = {}
469469

470-
if u2f_appid and obj.dwVersion >= 2:
470+
if obj.dwVersion >= 2 and u2f_appid:
471471
extension_outputs["appid"] = bool(u2f_appid_used.value)
472472

473473
if options.extensions:
474-
if hmac_secret_salts and obj.dwVersion >= 3:
474+
if obj.dwVersion >= 3 and hmac_secret_salts:
475475
secret = obj.pHmacSecret.contents
476476
if "prf" in options.extensions:
477477
result = {"first": secret.first}
@@ -483,7 +483,7 @@ def get_assertion(self, options, event=None):
483483
if secret.second:
484484
result["output2"] = secret.second
485485
extension_outputs["hmacGetSecret"] = result
486-
if obj.dwCredLargeBlobStatus != 0:
486+
if obj.dwVersion >= 2 and obj.dwCredLargeBlobStatus != 0:
487487
if options.extensions["largeBlob"].get("read", False):
488488
extension_outputs["largeBlob"] = {"blob": obj.cred_large_blob}
489489
else:

0 commit comments

Comments
 (0)