chain-construct-smart-contract
Skill220 starsChanged 18 days agoMITView on GitHub
Use when you have a confirmed on-chain vulnerability hypothesis and must demonstrate it with a passing proof-of-concept — author an attacker contract or crafted instruction sequence for an EVM reentrancy, flash-loan, delegatecall-overwrite, or proxy-upgrade primitive (or a Solana CPI-privilege, account-substitution, or overflow primitive) and reproduce it under Forge, LiteSVM, or Trident.
In this repository179 other files it gives its agents.
- AGENTS.mdAGENTS.md
- chrono/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- accessible-media-authoringSkill
- agentic-safety-auditSkill
- agent-prompt-engineeringSkill
- audio-event-map-authoringSkill
- auto-scaffoldSkill
- chain-constructSkill
- claim-verificationSkill
- code-reachability-auditSkill
- code-review-loopSkill
- color-theorySkill
- conversation-designSkill
- copy-refinementSkill
- cosmos-sdk-audit-checklistSkill
- cross-chain-bridge-auditSkill
- cross-file-relationship-synthesisSkill
- data-flow-traceSkill
- dedup-prior-art-checkSkill
- defi-invariant-checkSkill
- dependency-cycle-auditSkill
- dependency-health-triageSkill
- detection-as-codeSkill
- diff-aware-semgrep-scanSkill
- differential-reviewSkill
- dimensional-analysis-checkSkill
- dual-level-retrievalSkill
- durable-nonce-exploitationSkill
- erc1271-revert-data-checkSkill
- error-based-sstiSkill
- evm-audit-flowSkill
- figma-implement-designSkill
- findings-filterSkill
- forensic-timeline-authoringSkill
- game-design-fundamentalsSkill
- game-mechanics-balancingSkill
- head-tailSkill
- incident-response-runbookSkill
- interactive-audio-designSkill
- interface-ambiguity-checkSkill
- keyword-clusteringSkill
- knowledge-base-integrationSkill
- known-advisory-backport-checkSkill
- layered-analysis-loopSkill
- level-design-patternsSkill
- locale-adaptationSkill
- multi-stance-audit-fanoutSkill
- narrative-structureSkill
- osint-platform-auditSkill
- parser-differential-route-confusionSkill
- persuasive-technical-writingSkill
- platform-complianceSkill
- player-engagement-psychologySkill
- pre-audit-threat-modelSkill
- program-rubric-lookupSkill
- read-only-reentrancy-checkSkill
- requirements-elicitationSkill
- review-severity-ladderSkill
- rule6-rights-gateSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 70
Chain needs live mainnet state: use forge test --fork-url <rpc> --fork-block-number <n>.
- Very specific: line 73
Chain spans multiple blocks: use vm.warp() / vm.roll() (EVM) or advance slots on a local validator (Solana).
- Distinctive: line 78
Do NOT author chains that require compromised admin keys or any attacker-unestablishable precondition — out of scope for smart-contract …
- Distinctive: line 80
Do NOT submit a chain that only works against a specific past chain state without noting the block-height constraint.
- Very specific: line 82
Do NOT conflate a theoretical chain with a demonstrated one — the Forge/LiteSVM/Trident test must actually pass.
- Very specific: line 84
Do NOT invoke dead tool_wrappers names (forge_test, litesvm_test, trident_fuzz).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- attack-chain-builder pattern, recreated against native CLIs; no upstream code copied -->chain-construct-smart-contract
Smart-contract specialization of chain-construct for exploit-developer: build multi-step
attack call sequences for on-chain vulnerabilities and prove them with a passing Forge (EVM) or
LiteSVM/Trident (Solana) reproduction. Follow the generic chain-construct method (objective as
end-state, chain head, state-feeds ordering, prove-don't-assert); this skill adds the
EVM/Solana chain primitives. Where the two conflict, the contract-level guidance here wins for
smart-contract targets. All tools are native host CLIs (forge, cargo test/litesvm,
trident, cargo-fuzz, anchor) — no wrapper layer.
Chain primitives — EVM
Reentrancy chain: deploy an attacker contract whose receive()/fallback() re-enters the
target; call the withdrawable function; re-enter before the balance is decremented; repeat
until drained. Scaffold: test/attack/AttackerReentrant.sol + a Forge test.
Flash-loan chain: borrow asset X (Aave/Uniswap V3 callback); in the callback manipulate
target state (price oracle, reserve ratio, collateral); extract profit; repay loan + fee.
Scaffold: FlashLoanAttacker.sol implementing IERC3156FlashBorrower or a Uniswap V3
flash callback.
Delegatecall-overwrite chain: find an unprotected delegatecall to a caller-controlled
address; supply a malicious implementation that overwrites slot 0 (owner/admin); call a
privileged function. Scaffold: a Forge fuzz test supplying arbitrary impl_addr.
Proxy-upgrade chain: find a UUPS/Transparent proxy with a bypassable upgrade guard (missing
onlyOwner, missing _authorizeUpgrade override); upgradeTo(malicious_impl); drain from the
new implementation. Scaffold: a Forge test with a MaliciousImpl.
Chain primitives — Solana
CPI privilege-escalation chain: find an instruction that makes a CPI with caller-controlled
signer_seeds; derive a PDA whose seeds match a privileged authority; call with the crafted
seeds so the program signs on that authority's behalf. Scaffold: a Trident FuzzInstruction
supplying crafted seed arrays, or a LiteSVM test.
Account-substitution chain: find an instruction accepting a generic AccountInfo for a
privileged account type; pass a different account that passes owner/discriminator checks due to
missing validation. Scaffold: a LiteSVM test passing a crafted account buffer.
SPL-arithmetic-overflow chain: find token arithmetic without a checked_* guard; supply an
amount that overflows to a small number; withdraw more than deposited. Scaffold: a LiteSVM test
with amount = u64::MAX.
Order of ops
- Map the chain head — the first externally-callable function/instruction the attacker controls.
- Select the primitive from the categories above and its scaffold.
- Author the attack contract/test in
test/attack/(Forge) or aprograms/attacker// fuzz target (Solana). Validate withforge test --match-contract <Attacker> -vvvv, orcargo test/trident fuzz run <target>/cargo fuzz run <target>for Solana. - Gate on state confirmation — the chain is valid only if the final state demonstrates the intended impact (balance drain, ownership change, unauthorized state write). Add explicit assertions on the expected final state; a passing test with unclear impact is not a finding.
- Document the chain — entry point → numbered intermediate steps → final impact →
preconditions (flash loan available, specific contract state, fork block). This becomes the
PoC evidence handed to
impact-validator.
When to pivot
- Chain needs live mainnet state: use
forge test --fork-url <rpc> --fork-block-number <n>; never submit a finding that only reproduces on a live fork without documenting the fork block and contract state. - Chain spans multiple blocks: use
vm.warp()/vm.roll()(EVM) or advance slots on a local validator (Solana); document the required delta.
Anti-patterns
- Do NOT author chains that require compromised admin keys or any attacker-unestablishable precondition — out of scope for smart-contract auditing.
- Do NOT submit a chain that only works against a specific past chain state without noting the block-height constraint.
- Do NOT conflate a theoretical chain with a demonstrated one — the Forge/LiteSVM/Trident test must actually pass.
- Do NOT invoke dead
tool_wrappersnames (forge_test,litesvm_test,trident_fuzz); use the native CLIs above.
Example
// test/attack/ReentrancyAttacker.sol
contract ReentrancyAttacker {
VulnerableVault vault;
constructor(address _vault) { vault = VulnerableVault(_vault); }
function attack() external payable {
vault.deposit{value: msg.value}();
vault.withdraw();
}
receive() external payable {
if (address(vault).balance > 0) vault.withdraw(); // re-enter before balance update
}
}forge test --match-contract ReentrancyAttacker -vvvvRecording (chrono-vault)
The task packet's injected memory contract owns the exact call shape, sequence, and fields - see
wirework-reflect. Do not copy a record(...) example or add fields (including source_task) from
memory; the server binds them, and a baked example violates the run's authenticated schema. Memory is
best-effort telemetry and never gates the work. What is worth recording here is the task-specific
outcome: chain primitive, entry point, numbered steps, impact, preconditions, test file, reproduced?.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

