Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@ethereum-sourcify/radspec
Advanced tools
Radspec is a safe alternative to Ethereum's natspec (Sourcify fork)
Sourcify fork of aragon/radspec.
"Sends `_amount` to `address`"
throws an error if the passed parameter of function is amount
not _amount
. The modified version will show "Sends `_amount` to 0x23f..de2"
.Radspec is a safe interpreter for dynamic expressions in Ethereum's NatSpec.
This allows smart contact developers to show improved function documentation to end users, without the security pitfalls of natspec.js. Radspec defines its own syntax structure and parses its own AST rather than directly evaluating untrusted JavaScript.
Radspec supports any contract programming language, such as Solidity or Vyper because radspec works on the compiled JSON ABI. Here is an example using Solidity.
pragma solidity ^0.5.0;
contract Tree {
/// @notice Set the tree age to `numYears` years
function setAge(uint256 numYears) external {
// set the age into storage
}
}
Notice the dynamic expression documentation for the setAge
function. When presented to the end user, this will render based on the inputs provided by the user. For example, if the end user is calling the contract with an input of 10 years, this will be rendered by radspec as:
Set the tree age to 10 years
Use the Solidity compiler to generate user documentation and ABI with:
solc --userdoc --abi tree.sol
This produces the outputs:
{
"methods": {
"setAge(uint256)": {
"notice": "Set the tree age to `numYears` years"
}
}
}
and
[
{
"constant": false,
"inputs": [{ "name": "numYears", "type": "uint256" }],
"name": "setAge",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
]
Write a simple tool using radspec to interpret this:
import radspec from "radspec";
// Set userDoc and ABI from above
const expression = userDoc.methods["setAge(uint256)"].notice;
const call = {
abi: abi,
transaction: {
to: "0x8521742d3f456bd237e312d6e30724960f72517a",
data: "0xd5dcf127000000000000000000000000000000000000000000000000000000000000000a",
},
};
radspec.evaluate(expression, call).then(console.log); // => "Set the tree age to 10 years"
See more examples here and in the tests.
Please let us know if there's anything else you'd like Radspec to be able to evaluate by filing an issue!
Simply use your favorite Node.js package manager:
npm i radspec
Documentation about radspec and the internals of radspec can be found here.
TBD
natspec.js accepts any valid JavaScript. There are multiple reasons this is a bad idea:
eval
(unsafe!) from inside JavaScriptAs dapps become increasingly complex, it is paramount that tools are written in a way that makes phishing near impossible. Evaluating JavaScript directly makes opens your dapp up to cross-site scripting attacks by users merely submitting a transaction(!).
MIT
FAQs
Radspec is a safe alternative to Ethereum's natspec (Sourcify fork)
We found that @ethereum-sourcify/radspec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.