Skip to content

Possible integer overflow in Stateful_Key_Index_Registry #5661

Description

@TJ-91

In #5358 (comment) Stephan Ehlen points out that the XMSS^MT implementation first advances the index and then refuses to sign if the state is exhausted, advancing the index past the valid range.

This does not seem like an issue at first, since we check whether the index exceeds the total number of signatures afterwards. However, when repeatedly trying to sign with an exhausted key, at some point, you will overflow the uint64_t counter and then end up reserving the first leaf nodes again, breaking the security of the system. This affects all stateful hash signature algorithms.

I propose to re-design the registry s.t. it does not advance the index if the max is reached. Either the reserve_next_index must receive the maximum number of signatures as a parameter, or, when registering a key, it must already provide the maximum number of signatures and store it alongside the index. Then, after locking, we can check if the index can be advanced or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions