
Canister Security
If you're writing Internet Computer canisters, this covers the security patterns that aren't obvious from Web2 backend development. The async messaging model creates TOCTOU vulnerabilities between await calls, canister_inspect_message isn't a real security boundary, and the anonymous principal is a shared identity anyone can use. You get copy-paste patterns for CallerGuard (reentrancy prevention), saga pattern (async safety), and upgrade traps that brick canisters. The pitfalls section is dense but accurate, especially on callback traps after state mutation and the fact that a malicious replica can skip inspect_message entirely. Covers both Motoko and Rust. Read the pitfalls first, then use the patterns when you hit them.
- skills.sh installs
- 324
- GitHub stars
- 39
- last updated
- Aug 21, 2026
Install
$ npx -y skills add dfinity/icskills --skill canister-security --agent claude-codeInstalls into .claude/skills of the current project.
Files
Canister Security
What This Is
Security patterns for IC canisters in Motoko and Rust. The async messaging model creates TOCTOU (time-of-check-time-of-use) vulnerabilities where state changes between await calls. canister_inspect_message is NOT a reliable security boundary. Anyone on the internet can burn your cycles by sending update calls. This skill provides copy-paste correct patterns for access control, reentrancy prevention, async safety, and callback trap handling.
Prerequisites
- For Motoko:
mopspackage manager,core = "2.0.0"in mops.toml - For Rust:
ic-cdk = "0.19",candid = "0.10"
Security Pitfalls
- Relying on
canister_inspect_messagefor access control. This hook runs on a single replica without full consensus. If that replica is malicious, it can simply skip the check and execute the update call without any message inspection. It is also never called for inter-canister calls, query calls, or management canister calls. Always duplicate access checks inside every update method. Useinspect_messageonly as a cycle-saving optimization, never as a security boundary.
Sponsors
Details
- Repository
- github.com/dfinity/icskills
- Categories
- Security, Documentation, Rust
- First seen
- Jun 3, 2026