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

Change outputs are confirmed without being received #68

Open
r4mmer opened this issue May 22, 2024 · 0 comments · Fixed by #70
Open

Change outputs are confirmed without being received #68

r4mmer opened this issue May 22, 2024 · 0 comments · Fixed by #70
Assignees

Comments

@r4mmer
Copy link
Member

r4mmer commented May 22, 2024

Description

When a transaction is divided in chunks and the last chunk only has change outputs, the change outputs on the last chunk are confirmed before being received by the device, which sends the signing to the next step.
When the client tries to send the next tx chunk it fails with BAD_STATE due to state protection.

Reproducing

A transaction that mimics this scenario without custom tokens (to make this simpler) was made, divided in chunks and added APDU headers.
The transaction was made with change protocol v1 but it also can happen with the old protocol since we only need 1 change output on the last chunk.

chunk 1

e0060000ff010400058000002c8000011880000000000000000000000002058000002c8000011880000000000000000000000203058000002c8000011880000000000000000000000304058000002c800001188000000000000000000000040001000205d57eff854a615612b5d089f667a32161b347344dd62dd7315f68dd508b17e1ddb300006d39806ee6bb56cc06b50723be09506b11ec11dde388a720ef1f68a9b2e6950aa200000000133800001976a91483d3ee6df8bee68f8043d3d7f7feba807a683dfe88ac000018f100001976a9142d9d5cc2969d59836204376a5c4927f84ca4c7b288ac0000113c00001976a91407a6e2e3c254b330de8d1b73bb3418e0

chunk 2

e0060001469466b45388ac0000206800001976a914279116ab46ab6111641fe2ad24bd8bf5b9636ad588ac000023b200001976a914d035b2d6e8663bbaa6c03e69df6953d5be25575288ac

Solution

Stop confirming outputs when we reach the last output received in the latest APDU call.
This means we need to keep track of the number of parsed outputs and only confirm outputs until the parsed ones, anything more should throw a request for more data.

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 a pull request may close this issue.

1 participant