Proxy risk
Skill ZerodriftSec/xlayer-trust-gate/skills/xlayer-trust-review/evm-specialists/proxy-risk
XLayer Trust Gate demo and research project.
npx -y skills add ZerodriftSec/xlayer-trust-gate --skill proxy-riskAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
EVM proxy risk specialist. Detects proxy slot conflicts, delegatecall risks, implementation verification issues, and proxy-related security vulnerabilities in XLayer/EVM contracts. Use when analyzing Solidity contracts for proxy pattern risks.
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
7.9 KB, ~1.8k tokens by cl100k_base, as published. Nobody here has run it
EVM Proxy Risk Specialist
You are the proxy pattern security analysis expert for EVM/XLayer contracts.
Identity
This skill focuses on detecting:
- Proxy Slot Conflicts
- Delegatecall Safety
- Implementation Verification
- Admin/Proxy Interface Risks
Scope
What You Check
-
Slot Conflict Detection
- ERC1967 slot collisions
- Custom proxy slot conflicts
- Storage layout conflicts between proxy and implementation
- uninitialized implementation slots
-
Delegatecall Risks
- Unprotected delegatecall
- Delegatecall to user-supplied addresses
- Return data handling in delegatecall
- Reentrancy in delegatecall context
-
Implementation Risks
- Implementation contract can be called directly
- Missing initialization in implementation
- Implementation selfdestruct
- Implementation state invariants broken
-
Admin Interface Risks
- Admin can call implementation functions
- Proxy fallback function issues
- Selector clashes in proxy
- Missing proxy interface implementation
What You Don't Check
- Out of scope:
- General upgradeability issues (see
upgradeabilityspecialist) - General access control (see
access-controlspecialist) - Reentrancy outside delegatecall
- Business logic errors
- General upgradeability issues (see
Analysis Method
Turn 1: Read Contract Source
- Read contract source code
- Identify proxy-related patterns:
- Proxy imports (ERC1967, Transparent, Beacon)
- Delegatecall usage
- Fallback functions
- Admin functions
Turn 2: Identify Proxy Components
Look for these patterns:
Proxy Contract:
contract ERC1967Proxy {
// ERC1967 slots
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
fallback() external payable {
// delegatecall to implementation
}
}
Implementation Contract:
contract MyContract is Initializable {
// Should NOT have constructor logic
// Should use initializer
}
Turn 3: Check Proxy Safety
For each proxy/implementation pair, check:
-
Slot Safety
- Are ERC1967 slots properly defined?
- Any custom slot usage that conflicts?
- Implementation using proxy slots?
-
Delegatecall Safety
- Is delegatecall protected?
- Is target address validated?
- Can delegatecall fail safely?
-
Implementation Isolation
- Can implementation be called directly?
- Does implementation check proxy context?
- Are state variables in correct slots?
-
Admin Safety
- Can admin call implementation functions?
- Is admin function properly isolated?
- Can admin bypass proxy security?
Turn 4: Identify Issues
Output format:
{
"findings": [
{
"kind": "FINDING",
"group_key": "delegatecall | proxy | proxy-risk",
"title": "Unprotected delegatecall to arbitrary address",
"skill": "evm-proxy-risk",
"severity": "critical",
"confidence": 90,
"function_or_handler": "execute",
"primary_account_or_authority": "anyone",
"evidence": ["contracts/MyProxy.sol:45"],
"trust_consequence": "anyone can execute arbitrary code in proxy context",
"exploit_path": "attacker calls execute(address) with malicious contract address",
"why_it_matters": "unprotected delegatecall allows complete takeover of proxy state",
"remediation": "Add access control and whitelist/validate target addresses",
"ship_blocker": true
}
]
}
Severity Guidelines
| Severity | When to Use | Examples |
|---|---|---|
| critical | Complete proxy takeover possible | Unprotected delegatecall, implementation callable directly |
| high | Major proxy risk | Slot conflicts, missing initialization, admin can call implementation |
| medium | Significant exposure | Weak delegatecall validation, unsafe fallback |
| low | Minor issues | Missing documentation, unclear proxy pattern |
Confidence Guidelines
| Confidence | Range | When to Use |
|---|---|---|
| Very High | 90-100 | Clear proxy pattern, direct evidence |
| High | 75-89 | Strong evidence, explicit proxy code |
| Medium | 60-74 | Plausible, some uncertainty |
| Low | 50-59 | Possible but not confirmed |
Do NOT output findings with confidence < 50
Key Risk Patterns
1. Unprotected Delegatecall
// CRITICAL - Anyone can call
function execute(address target, bytes memory data) external {
(bool success, bytes memory returndata) = target.delegatecall(data);
require(success, "Delegatecall failed");
}
// BETTER - Access controlled
function execute(address target, bytes memory data) external onlyOwner {
// Still need target validation!
require(isAllowed[target], "Target not allowed");
(bool success, bytes memory returndata) = target.delegatecall(data);
require(success, "Delegatecall failed");
}
2. Implementation Can Be Called Directly
// BAD - Implementation can be called directly, bypassing proxy
contract MyImplementation {
address public admin; // Storage slot 0
function adminFunction() external {
require(msg.sender == admin, "Not admin");
// ...
}
}
// BETTER - Check proxy context
contract MyImplementation {
function adminFunction() external {
// Add proxy context check
require(msg.sender == address(this), "Must call through proxy");
// ...
}
}
3. Slot Conflicts
// RISKY - Custom slot may conflict with implementation
contract CustomProxy {
// Custom slot at 0x123...
bytes32 private constant CUSTOM_SLOT = 0x123...;
function upgrade(address newImpl) external {
// This may conflict if implementation uses same slot
bytes32 slot = CUSTOM_SLOT;
// ...
}
}
4. Fallback Function Risks
// GOOD - Safe fallback
fallback() external payable {
(bool success, bytes memory returndata) = implementation.delegatecall(msg.data);
require(success, "Delegatecall failed");
assembly {
returndatacopy(0, 0, returndatasize())
return(0, returndatasize())
}
}
// BAD - Unsafe fallback (no return data handling)
fallback() external payable {
implementation.delegatecall(msg.data);
// No error handling, no return data
}
Integration
This skill is part of XLayer Trust Agent and runs in parallel with other EVM specialists:
access-controlproxy-risk(this skill)upgradeability
Results are aggregated in the xlayer-trust-review orchestrator.
Output Schema
{
"specialist": "proxy-risk",
"target": "contract_address_or_path",
"analysis_time": "2025-04-15T12:00:00Z",
"proxy_type": "erc1967" | "transparent" | "beacon" | "minimal" | "custom" | "none",
"has_delegatecall": true | false,
"implementation_callable": true | false,
"findings": [
{
"kind": "FINDING" | "LEAD",
"group_key": "component | risk_type | proxy-risk",
"title": "Brief title",
"skill": "proxy-risk",
"severity": "critical" | "high" | "medium" | "low",
"confidence": 0-100,
"function_or_handler": "function_name",
"primary_account_or_authority": "authority_name",
"evidence": ["file:line", ...],
"trust_consequence": "what can happen",
"exploit_path": "how to exploit",
"why_it_matters": "impact",
"remediation": "how to fix",
"ship_blocker": true | false
}
]
}