Unlinked address can link immediately again
The unlinkAddress function deletes the linked address record but does not clear the pending link request, so the unlinked address can immediately call linkAddress again and become linked without the master's permission. An attacker who controls a previously unlinked address could re-link to the master without approval.
Submitted by gpersoon
Impact
After a master calls unlinkAddress() to unlink an address, the address that has just been unlinked can directly link again without permission. The address that is just unlinked can call linkAddress(masterAddress) which will execute because pendingLinkAddresses is still set. Assuming the master has unlinked for a good reason it is unwanted to be able to be linked again without any permission from the master.
Note: a master can prevent this by calling cancelAddressLinkingRequest(), but this doesn’t seem logical to do
Proof of Concept
function unlinkAddress(address _linkedAddress) external {
address _linkedTo = linkedAddresses[_linkedAddress].masterAddress;
require(_linkedTo != address(0), 'V:UA-Address not linked');
require(_linkedTo == msg.sender, 'V:UA-Not linked to sender');
delete linkedAddresses[_linkedAddress];
...
}
function linkAddress(address _masterAddress) external {
require(linkedAddresses[msg.sender].masterAddress == address(0), 'V:LA-Address already linked'); // == true (after unlinkAddress)
require(pendingLinkAddresses[msg.sender][_masterAddress], 'V:LA-No pending request'); // == true (after unlinkAddress)
_linkAddress(msg.sender, _masterAddress); // // pendingLinkAddresses not reset
}
function cancelAddressLinkingRequest(address _linkedAddress) external {
...
delete pendingLinkAddresses[_linkedAddress][msg.sender]; // only location where pendingLinkAddresses is reset
Recommended Mitigation Steps
Add something like to following at the end of linkAddress:
delete pendingLinkAddresses[msg.sender][_masterAddress];
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the unlinkAddress function does not delete the pendingLinkAddresses entry, so the pending request remains valid after unlinking.
Impact
An address that was unlinked can re-link itself without the master's permission, unless the master also calls cancelAddressLinkingRequest.
What the attacker needed
Victim has previously linked an address; victim calls unlinkAddress; attacker controls the unlinked address
The fix
The linkAddress function should delete the pending link request after a successful link, or unlinkAddress should clear it.
How it was found
- A master calls unlinkAddress to remove an address.
- The unlinked address calls linkAddress with the master's address.
- The call succeeds because the pending link request was not cleared.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a master removes an address from their list, the system forgets the link but still remembers that the address had asked to be linked. That leftover request lets the removed address link itself back immediately, without the master saying yes again.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.