Open code423n4 opened 1 year ago
We accept the issue, we are not sure about its severity
donosonaumczuk marked the issue as disagree with severity
This is somewhere between "function incorrect as to spec" and "the function of the protocol or its availability could be impacted". As the given example ("a module that pays profiles to perform a follow, thus requiring the transaction executor to deposit an initial amount of tokens") relies on a module who's dev team would have checked the doc and not the code, I think it's an instance of "function incorrect as to spec", so of Low severity.
Picodes changed the severity to QA (Quality Assurance)
Hi @Picodes, I don't really understand why this issue isn't qualified for medium severity.
If you take a look at all the other meta-transaction related functions, such as postWithSig()
or commentWithSig()
, it becomes quite apparent that transactionExecutor
is always meant to be the signer instead of the relayer.
This issue has pointed out an error in the code that causes transactionExecutor
to be set to the wrong address in setFollowModule()
, which contradicts all the other meta-transaction related functions in the protocol. Therefore, in my opinion, the function is working incorrectly/differently than intended due to an error, which would fall under "function of the protocol could be impacted".
I don't think it would be fair to consider this "function incorrect as to spec", since even if the contest's README didn't exist and there was no specification, this would still have been considered a bug.
Hope you could reconsider your judgement here, thanks!
@MiloTruck there is a bug for sure, but what is its impact? I'll give it more thought but to me it's like a bug in a view function so Low for "assets are not at risk: state handling" or "function incorrect as to spec". "function of the protocol could be impacted" would be if this would lead to an important functionality not being available
Lines of code
https://github.com/code-423n4/2023-07-lens/blob/main/contracts/libraries/ProfileLib.sol#L100
Vulnerability details
Bug Description
In
ProfileLib.sol
, thesetFollowModule()
function calls_initFollowModule()
withmsg.sender
as thetransactionExecutor
:ProfileLib.sol#L100
_initFollowModule()
then initializes the follow module withtransactionExecutor
:ProfileLib.sol#L110-L118
However, as
setFollowModule()
is called bysetFollowModuleWithSig()
, the implementation above is incorrect. WhensetFollowModuleWithSig()
is called during a meta-transaction, the relayer's address will be passed toinitializeFollowModule()
as thetransactionExecutor
, instead of the signer.This contradicts the contest's README, which states that
transactionExecutor
should be set to the signer in a meta-transaction:Impact
When
setFollowModuleWithSig()
is called during a meta-transaction, the follow module will be initialized with the relayer as the transaction executor instead of the signer.This could become problematic for follow modules that use
transactionExecutor
during initialization (eg. a module that pays profiles to perform a follow, thus requiring the transaction executor to deposit an initial amount of tokens).Proof of Concept
The Foundry test below demonstrates how
setFollowModuleWithSig()
incorrectly initializes follow modules with the relayer as the transaction executor. It can be run with the following command:Recommended Mitigation
Consider adding a
transactionExecutor
parameter tosetFollowModule()
and passing it to_initFollowModule()
instead ofmsg.sender
:ProfileLib.sol#L92-L101
In
setFollowModuleWithSig()
, passsignature.signer
as thetransactionExecutor
:LensHub.sol#L138-L146
Assessed type
Context