Skip to content

fix(web): receiver snippet requires the owner's own flash-loan in the callback - #144

Merged
mattglory merged 1 commit into
mattglory:mainfrom
unixwhisperer:security-lead/web-snippet-owner-callback
Oct 27, 2026
Merged

mattglory merged 1 commit into
mattglory:mainfrom
unixwhisperer:security-lead/web-snippet-owner-callback

Conversation

@unixwhisperer

Copy link
Copy Markdown
Collaborator

Follow-up to #136, as Matt asked in his review comment there.

flashstack-stx-core calls execute-stx-flash without as-contract, so inside the callback tx-sender is whoever called flash-loan. With only the arm check, a stranger could call flash-loan with the exact armed amount before the owner's own transaction landed. This adds the same check #140 added to hk-sbtc-real-receiver-v2:

;; only the owner's own flash-loan can use the arm
(asserts! (is-eq tx-sender (var-get owner)) (err u403))

It's applied to both copies of the snippet (/receivers and the landing page), along with a matching line in the snippet's header comment.

Checked in simnet. I extracted the snippet from each page, pointed it at the local core and trait, and ran it in a throwaway worktree. None of this is committed.

  • Before this change, the stranger's flash-loan with the armed amount returned (ok true). That's the front-run.
  • After it, the stranger gets (err u403), the owner's own loan returns (ok true), and a second loan gets (err u402) (the arm is single-use).

… callback

Follow-up to mattglory#136, per Matt's review. The core calls execute-stx-flash
without as-contract, so tx-sender is whoever called flash-loan. With only
the arm check, a stranger could call flash-loan with the exact armed
amount before the owner's own transaction landed. The callback now also
asserts tx-sender == owner (err u403), the same check mattglory#140 added to
hk-sbtc-real-receiver-v2.

Checked in simnet, with the snippet extracted from both pages and pointed
at the local core: before this change the stranger's front-run returned
(ok true); after it, it returns (err u403). The owner's own loan still
succeeds, and the arm stays single-use (err u402).
@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

@unixwhisperer is attempting to deploy a commit to the matt glory's projects Team on Vercel.

A member of the Team first needs to authorize it.

@unixwhisperer unixwhisperer changed the title fix(web): receiver snippet requires the owner's own flash-loan in the callback fix(web): receiver snippet requires the owner's own flash-loan in the callback Oct 27, 2026

@mattglory mattglory left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Verified: closes exactly the front-run gap flagged on #136. Approving.

@mattglory
mattglory merged commit 6754aa5 into mattglory:main Oct 27, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants