Skip to content
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

Resolve SSW-001 + SSW-002 #53

Merged
merged 7 commits into from
Feb 29, 2024
Merged

Conversation

Quantumplation
Copy link
Member

@Quantumplation Quantumplation commented Feb 11, 2024

Resolves SSW-001, where the pool token didn't have to be paid to the pool address.

Also resolves the accidental finding that we don't check for the pool output
address! Was discovered accidentally when we thought we fixed SSW-001 😅

These likely crept in because we were focused on checking the staking credential, from a previous finding, but this would have been a very critical bug!

Resolves the critical finding that we don't check for the pool output
address!

This likely crept in because we were focused on checking the staking
credential, but this would have been a fairly critical bug!
@Quantumplation Quantumplation changed the title Resolves SSW-001 Resolve SSW-001 Feb 12, 2024
@francolq
Copy link
Collaborator

Hi! SSW-001 is about pool creation, so the fix should be done in the minting policy, not in the spending validator.

@Quantumplation
Copy link
Member Author

Hmm. Is this related to a different finding then? Cause I think this was definitely a different bug then.

@francolq
Copy link
Collaborator

This PR is actually solving a new finding of an issue that was introduced at some point after or while solving SSW-302, and is still present in
current version of the main branch (00d71b1):

FINDING: The payment part of the output address is not being checked to be correct under the "PoolScoop" redeemer.

The required check was there at some point but it was lost (I couldn't find where):

expect pool_output.address == pool_input.address

This PR is solving the issue, but in a way that now there is a redundant check under the WithdrawFees redeemer, where the payment part is checked again.

check for payment part of output address is already done
@cardenaso11
Copy link
Contributor

Didn't want to force push a rebase as requested, so I've got tests up here. Rebase was necessary to put these into the tests folder as requested: https://github.com/SundaeSwap-finance/sundae-contracts/tree/pi/SSW-001-pool-output-address-necessary-rebase

@cardenaso11
Copy link
Contributor

Can force push the rebase onto here if requested, or clone the PR

@Quantumplation Quantumplation changed the title Resolve SSW-001 Resolve SSW-??? Feb 29, 2024
@Quantumplation
Copy link
Member Author

@cardenaso11 the correct way to deal with the "neccesary rebase" here, IMO, is to just merge main into this branch, since it has changes we depend on, and then apply your changes; I've gone ahead and done that for you by cherry-picking the commit from the other branch

@@ -635,3 +635,14 @@ test mint_test() {
mint_test_modify(identity, identity, identity, identity)
}

// make sure pool_output.address is checked to be the pool address
test mint_test_wrong_address () {
let minted = mint_test_modify(
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this is actually testing the bug that was fixed; the bug fixed in this PR is related to spending the pool UTXO as part of a scoop, and ensuring we pay the pool back into the pool script. I can see how this is confusing, because originally this PR was intended to fix the issue you pointed out, and it turns out I misinterpreted the finding and fixed a different critical issue and didn't fix the PR title.

I was going to split them into two different PRs, but i'll just fix both issues in the same PR.

Also, given that we want these transactions to fail, this test also isn't testing the correct thing; The fact that it's passing is indicative that we haven't actually fixed the issue 😅

We want to make sure that these transactions *fail* if we spend to the wrong address on the output
Add tests for the main issue that was fixed, and some other things related to tweaking the pool address
*Actually* resolve SSW-001; turns out I had misread the finding and stumbled on another finding where we weren't checking the output address on the scoop path. Woops!  This shoudl fix SSW-001, which was related to pool minting, and fixes some tests related to it
@Quantumplation
Copy link
Member Author

@francolq ok, can you re-review? this should now actually fix the issue (plus the other un-numbered finding), plus some tests!

@Quantumplation Quantumplation changed the title Resolve SSW-??? Resolve SSW-001 + SSW-??? Feb 29, 2024
@francolq
Copy link
Collaborator

Ok, I will also numerate the finding and add it to the audit report.

@Quantumplation Quantumplation changed the title Resolve SSW-001 + SSW-??? Resolve SSW-001 + SSW-002 Feb 29, 2024
Copy link
Collaborator

@francolq francolq left a comment

Choose a reason for hiding this comment

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

LGTM. This is finally resolving SSW-001 and SSW-002.

@rrruko rrruko self-requested a review February 29, 2024 18:19
@Quantumplation Quantumplation merged commit d43f212 into main Feb 29, 2024
1 check passed
@Quantumplation Quantumplation deleted the pi/SSW-001-pool-output-address branch February 29, 2024 18:22
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.

4 participants