Collection admins can inject arbitrary collection javascript libraries
Vulnerability Explanation
inside NextGenCore#updateCollectionInfo, a collection admin can update their collection with an arbitrary collection library or through a generative script.
When tokenURI() is called, the collection library is used to construct a json string which includes the base64 encoding of the collection library and script being embedded into into an HTML string..
data:application/json;utf8,{"name":"here is my name","description":"here is my desc","image":"","attributes":[],"animation_url":"data:text/html;base64,PGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5PjxzY3JpcHQgc3JjPSJ3d3cubGlicmFyeS5jb20iPjwvc2NyaXB0PjxzY3JpcHQ+d3d3LnNjcmlwdC5jb208L3NjcmlwdD48L2JvZHk+PC9odG1sPg=="}
The arbitrary javascript will then be rendered in a users browser and can result in
Login cookies being stolen
modification of HTML page resulting in users being social engineered
escalation to RCE if access to 0-day or a user is using an outdated browser with publicly available exploits
Tools Used
VIM
Recommended Mitigation Steps
Only allow collection owners to add whitelisted javascript libraries and scripts that are approved by the owner.
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/NextGenCore.sol#L353 https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/NextGenCore.sol#L246
Vulnerability details
Impact
Collection admins can inject arbitrary collection javascript libraries
Vulnerability Explanation
inside
NextGenCore#updateCollectionInfo
, a collection admin can update their collection with an arbitrary collection library or through a generative script.When
tokenURI()
is called, the collection library is used to construct a json string which includes the base64 encoding of the collection library and script being embedded into into an HTML string..Here is what the constructed string looks like:
The arbitrary javascript will then be rendered in a users browser and can result in
Tools Used
VIM
Recommended Mitigation Steps
Only allow collection owners to add whitelisted javascript libraries and scripts that are approved by the owner.
Assessed type
Invalid Validation