Skip to content
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

Fix parsing errors in ctap_parse_hmac_secret #582

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stevenwdv
Copy link

@stevenwdv stevenwdv commented Oct 14, 2021

  1. saltEnc type was not checked causing an assertion in cbor_value_copy_byte_string to fail.
    Reproduce using solo-python: Go to HmacSecretExtension in extensions.py in python-fido2 and replace 2: salt_enc by 2: "hey", run solo key challenge-response.

  2. Parameters could be omitted by duplicating known keys, causing parsed_count to increase anyway. This causes reading later on of arrays that are still 0.
    Reproduce using solo-python: Go to HmacSecretExtension in extensions.py in python-fido2 and replace 1: key_agreement by -42: True, then go to dump_dict in cbor.py in python-fido2 and replace it by:

def dump_dict(data):
    items = [(encode(k), encode(v)) for k, v in data.items() if k != -42]
    if -42 in data:
        items.append((encode(2), encode(data[2])))
    items.sort(key=_sort_keys)
    return dump_int(len(items), mt=5) + b"".join([k + v for (k, v) in items])

and run solo key challenge-response.
This will duplicate saltEnc(2) while removing keyAgreement(1), so the total number of keys will remain 3, which ctap_parse_hmac_secret will happily accept. You can also choose other parameters to duplicate. We cannot directly add a duplicate key to the dict because Python will ignore it.

Is there maybe somewhere that regression tests for this can be added? Maybe I could add something to solokeys/fido2-tests, if that's the right place for this.

…ecked causing assertion to fail; parameters could be omitted by duplicating known keys, causing parsed_count to increase anyway.
@stevenwdv stevenwdv changed the title Fix parsing errors in ctap_parse_hmac_secret Fix parsing errors in ctap_parse_hmac_secret Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant