flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Contracts] Require auth in mint_stream_position and stop overloading token_address

Open blurbeast opened this issue 1 week ago • 4 comments

Overview & Background

mint_stream_position never calls require_auth — anyone can mint position metadata for any stream_id without the sender/recipient consenting, contradicting its own doc ("Position metadata is generated upon stream creation and linked to the stream's sender and recipient"), and no creation path calls it at all. Worse, it saves token_address: sender and token_address: recipient into StreamPositionMetadata.token_address, overloading a token-address field with account addresses, while StreamPositionCreatedEvent emits the real token under the same field name — storage and events disagree about what the field means. update_position_on_transfer later assigns position.token_address = new_recipient, confirming the field is used as an owner slot.


Technical Specification & Architecture

  1. In contracts/stream_contract/src/lib.rs:884-954, require the stream's sender/recipient auth (or mint from inside create_stream).
  2. Rename the field to owner or split into owner + token_address (types.rs:113), and make events consistent.
  3. Add auth-negative tests: a third party minting a position must fail.

Target Files

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

Acceptance Criteria

  • [ ] mint_stream_position requires sender or recipient authorization.
  • [ ] Position metadata distinguishes owner address from token address.
  • [ ] Events and storage use consistent field semantics.
  • [ ] Negative auth tests exist for all position entrypoints.

blurbeast avatar Nov 18 '26 19:11 blurbeast

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

Hi Maintainer,

I’d like to take this on. I will enforce sender/recipient authorization in mint_stream_position (contracts/stream_contract/src/lib.rs), separate owner and token address semantics consistently across StreamPositionMetadata (types.rs) and events (events.rs), and add negative authorization tests covering unauthorized third-party calls across position entrypoints.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Kami-no-san to this issue.

Kami-no-san avatar Nov 20 '26 20:11 Kami-no-san

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

i have experience

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

wagmiiii avatar Nov 21 '26 07:11 wagmiiii

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

🧑‍💻 @wagmiiii: 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 @wagmiiii as part of the Stellar Wave Program's 11th Wave 🥳

😎 @wagmiiii: 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 21 '26 17:11 drips-wave[bot]