Skip to content

execute_flash_loan's repayment step cannot pass authorization on a real network (only works under mock_all_auths) #315

Description

@abayomicornelius

Area

Investment Vault / Security

Complexity

Medium-hard

File(s)

investment_vault/src/lib.rs:1451-1482 (specifically line 1478); tests at investment_vault/src/test.rs:2627-2729

Problem

After client.flash_loan_callback(...) returns, the vault calls Base::transfer(&env, &borrower, &MuxedAddress::from(&vault), amount + fee). Base::transfer calls from.require_auth() on borrower — but borrower is a contract address whose authorization window was tied to its own flash_loan_callback invocation, which has already returned by this point. A contract cannot pre-authorize a debit the vault initiates against it after the fact unless it implements a custom account/auth contract. All existing flash-loan tests pass only because env.mock_all_auths() is set globally, masking that this would fail real signature verification on any live network.

Scope

In:

  • Redesign so the borrower repays by calling into the vault/transfer from within its own callback frame (the standard flash-loan repayment pattern), rather than the vault debiting the borrower afterward.

Out:

  • Fee schedule changes.

Acceptance Criteria

  • A test using scoped mock_auths (not mock_all_auths) demonstrates repayment succeeds under real auth requirements
  • Existing flash-loan tests continue to pass

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcontractSmart contract logic and designsecuritySecurity concerns and audit items

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions