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

Do not emit events upon ack status failure #1324

Closed
seanchen1991 opened this issue Aug 27, 2024 · 1 comment
Closed

Do not emit events upon ack status failure #1324

seanchen1991 opened this issue Aug 27, 2024 · 1 comment
Labels
A: bug Admin: something isn't working O: security Objective: aims to enhance security and improve safety
Milestone

Comments

@seanchen1991
Copy link
Contributor

seanchen1991 commented Aug 27, 2024

Bug Summary

Amulet alerted us to a security report regarding a vulnerability that is similar in nature to the ibc-go Huckleberry vulnerability. We should address the cause(s) of the vulnerability in ibc-rs and communicate with Amulet once the issue has been resolved satisfactorily.

To be clear, ibc-rs's application implementations, ics20 and ics721, are safe from this vulnerability, since those implementations always return ModuleExtras::Empty() upon failure in the packet_recv flow. The main issue to be addressed here is more to do with limiting the impact on downstream implementors.

Details

From the security report we received, upon a failed acknowledgment receipt, ibc-rs will still emit events unconditionally, potentially for transfers / deposits that failed where no events should be emitted at all.

@rnbguy's analysis points to this line as being the possible main culprit:

    Err((extras, error)) => (extras, AcknowledgmentStatus::error(error.into())),

where upon an error being encountered in the logic for handling the execution of transfers, this function could still potentially emit events in the form of extras when it shouldn't.

Per Rano's suggestion, this line should be changed to

    Err((extras, error)) => (ModuleExtras::Empty(), AcknowledgmentStatus::error(error.into())),

to ensure that no extraneous events are emitted when an AcknowledgmentStatus::error is encountered.

Once this issue has been addressed in the ibc-rs codebase, the projects that have thus far integrated ibc-rs should be contacted about the possible impact towards them.

Version

ibc-rs v0.54.0 and older

@seanchen1991 seanchen1991 added A: bug Admin: something isn't working O: security Objective: aims to enhance security and improve safety labels Aug 27, 2024
@seanchen1991 seanchen1991 added this to the 0.55.0 milestone Aug 27, 2024
@github-project-automation github-project-automation bot moved this to 📥 To Do in ibc-rs Aug 27, 2024
@seanchen1991 seanchen1991 changed the title Address Huckleberry vulnerability in ibc-rs Do not emit events upon ack status failure Aug 27, 2024
@rnbguy
Copy link
Member

rnbguy commented Aug 28, 2024

It appears that this issue is not resolved yet in ibc-go. They had to revert the patch from the jump blog via cosmos/ibc-go#5541 because the ICA application module requires the error events.

As an immediate fix, ibc-go emits the module error events with attribute keys prefixed with ibccallbackerror-.

Maybe we can follow a similar pattern and add a separate event here,

https://github.com/cosmos/ibc-rs/blob/60ff9bd16d43d3475ba443069868959f0fdc5bd6/ibc-core/ics25-handler/types/src/events.rs#L91

ModuleError(ModuleEvent)

to handle/emit successful and failed module events differently.

We also confirmed our ics20 and ics721 implementations return empty module events at recv_packet error - so they are completely safe from this bug.

Since the issue is not fully addressed at IBC protocol level and needs further exploration, we will close this for now and open in the future if needed.

@rnbguy rnbguy closed this as completed Aug 28, 2024
@github-project-automation github-project-automation bot moved this from 📥 To Do to ✅ Done in ibc-rs Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A: bug Admin: something isn't working O: security Objective: aims to enhance security and improve safety
Projects
None yet
Development

No branches or pull requests

2 participants