Ask a coding agent for a simple treasury contract and you will often get something like this:
contract Treasury {
address public owner;
constructor() { owner = msg.sender; }
receive() external payable {}
function sweep(address payable to) external {
to.transfer(address(this).balance);
}
}
It compiles, the deploy script works, and the happy-path test (the owner calls sweep) passes. The problem is that sweep() has no access control. Anyone can call it with their own address and take everything the contract holds. The owner variable exists, but nothing checks it.
This is the "arbitrary ETH send" pattern. It's well known, and it still reaches mainnet because the code looks finished and nobody re-reads a 10-line contract.
Catch it where the code is written
If your agent has an MCP connection to Kestrova, the free preview tool flags this right away. On the contract above it returns:
- High:
arbitrary-send-eth - "ETH can be sent to an arbitrary address. A function sends the contract's ETH to an address chosen by the caller. If access control is missing or weak, anyone may be able to drain funds."
The fix is one line:
function sweep(address payable to) external {
require(msg.sender == owner, "not owner");
to.transfer(address(this).balance);
}
Scan again and the High finding is gone. Only Low, Informational and Optimization notes remain. In a real project, use OpenZeppelin's Ownable instead of a hand-rolled check.## Catch it in the pull request
Agents aren't the only source of this bug, and not every developer runs a scanner by hand. The same free check runs in CI as a GitHub Action. It looks only at the Solidity files a pull request changes and reports only new findings:
- uses: kestrova/solidity-scan-action@v1.0.0
with:
fail-on: high
With fail-on: high, a pull request that adds an unprotected sweep() fails the check, and the job summary names the detector. The action needs no token or secrets and never pays for anything. If the service is busy, it only warns, so your build is never blocked by our uptime.
When you need exact lines
The free preview names the High and Medium detectors and gives one example. On a larger codebase you want every finding with its file and line. That's optional and paid per scan with x402: 0.25 USDC for every finding with locations, or 1 USDC for a full report with an explanation and fix for each finding plus PDF and SARIF. An agent should always ask its user before paying.
What this is not
This is Slither-based pattern detection. It catches known bug shapes like this one, reentrancy, unchecked calls and tx.origin authorization. It doesn't understand your business logic or economic attacks, and zero findings doesn't mean a contract is safe. It's not an audit.
Setup:
- GitHub Action: https://github.com/marketplace/actions/kestrova-solidity-scan
- MCP server and one-click installs: https://kestrova-api.onrender.com/developers
- Earlier tutorial (reentrancy in the agent loop): https://dev.to/kestrova/let-your-coding-agent-catch-reentrancy-before-it-deploys-a-solidity-contract-5296
Top comments (0)