flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Contracts] Require auth in update_position_on_complete and type the status argument

Open blurbeast opened this issue 1 week ago • 5 comments

Overview & Background

update_position_on_complete(env, stream_id, role, status: String) takes no caller and performs no require_auth. It re-saves unchanged metadata (the comment admits StreamPositionMetadata has no status field) and emits StreamPositionSettledEvent with the caller-supplied free-form status string. Any address can emit a settlement event for any stream/role with any status text, letting an attacker spoof settlement records consumed by indexers. The function is also a storage no-op — its only observable effect is the spoofable event.


Technical Specification & Architecture

  1. Require the stream's sender/recipient (or admin) auth in contracts/stream_contract/src/lib.rs:1011-1037.
  2. Type the status argument as an enum instead of String.
  3. Either drop the write or actually persist a status field.
  4. Add auth-negative tests.

Target Files

  • contracts/stream_contract/src/lib.rs
  • contracts/stream_contract/src/types.rs
  • contracts/stream_contract/src/events.rs

Acceptance Criteria

  • [ ] Unauthenticated calls fail.
  • [ ] Status values are constrained to a typed enum.
  • [ ] Events cannot be spoofed by third parties.

blurbeast avatar Nov 18 '26 19:11 blurbeast

@heymide has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

I can take this on. I've gone through the details and will provide a well-tested solution aligned with the project standards.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @heymide to this issue.

heymide avatar Nov 20 '26 13:11 heymide

@Thobadd has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

Hi maintainer,

I'd like to take a shot at this issue. I went through the checkout flow and looked at the XLM checkout modal component. I can see exactly what's happening when a user rejects the transaction in Freighter — the promise gets rejected, but there's no catch around it. The modal just sits there in its loading state, leaving the user staring at a spinner with no feedback. Since rejecting a transaction is a normal thing to do, the app shouldn't freeze.

My plan is to wrap the Freighter signing call in a try/catch and specifically detect the rejection case. From what I've seen with the Freighter API, user rejection usually comes back as an error containing something like "User declined" or "User rejected the request." I'll check for that pattern to distinguish an intentional rejection from a real failure like a network issue. On rejection, I'll reset the modal's loading state so the UI doesn't freeze and surface a friendly toast like "Transaction rejected in Freighter. No funds were sent." For genuine errors, I'll keep a separate message so we don't conflate the two.

A couple of things I want to get right: first, the loading state needs to be reset in a finally block so we never leave the button disabled if something unexpected throws. Second, I'll make sure the toast component matches the pattern already used in the codebase rather than introducing a new one. I'll also manually verify the flow by rejecting in the Freighter extension to confirm the modal returns to a usable state.

I've contributed to a few React/TypeScript projects before and I'm comfortable with error-handling patterns like this. I'll keep the PR scoped to just this component, and the PR description will include the required closing tag as requested. Happy to adjust the message copy if you have a preferred tone. Let me know if you'd like me to proceed or if there's anything else you want covered in scope.

Thanks

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Thobadd to this issue.

Thobadd avatar Nov 20 '26 16:11 Thobadd

@achiever2110 has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

i ca solve

ℹ️ Repo Maintainers: To accept this application, review their application or assign @achiever2110 to this issue.

achiever2110 avatar Nov 21 '26 07:11 achiever2110

Congratulations, @achiever2110! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.

🧑‍💻 @achiever2110: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Nov 21 '26 07:11 drips-wave[bot]

This issue has been completed by @achiever2110 as part of the Stellar Wave Program's 11th Wave 🥳

😎 @achiever2110: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Nov 22 '26 20:11 drips-wave[bot]