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

fix: only allow whitelisted relayer account to send IBC relayer messages #614

Merged

Conversation

zale144
Copy link
Contributor

@zale144 zale144 commented Dec 6, 2024

Description


Closes #615

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow-up issues.

PR review checkboxes:

I have...

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Targeted PR against the correct branch
  • included the correct type prefix in the PR title
  • Linked to the GitHub issue with discussion and accepted design
  • Targets only one GitHub issue
  • Wrote unit and integration tests
  • Wrote relevant migration scripts if necessary
  • All CI checks have passed
  • Added relevant godoc comments
  • Add an issue in the e2e-tests repo if necessary

SDK Checklist

  • Import/Export Genesis
  • Registered Invariants
  • Registered Events
  • Updated openapi.yaml
  • No usage of go map
  • No usage of time.Now()
  • Used fixed point arithmetic and not float arithmetic
  • Avoid panicking in Begin/End block as much as possible
  • No unexpected math Overflow
  • Used sendCoin and not SendCoins
  • Out-of-block compute is bounded
  • No serialized ID at the end of store keys
  • UInt to byte conversion should use BigEndian

Full security checklist here


For Reviewer:

  • Confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • Confirmed all author checklist items have been addressed

After reviewer approval:

  • In case the PR targets the main branch, PR should not be squash merge in order to keep meaningful git history.
  • In case the PR targets a release branch, PR must be rebased.

@zale144 zale144 self-assigned this Dec 6, 2024
@zale144 zale144 requested a review from a team as a code owner December 6, 2024 08:58
keruch
keruch previously approved these changes Dec 6, 2024
@mtsitrin
Copy link
Collaborator

mtsitrin commented Dec 6, 2024

@omritoptix we wanted whitelisted to allow client creation
the on-going relaying over established channel should be permissionless

Copy link
Contributor

@omritoptix omritoptix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed we should reject mixed messages which contains IBC messages

@omritoptix
Copy link
Contributor

@omritoptix we wanted whitelisted to allow client creation

yea true but don't think it's worth extra effort. mostly thought it's gonna reduce work.

omritoptix
omritoptix previously approved these changes Dec 8, 2024
Copy link
Contributor

@omritoptix omritoptix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great job!
small nits.

server/ante/bypass_ibc_fee_decorator.go Outdated Show resolved Hide resolved
server/ante/bypass_ibc_fee_decorator.go Outdated Show resolved Hide resolved
Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple small code things.

Biggest question is if this breaks actual IBC gov props. Does it?

server/ante/bypass_ibc_fee_decorator.go Outdated Show resolved Hide resolved
Comment on lines 46 to 67
msgs, err = n.getAllFinalMsgs(ctx, msgs, 0)
if err != nil {
// This error is not critical; just log and fall into the default fee handling
ctx.Logger().With("module", "BypassIBCFeeDecorator", "err", err).
Error("Failed to check if the tx is from the whitelisted relayer")
return ctx, err
}
if whitelisted {
// The tx is from the whitelisted relayer, so it's eligible for the fee exemption
return next(ctx, tx, simulate)

totalMsgs := len(msgs)
ibcCount := countIBCMsgs(msgs)

if ibcCount == totalMsgs {
// all are IBC messages
ibcWhitelisted, err := n.isIBCWhitelistedRelayer(ctx, msgs)
if err != nil {
return ctx, err
}
if ibcWhitelisted {
return next(ctx, tx, simulate)
}
return ctx, fmt.Errorf("not all signers whitelisted")
} else if ibcCount > 0 {
// mixed: some IBC and some non-IBC
return ctx, fmt.Errorf("mixed IBC and non-IBC messages in the same transaction not allowed")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is gonna let IBC gov proposals work as normal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a governance proposal includes IBC messages and the signer is not whitelisted, the code will reject the transaction

server/ante/bypass_ibc_fee_decorator.go Outdated Show resolved Hide resolved
server/ante/bypass_ibc_fee_decorator.go Outdated Show resolved Hide resolved
server/ante/bypass_ibc_fee_decorator.go Outdated Show resolved Hide resolved
server/ante/bypass_ibc_fee_decorator.go Show resolved Hide resolved
server/ante/bypass_ibc_fee_decorator.go Show resolved Hide resolved
server/ante/bypass_ibc_fee_decorator.go Outdated Show resolved Hide resolved
@omritoptix
Copy link
Contributor

omritoptix commented Dec 8, 2024

Biggest question is if this breaks actual IBC gov props. Does it?

great point @danwt. don't think we actually need to prevent gov prop nested messages either way. @zale144

UPDATE: checked and it's a different message type so should be fine either way (ClientUpdateProposal)

@omritoptix omritoptix merged commit 5cc3d81 into main Dec 8, 2024
7 checks passed
@omritoptix omritoptix deleted the zale144/block-non-whitelisted-accs-from-creating-ibc-client branch December 8, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

make sure ibc create client messages can't bypass whitelisted addresses by being wrapped (i.e with authz)
5 participants