Closed code423n4 closed 1 year ago
OpenCoreCH marked the issue as sponsor confirmed
Very good PoC, thanks for that! I think I'll ultimately go with the approach the warden suggested, as handling all edge cases properly on-chain is quite complex and error-prone.
Very good PoC, thanks for that! I think I'll ultimately go with the approach the warden suggested, as handling all edge cases properly on-chain is quite complex and error-prone.
While I'd say this issue is extremely comprehensive, I don't really see any security vulnerability. These improvements are mostly cosmetic in nature so I think it makes sense to downgrade to QA.
0xleastwood changed the severity to QA (Quality Assurance)
This previously downgraded issue has been upgraded by 0xleastwood
This previously downgraded issue has been upgraded by 0xleastwood
0xleastwood marked the issue as duplicate of #59
After further consideration, this seems to be a pretty important aspect of the protocol that should be addressed.
0xleastwood marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2023-03-canto-identity/blob/077372297fc419ea7688ab62cc3fd4e8f4e24e66/canto-bio-protocol/src/Bio.sol#L43
Vulnerability details
Impact
Proof of Concept
The task of the
tokenURI
method is to return ajson
object with a generated svg where the biography up to 200 bytes long is divided by 40 per line. This was implemented by iterating through each character of thebio
, with a large number of operations. Which makes it difficult to understand, increases the possibility of making mistakes, the cost of a method call, etc.I recommend transferring the line break to the shoulders of SVG tags and styles, which will simplify and make the code many times cheaper, and get rid of potential errors.
An example is given below:
Old Flow
Code
Actual code code +-43 lines, 14 variables, a lot differens operations
Old SVG format
Old SVG View (set additional 400px:200px):
New Flow:
SVG format
New SVG view from example (set additional 400px:200px):
This is just an example. The point is to use svg, css tags in order to reduce the complexity of the code many times
We can see that there is more plain text.
But now we don't have to worry about the following things:
Now we need to return only the template and insert the bio in the center of the template Code will look like:
We see a colossal simplification, With the avoidance of many moments
Compare this with actual code code the method became cheaper by an order of magnitude, the complexity was reduced to a minimum. Now there are only 2 limitations for the biography, these are: length, and limitations to the
XML
textTools Used
Recommended Mitigation Steps