Skip to content

Solidity entrypoint detection is unreliable #57

Description

@infosec-us-team

We are very excited about Trailmark's potential and looking forward to building tooling on top of it. Thanks for open sourcing it!

In its current state, the entrypoints feature (described as "attack surface") is unreliable for Solidity.

Tagging anything with "public" or "external" as an entry point is a heuristic that will fail with nearly all Solidity smart contracts.

_SOL_VISIBILITY = re.compile(
r"\bfunction\s+\w+\s*\([^)]*\)\s*(?:[\w\s]*?\b)?(external|public)\b",
)

For example, view only functions that do not modify the state are marked as an entrypoint / attack surface:

/**
 * @notice seconds until the next epoch begins
 */
function secondsToNextEpoch() external view returns (uint256) {
    return epoch.end.sub(block.timestamp);
}

Interfaces are scanned (when they should be ignored), and as a result, governor() will be listed as an "entry point" of the target project.

interface IOlympusAuthority {
    function governor() external view returns (address);
}

A regex-based approach falls short here, especially with Solidity’s inheritance. When a smart contract overrides an inherited entry point, Trailmark needs to return the override only, not every version in the hierarchy.

Trailofbits implemented in Slither an "entrypoint scanner" for Solidity (thanks @nisedo !) that seems to behave correctly.

Are there any plans to improve entrypoint detection for Solidity?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions