-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Insecure tx-sender principal authentication and Post-Conditions reliance #500
Comments
This is equivalent to tricking the user to sign a malicious transaction, which is not something the blockchain can address. How can the blockchain know that the user was tricked? The wallet would display the list of post-conditions to the user, and the user would check that they are sound. For example, a user would expect that the post-conditions only authorize the user's address, and nothing else, and would not sign a transaction which stipulated that We believe that requiring the user to inspect post-conditions is a reasonable defense against malicious websites submitting malicious transactions to the user to sign, because post-conditions are something that non-technical users can readily understand with the help of their wallet (as opposed to, e.g., the code body of the contract and the arguments to the public function). For example, the wallet can represent the user's account address as "You" or "Your account" in the post-condition list, so the user would immediately identify the presence of an unrecognized principal's post-condition, and refuse to sign. As another example, the wallet can flag |
Thanks Jude,
The described example could have been clearer. The described risk here is not that the user sings a malicious transaction but instead that an attacker can call into a vulnerable contract This specific vector is known as per stacks-network/stacks-core#2921 but hasn't been addressed.
Agreed, however as noted the available wallets don't seem to show any warnings for unconstrained post-conditions or at least didn't do so at the time of issue creation. Please see:
|
I agree that the post-conditions should be sufficient to keep users safe. There has been discussion before about the need for a mechanism for a contract to protect itself, such as |
(High) Insecure tx-sender principal authentication and Post-Conditions reliance
1. Description
The sBTC Clarity contracts rely on
tx-sender
for principal authentication in two ways.To verify the current principal is a signer.
To spend tokens from
tx-sender
or to ensure one is allowed to do so from a givensender
address.sender
to a givenrecipient
.tx-sender
in order to issue BTC at a later point.The usage of
tx-sender
seems to be recommended by SIP-010 as Stacks token standards don't have a notion of approvals. However, checks againsttx-sender
can be implicitly bypassed once there's a call into a malicious contract. To mitigate this, sBTC relies on Stacks Post-Conditions. These checks, specified outside of contract code, run indeny mode
by default, meaning no asset transfers can occur except the ones explicitly allowed. However, there are notable limitations:as-contract
, it changestx-sender
to its own address. Post-conditions are set once, before the transaction is signed, and cannot be accessed or modified during contract execution. Accordingly, if a contract (e.g.,Foo
) callsas-contract
and subsequently callssbtc-token:transfer
, an attacker could specify a post-condition such as[Foo spends ≥ 0 sBTC]
and then drain all sBTC fromFoo
.Recommendations for sBTC
tx-sender
for any auth purposes altogether as the phishing risk is insufficiently mitigated by Post-Conditions. Instead, consider implementing an approval-based mechanism such as ERC-1363approveAndCall
or ERC-2612 style permits to do so in a single transaction.Long-term considerations for Stacks
as-contract
calls.[Principal spends ≥ 0.01 STX]
can lead to full STX drainage without displaying any warnings.3. Related Issues and Pull Requests (optional):
or
andtx-sender
Trust-Machines/BNS-V2#70)The text was updated successfully, but these errors were encountered: