Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: medium
Invalid

The Soulmate::readMessageInSharedSpace function is available for use by individuals who have previously undergone divorce

Summary

  • This function is intended to provide a means for individuals who are not divorced and are committed to one another to read through a shared space on the blockchain. However, the current implementation does not adequately restrict access, allowing divorced parties to continue reading messages in the shared space, which is contrary to the intended design and usage.

Vulnerability Details

  • This function have no check for the msg.sender for checking the person is Soulmate or Divorce

/// @notice Allows any soulmates with the same NFT ID to read in a shared space on blockchain.
@> function readMessageInSharedSpace() external view returns (string memory) {
// Add a little touch of romantism
return
string.concat(
sharedSpace[ownerToId[msg.sender]],
", ",
niceWords[block.timestamp % niceWords.length]
);
}

POC

  • this is a test function which test the Soulmate::readMessageInSharedSpace function.

  • this function pass which make the current implementation does not adequately restrict access, allowing divorced parties to continue reading messages in the shared space

function test_readMessageInSharedSpace() public {
_mintOneTokenForBothSoulmates();
string memory message = "Hello!!";
vm.prank(soulmate1);
soulmateContract.writeMessageInSharedSpace(message);
vm.prank(soulmate2);
soulmateContract.getDivorced();
vm.prank(soulmate2);
string memory receiveMessage = soulmateContract.readMessageInSharedSpace();
bytes memory s1Bytes = bytes(message);
bytes memory s2Bytes = bytes(receiveMessage);
for(uint256 i = 0; i < s1Bytes.length ; i++){
assertEq(s1Bytes[i], s2Bytes[i]);
}
}

Impact

  • Lack of Access Control

  • Inadequate Design and Usage of Function

Tools Used

  • Manual Review

Recommendations

  • we can create these changes to correct the design and usage of this function.

+ error Soulmate__CoupleIsDivorced();
+ modifier isSoulmates {
+ if(isDivorced()){
+ revert Soulmate__CoupleIsDivorced();
+ }
+ _;
+ }
- function readMessageInSharedSpace() external view returns (string memory) {
+ function readMessageInSharedSpace() external view isSoulmates returns (string memory) {
// Add a little touch of romantism
return
string.concat(
sharedSpace[ownerToId[msg.sender]],
", ",
niceWords[block.timestamp % niceWords.length]
);
}
Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.