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

Adversary can craft arbitrary PaymentId due to type confusion in deserialization #6891

Open
SWvheerden opened this issue Mar 25, 2025 · 0 comments · May be fixed by #6901
Open

Adversary can craft arbitrary PaymentId due to type confusion in deserialization #6891

SWvheerden opened this issue Mar 25, 2025 · 0 comments · May be fixed by #6901
Assignees

Comments

@SWvheerden
Copy link
Collaborator

An attacker with control over the user_data field in a PaymentId::Open can
manipulate its deserialization to be interpreted as a different type, such as
PaymentId::TransactionInfo. This can lead to unintended transaction
processing behavior depending on how the PaymentId is used.
The core issue lies in the deserialization logic, which relies on byte length and
pattern matching rather than a definitive type identifier. When handling larger
payloads, the function first attempts to parse them as AddressAndData. If that
fails, it defaults to TransactionInfo, creating an opportunity for type
confusion.
An attacker can exploit this by crafting the user_data field in a
PaymentId::Open to:

Be too large for a simple Open variant.
Contain bytes that fail TariAddress parsing, preventing it from being
interpreted as AddressAndData.
Have a structure that matches TransactionInfo, allowing control over
critical transaction parameters such as amount, fee, weight, and
recipient_address.

Recommendation

Introduce an explicit type tag as the first byte in all serialized PaymentId
variants to ensure unambiguous type identification.

@hansieodendaal hansieodendaal self-assigned this Mar 31, 2025
@hansieodendaal hansieodendaal linked a pull request Mar 31, 2025 that will close this issue
4 tasks
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.

2 participants