Skip to content

Require signed proof-of-ownership for Stellar wallet address linking #32

Closed

Description

@chonilius

Problem

src/context/WalletContext.tsx persists the connected address under WALLET_KEY in localStorage and, per the visible code, ties into useAuth()'s user/refresh. The likely intent (per AuthUser.stellarAddress existing in src/types/index.ts) is that a connected wallet address gets associated with the authenticated user's account server-side. This creates a security-relevant linking operation — associating a Stellar address with a GitHub-authenticated identity, presumably so escrow payouts know where to send funds — that needs to be airtight: the frontend must prove the connecting user actually controls the claimed Stellar address (typically via a signed challenge message, not just "Freighter returned this address so we'll trust it"), otherwise a malicious actor could potentially claim an address they don't control if the backend's linking endpoint trusts the frontend-submitted address without independent proof of ownership.

Why this is hard

  • You need to determine whether mergefi-backend's wallet-linking endpoint already requires a signed-challenge proof of ownership (in which case the frontend's job is to correctly implement the challenge/response flow) or whether it naively trusts an address string from the frontend (in which case this is a backend vulnerability that needs cross-repo coordination, and the frontend fix alone can't fully close the gap — but the frontend should still implement client-side best practice and flag the gap clearly).
  • If a signed-challenge flow needs to be added, this involves wallet.ts#signTransaction-adjacent work but for message signing rather than transaction signing — check whether Freighter's API (via @stellar/freighter-api) supports a signMessage-equivalent function distinct from signTransaction, since these have different security semantics (signing a transaction has fund-moving consequences; signing an arbitrary message for proof-of-ownership must be clearly scoped so the signed payload can't be replayed as something else, e.g. must include a nonce and domain-binding to prevent a captured signature being reused elsewhere).
  • Must handle the "wallet address changed" case: if a user disconnects and reconnects with a different Freighter account, does the app silently re-link to the new address (dangerous — could let a compromised or wrong account override a legitimate linked payout address without strong re-authentication), or does it require explicit re-confirmation? This needs a deliberate answer, not default behavior.
  • Needs to handle the persisted-but-stale-link case: WALLET_KEY in localStorage could reflect an address that was linked in a previous session but is no longer the backend's source of truth if the user linked a different address from another device — WalletContext's reconciliation logic (or lack thereof) between localStorage, live Freighter state, and backend-recorded AuthUser.stellarAddress needs to be audited and fixed to avoid the UI presenting a wallet as "connected" when it's actually not the authoritative linked address.

Scope

  • Audit whether wallet-address linking currently includes any proof-of-ownership step; if not, implement a signed-challenge (nonce + domain-bound message, signed via Freighter, verified server-side) flow and clearly document the required backend verification as a cross-repo dependency if not already present.
  • Add explicit re-confirmation UX for re-linking when the live Freighter address differs from the backend-recorded stellarAddress.
  • Fix WalletContext's reconciliation logic to treat AuthUser.stellarAddress (backend source of truth) as authoritative over the localStorage-persisted address, syncing/correcting the local value rather than trusting it blindly.

Acceptance criteria

  • Linking a wallet requires a signed proof-of-ownership message, not just a reported address.
  • Reconnecting with a different Freighter account than the backend's recorded address triggers explicit user confirmation before any re-link action, and never silently overrides the record without it.
  • WalletContext's displayed connection state always reconciles to the backend's recorded address as authoritative on load.

Activity

  1. added
    very hard
    security
    on Jul 15, 2026
  2. added
    GrantFox OSS
    Maybe Rewarded
    Official Campaign | FWC26
    on Jul 15, 2026
  3. added
    Stellar Wave
    on Aug 25, 2026
  4. abdulwahabmonilola-ctrl commented on Aug 25, 2026

    @abdulwahabmonilola-ctrl

    @abdulwahabmonilola-ctrl has applied to work on this issue as part of the Stellar Wave Program's 8th wave.

    Hi Maintainer,kindly assign the task to me.

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

  5. tecmalik commented on Aug 25, 2026

    @tecmalik

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

    please assign me to this issue i would love to work on it

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

  6. Waffiyyi commented on Aug 25, 2026

    @Waffiyyi

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

    I would love to work on this issue. Please assign this to me.

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

  7. Max347bot commented on Aug 25, 2026

    @Max347bot

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

    Hi Maintainer! I'm a senior developer with experience building high-quality, production-ready software. I'd love to take on this issue and deliver a clean, well-tested solution that aligns with the project's standards. Please assign it to me—I'm ready to get started and contribute effectively.

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

  8. gerani1 commented on Aug 26, 2026

    @gerani1

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

    hello, i would like to work on this issue

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

  9. drips-wave commented on Aug 26, 2026

    @drips-wave

    Congratulations, @gerani1! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on August 31, 2026.

    🧑‍💻 @gerani1: 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 🌊

  10. grantfox-oss commented on Sep 29, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @gerani1's PR #575 was approved and merged by @chonilius.

    🏆 @gerani1: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (236 total points). Track your full progress on GrantFox.

    👏 Great work, @gerani1! Keep contributing to MergeFi.

  11. drips-wave commented on Sep 29, 2026

    @drips-wave

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

    😎 @gerani1: You earned 200 Points for completing this issue! After the current Wave ends, 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.

  12. removed
    Stellar Wave
    on Oct 15, 2026
  13. added
    Stellar Wave
    on Oct 15, 2026
  14. removed
    Stellar Wave
    on Oct 15, 2026
  15. added
    Stellar Wave
    on Oct 15, 2026
  16. removed
    Stellar Wave
    on Oct 15, 2026
  17. added
    Stellar Wave
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

GrantFox OSSMaybe RewardedOfficial Campaign | FWC26Stellar Wavesecurityvery hard

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions