Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
During liquid stake and forward, the autopilot "receiver" of the inbound transfer becomes the "sender" of the transfer back to the host. However, downstream applications shouldn't trust this new "sender" so we need to use a generated address instead.
To be clear, using the original sender would not introduce an attack vector on Stride. However, it could introduce an attack vector on a different zone, if they were to trust the sender. The hashed sender is used to make the assumption more explicit that new zones should not trust the address.
This bug appeared in PFM (if more context is needed):
Design Considerations
There wasn't an immediately obvious way to implement this. The complexity arises in that the address used for the inbound transfer doesn't always line up with the address used in the autopilot action.
We send the packet down the stack first to complete the inbound transfer, this means there's a few ways we could implement this:
Two additional constraints (not that these were impossible, but I think they would have made the code hard to follow)
All that said, I opted with the approach of doing the inbound transfer with the hashed address and doing a bank send later if needed. Very open to a better way of doing this though if you can think of one!
High Level Design
AutopilotTransferMetadata
) to replaceFungibleTokenPacketData
and include the hashed senderBrief Changelog
GenerateHashedReceiver
to generate the hashed address (body of function taken from PFM)AutopilotTransferMetadata
which stores the original packet data + the hashed senderPacketForwardMetadata
toAutopilotActionMetadata
AutopilotTransferMetadata
into each action's function instead ofFungibleTokenPacketData