[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B7N81F2630E2E4AMKPZQRZ":3,"skill-same:01M7B7N81F2630E2E4AMKPZQRZ":66},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":29,"commitSha":30,"skillDirectory":31,"forksCount":32,"repositoryHtmlUrl":33,"repositoryHomepageUrl":6,"ownerHtmlUrl":34,"ownerBlogUrl":35,"ownerDescription":36,"updatedAt":37,"install":38,"resources":51},"01M7B7N81F2630E2E4AMKPZQRZ","canister-audit",null,"Audit an existing Internet Computer Rust canister (ic-cdk) for security flaws and PROVE a confirmed one with a PocketIC reproduction. Covers detecting the canister, a high-recall static first pass, a systematic review against the canister-security pitfalls, and the distinctive step: building the canister to wasm and executing the exploit in PocketIC to turn a suspected flaw into a demonstrated one. Use when reviewing or auditing a canister you did NOT write, or proving a finding before you report it. Complements canister-security (which teaches the secure patterns); this one finds and proves violations of them.","jiayaoqijia\u002Fcryptoskill","jiayaoqijia","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1453879?v=4","01M6GMYTX7Q7S504VC6E756ENR","YQ","01M6GMYV1QKJ1CC75MTTGT9PR0",81,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-canister-audit\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-canister-audit\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: canister-audit\ndescription: \"Audit an existing Internet Computer Rust canister (ic-cdk) for security flaws and PROVE a confirmed one with a PocketIC reproduction. Covers detecting the canister, a high-recall static first pass, a systematic review against the canister-security pitfalls, and the distinctive step: building the canister to wasm and executing the exploit in PocketIC to turn a suspected flaw into a demonstrated one. Use when reviewing or auditing a canister you did NOT write, or proving a finding before you report it. Complements canister-security (which teaches the secure patterns); this one finds and proves violations of them.\"\nlicense: Apache-2.0\ncompatibility: \"a Rust ic-cdk canister repo (ic-cdk >= 0.18); cargo + the wasm32-unknown-unknown target; the pocket-ic crate (16.x) for the proof step, which downloads its matching server; Semgrep and cargo-audit optional\"\nmetadata:\n  title: Canister Audit\n  category: Security\n---\n\n# Canister Audit\n\n## What This Is\n\nA workflow for auditing a Rust `ic-cdk` canister you did not write, and for turning a suspected flaw into a *proven* one. `canister-security` teaches the patterns a canister should follow; this skill is the other side of that coin - given existing code, find where those patterns are violated, and prove the highest-severity finding by reproducing the exploit in PocketIC. A grep hit or a hunch is a *candidate*; a PocketIC test that drives the deployed wasm and crosses the security boundary is *evidence*.\n\nThe worked example throughout is a deliberately-broken ledger canister, `token_vault`, whose accounting invariant `sum(balances) \u003C= total_deposited` is broken by exactly one unguarded method.\n\n## Prerequisites\n\n- Rust toolchain + the wasm target: `rustup target add wasm32-unknown-unknown`.\n- Optional static tools: `cargo-audit` (RustSec dependency CVEs) and Semgrep (a coarse first pass; Rust support is experimental, so treat it as high-recall).\n- For the proof step: the `pocket-ic` crate (e.g. `16.1`). With `POCKET_IC_BIN` unset, `PocketIc::new()` downloads the matching server release from `dfinity\u002Fpocketic` on first use. To pin a binary you have verified (sha256) instead, point `POCKET_IC_BIN` at it; the server's major version must match the crate's.\n\n## The audit workflow\n\n1. **Detect the canister.** Confirm it is a Rust ic-cdk canister: a `Cargo.toml` depending on `ic-cdk`\u002F`candid`, `#[ic_cdk::update]`\u002F`#[ic_cdk::query]` entrypoints, a `.did`. A canister's logic is not recoverable from its deployed wasm, so you need the source - there is no audit-by-mainnet-address mode.\n2. **Model the invariants first.** Before reading for bugs, write down what must always hold: the accounting identity, who may call what, which state moves across each `await`. The audit then hunts for a path that breaks each invariant. For `token_vault` the invariant is `sum(balances) \u003C= total_deposited`.\n3. **Static first pass (high-recall, best-effort).** Grep or Semgrep for the obvious footguns, treating every hit as a candidate to confirm, never an automatic finding:\n   - state-changing update fns — `#[update]`, `#[ic_cdk::update]`, with or without arguments (`guard = ...`, `name = ...`), `async` or not — with no caller check (`is_controller`, an owner check, or a `== Principal::anonymous()` rejection). `CallerGuard` is a reentrancy lock, **not** a caller check: it admits the anonymous principal;\n   - `fetch_root_key` \u002F `fetchRootKey` \u002F `shouldFetchRootKey` **anywhere** in the repo, including calls behind an environment check (`canister-security` pitfall #7 forbids it even there — environment branches leak into production builds); only test-only code is exempt. The fix to recommend is removing the call and passing the root key from the `ic_env` cookie (`IC_ROOT_KEY`, via `safeGetCanisterEnv()`) as `rootKey` to `HttpAgent.create()`;\n   - `let _ = CallerGuard::new(...)` - a guard bound to `_` is dropped at the end of the statement, so the lock is released immediately;\n   - `ic_cdk::caller()` - deprecated in favour of `msg_caller()`; legacy call sites often predate the current guard conventions.\n   A deliberately high-recall rule flags `deposit`, `withdraw`, *and* `claim_bonus` here, even though `deposit` rejects the anonymous principal and `withdraw` takes a `CallerGuard` - the point is to surface candidates for review, not to decide. Example Semgrep rule (tested with Semgrep 1.185):\n   ```yaml\n   rules:\n     - id: ic-update-missing-caller-auth\n       message: update method with no visible caller check - candidate for review\n       languages: [rust]\n       severity: ERROR\n       patterns:\n         # Every update entrypoint: bare or parameterized attribute, sync or async.\n         - pattern-either:\n             - pattern: |\n                 #[$ATTR]\n                 fn $F(...) { ... }\n             - pattern: |\n                 #[$ATTR]\n                 fn $F(...) -> $R { ... }\n             - pattern: |\n                 #[$ATTR]\n                 async fn $F(...) { ... }\n             - pattern: |\n                 #[$ATTR]\n                 async fn $F(...) -> $R { ... }\n             - pattern: |\n                 #[$ATTR(...)]\n                 fn $F(...) { ... }\n             - pattern: |\n                 #[$ATTR(...)]\n                 fn $F(...) -> $R { ... }\n             - pattern: |\n                 #[$ATTR(...)]\n                 async fn $F(...) { ... }\n             - pattern: |\n                 #[$ATTR(...)]\n                 async fn $F(...) -> $R { ... }\n         - metavariable-regex:\n             metavariable: $ATTR\n             regex: ^(ic_cdk::)?update$\n         # A bare `== Principal::anonymous()` is deliberately NOT a suppressor (a\n         # comparison that does not reject the caller is not a guard), and neither\n         # is CallerGuard (a reentrancy lock). Under-reporting is worse than noise.\n         - pattern-not-regex: (is_controller|require_owner|require_admin)\n   ```\n   The suppression is by name only, so methods it hides are still reviewed in step 4 - it just orders the queue.\n4. **Systematic review against the pitfalls.** Walk each entrypoint against the `canister-security` checklist (anonymous principal #2, TOCTOU across `await` #3, unguarded admin #8, storage \u002F cycle-drain DoS #10\u002F#5, callback-trap-after-mutation #11, and the rest). For each candidate, read the code and decide real or refuted. Trace every guard to its body: a `guard = \"...\"` function or helper proves nothing until you have read it, `require_authenticated`-style guards stop only the anonymous principal (not enough for admin methods), and a guard called as a statement whose `Result` is discarded (`require_owner();`) is a bypass - the mutation runs whether or not it returned `Err`. In `token_vault`, `claim_bonus` credits the caller with no guard and never touches `total_deposited`, so it breaks the invariant and is reachable by the anonymous principal (pitfalls #2 and #8); `deposit`'s `== Principal::anonymous()` check refutes its own candidate.\n5. **Prove a confirmed HIGH\u002FCRITICAL with PocketIC** (next section).\n6. **Report.** Per finding: the pitfall, the `file:line`, the invariant broken, and - for a proven one - the reproduction. Frame an unproven candidate honestly as \"suspected, not reproduced,\" and never ship a working exploit for an unpatched canister publicly - it belongs in a private report to the canister's controllers.\n\n## Proving a finding with PocketIC\n\nThis is the step that separates an audit from a lint. Build the audited canister to wasm, load it into PocketIC, call the suspect method as the attacker (usually `Principal::anonymous()`), and assert the prohibited outcome. If the test passes, the exploit is real.\n\nKeep the reproduction in a **separate, standalone crate** outside the audited repo's workspace, so PocketIC's dev-dependency never touches the target's manifests and your audit leaves the target unmodified. Drive the canister through its built wasm - ic-cdk canister code does not link for the host target.\n\n`token_vault_repro\u002FCargo.toml`:\n\n```toml\n[package]\nname = \"token_vault_repro\"\nversion = \"0.1.0\"\nedition = \"2021\"\npublish = false\n\n# Empty [workspace] keeps this crate out of any enclosing workspace.\n[workspace]\n\n[dev-dependencies]\ncandid = \"0.10\"\npocket-ic = \"16.1\"\n```\n\n### 1. The flaw (`token_vault\u002Fsrc\u002Flib.rs`)\n\n```rust\n\u002F\u002F INTENTIONAL FLAW: credits the caller out of thin air - no anonymous-principal\n\u002F\u002F rejection, no owner guard, and it never touches total_deposited. Breaks the\n\u002F\u002F invariant sum(balances) \u003C= total_deposited.\n#[ic_cdk::update]\nfn claim_bonus(amount: u64) {\n    let caller = msg_caller();\n    STATE.with(|s| {\n        *s.borrow_mut().balances.entry(caller).or_default() += amount;\n    });\n}\n```\n\n### 2. The reproduction (separate `token_vault_repro` crate, `tests\u002Frepro.rs`)\n\n```rust\nuse candid::{decode_one, encode_args, encode_one, Principal};\nuse pocket_ic::PocketIc;\n\nfn install(pic: &PocketIc) -> Principal {\n    let c = pic.create_canister();\n    pic.add_cycles(c, 2_000_000_000_000);\n    \u002F\u002F Must be an absolute path: cargo runs integration tests from this crate's root.\n    let path = std::env::var(\"CANISTER_WASM\").expect(\"set CANISTER_WASM to the built .wasm\");\n    let wasm = std::fs::read(&path).unwrap_or_else(|e| panic!(\"read {path}: {e}\"));\n    pic.install_canister(c, wasm, encode_args(()).unwrap(), None);\n    c\n}\n\nfn query_u64(pic: &PocketIc, c: Principal, method: &str, arg: Vec\u003Cu8>) -> u64 {\n    let reply = pic.query_call(c, Principal::anonymous(), method, arg).expect(\"query rejected\");\n    decode_one(&reply).expect(\"reply decodes to u64\")\n}\n\n#[test]\nfn anonymous_principal_mints_unbacked_balance() {\n    let pic = PocketIc::new();\n    let c = install(&pic);\n    let anon = Principal::anonymous();\n\n    \u002F\u002F Precondition: an empty ledger.\n    assert_eq!(query_u64(&pic, c, \"total_deposited\", encode_args(()).unwrap()), 0);\n\n    \u002F\u002F Attack: the anonymous principal credits itself 1_000 out of thin air.\n    pic.update_call(c, anon, \"claim_bonus\", encode_one(1_000u64).unwrap())\n        .expect(\"claim_bonus is callable by the anonymous principal - that is the bug\");\n\n    let bal = query_u64(&pic, c, \"balance_of\", encode_one(anon).unwrap());\n    let total = query_u64(&pic, c, \"total_deposited\", encode_args(()).unwrap());\n\n    assert_eq!(bal, 1_000, \"anonymous principal minted a balance\");\n    assert!(\n        bal > total,\n        \"INVARIANT BROKEN: sum(balances) {bal} > total_deposited {total} - \\\n         the ledger records a balance no deposit backs\"\n    );\n}\n```\n\n### 3. Run it\n\n```bash\nrustup target add wasm32-unknown-unknown\n# Build the audited canister in its own repo (no changes to it).\n(cd token_vault && cargo build --target wasm32-unknown-unknown --release)\n# Run the repro with an ABSOLUTE wasm path - a relative one resolves against\n# token_vault_repro\u002F, not the directory you ran this from.\n(cd token_vault_repro && \\\n  CANISTER_WASM=\"$PWD\u002F..\u002Ftoken_vault\u002Ftarget\u002Fwasm32-unknown-unknown\u002Frelease\u002Ftoken_vault.wasm\" \\\n  cargo test --test repro -- --nocapture)\n```\n\nIf the audited crate is part of a Cargo workspace, its wasm lands in the **workspace** `target\u002F` directory - adjust the path accordingly.\n\nA passing test is the whole point: it proves the anonymous principal can create a balance no deposit backs - the accounting invariant is broken on the deployed wasm. That is the difference between \"`claim_bonus` looks unguarded\" and \"here is the anonymous principal minting a balance.\" Claim exactly what the test shows: it does **not** by itself prove funds can be stolen. To prove theft, extend the test - fund the vault from an honest principal, have the attacker `claim_bonus` then `withdraw`, and assert the withdrawal succeeds and the honest user's funds can no longer be fully paid out.\n\n## Notes\n\n- The PocketIC server and the `pocket-ic` crate share a major version. Pin both and update the `update_call`\u002F`query_call` signatures together if you bump (the 16.x API returns `Result\u003CVec\u003Cu8>, _>`).\n- A clean or failed reproduction does **not** refute the static \u002F review finding. A flaw can be real but awkward to reproduce in a unit test (timing, multi-canister setup); keep the reasoning and record the proof as pending.\n- Static hits are candidates, not verdicts. The high-recall ruleset exists to miss nothing obvious; the review and the PocketIC proof are what confirm.\n","# Canister Audit\n\n## What This Is\n\nA workflow for auditing a Rust `ic-cdk` canister you did not write, and for turning a suspected flaw into a *proven* one. `canister-security` teaches the patterns a canister should follow; this skill is the other side of that coin - given existing code, find where those patterns are violated, and prove the highest-severity finding by reproducing the exploit in PocketIC. A grep hit or a hunch is a *candidate*; a PocketIC test that drives the deployed wasm and crosses the security boundary is *evidence*.\n\nThe worked example throughout is a deliberately-broken ledger canister, `token_vault`, whose accounting invariant `sum(balances) \u003C= total_deposited` is broken by exactly one unguarded method.\n\n## Prerequisites\n\n- Rust toolchain + the wasm target: `rustup target add wasm32-unknown-unknown`.\n- Optional static tools: `cargo-audit` (RustSec dependency CVEs) and Semgrep (a coarse first pass; Rust support is experimental, so treat it as high-recall).\n- For the proof step: the `pocket-ic` crate (e.g. `16.1`). With `POCKET_IC_BIN` unset, `PocketIc::new()` downloads the matching server release from `dfinity\u002Fpocketic` on first use. To pin a binary you have verified (sha256) instead, point `POCKET_IC_BIN` at it; the server's major version must match the crate's.\n\n## The audit workflow\n\n1. **Detect the canister.** Confirm it is a Rust ic-cdk canister: a `Cargo.toml` depending on `ic-cdk`\u002F`candid`, `#[ic_cdk::update]`\u002F`#[ic_cdk::query]` entrypoints, a `.did`. A canister's logic is not recoverable from its deployed wasm, so you need the source - there is no audit-by-mainnet-address mode.\n2. **Model the invariants first.** Before reading for bugs, write down what must always hold: the accounting identity, who may call what, which state moves across each `await`. The audit then hunts for a path that breaks each invariant. For `token_vault` the invariant is `sum(balances) \u003C= total_deposited`.\n3. **Static first pass (high-recall, best-effort).** Grep or Semgrep for the obvious footguns, treating every hit as a candidate to confirm, never an automatic finding:\n   - state-changing update fns — `#[update]`, `#[ic_cdk::update]`, with or without arguments (`guard = ...`, `name = ...`), `async` or not — with no caller check (`is_controller`, an owner check, or a `== Principal::anonymous()` rejection). `CallerGuard` is a reentrancy lock, **not** a caller check: it admits the anonymous principal;\n   - `fetch_root_key` \u002F `fetchRootKey` \u002F `shouldFetchRootKey` **anywhere** in the repo, including calls behind an environment check (`canister-security` pitfall #7 forbids it even there — environment branches leak into production builds); only test-only code is exempt. The fix to recommend is removing the call and passing the root key from the `ic_env` cookie (`IC_ROOT_KEY`, via `safeGetCanisterEnv()`) as `rootKey` to `HttpAgent.create()`;\n   - `let _ = CallerGuard::new(...)` - a guard bound to `_` is dropped at the end of the statement, so the lock is released immediately;\n   - `ic_cdk::caller()` - deprecated in favour of `msg_caller()`; legacy call sites often predate the current guard conventions.\n   A deliberately high-recall rule flags `deposit`, `withdraw`, *and* `claim_bonus` here, even though `deposit` rejects the anonymous principal and `withdraw` takes a `CallerGuard` - the point is to surface candidates for review, not to decide. Example Semgrep rule (tested with Semgrep 1.185):\n   ```yaml\n   rules:\n     - id: ic-update-missing-caller-auth\n       message: update method with no visible caller check - candidate for review\n       languages: [rust]\n       severity: ERROR\n       patterns:\n         # Every update entrypoint: bare or parameterized attribute, sync or async.\n         - pattern-either:\n             - pattern: |\n                 #[$ATTR]\n                 fn $F(...) { ... }\n             - pattern: |\n                 #[$ATTR]\n                 fn $F(...) -> $R { ... }\n             - pattern: |\n                 #[$ATTR]\n                 async fn $F(...) { ... }\n             - pattern: |\n                 #[$ATTR]\n                 async fn $F(...) -> $R { ... }\n             - pattern: |\n                 #[$ATTR(...)]\n                 fn $F(...) { ... }\n             - pattern: |\n                 #[$ATTR(...)]\n                 fn $F(...) -> $R { ... }\n             - pattern: |\n                 #[$ATTR(...)]\n                 async fn $F(...) { ... }\n             - pattern: |\n                 #[$ATTR(...)]\n                 async fn $F(...) -> $R { ... }\n         - metavariable-regex:\n             metavariable: $ATTR\n             regex: ^(ic_cdk::)?update$\n         # A bare `== Principal::anonymous()` is deliberately NOT a suppressor (a\n         # comparison that does not reject the caller is not a guard), and neither\n         # is CallerGuard (a reentrancy lock). Under-reporting is worse than noise.\n         - pattern-not-regex: (is_controller|require_owner|require_admin)\n   ```\n   The suppression is by name only, so methods it hides are still reviewed in step 4 - it just orders the queue.\n4. **Systematic review against the pitfalls.** Walk each entrypoint against the `canister-security` checklist (anonymous principal #2, TOCTOU across `await` #3, unguarded admin #8, storage \u002F cycle-drain DoS #10\u002F#5, callback-trap-after-mutation #11, and the rest). For each candidate, read the code and decide real or refuted. Trace every guard to its body: a `guard = \"...\"` function or helper proves nothing until you have read it, `require_authenticated`-style guards stop only the anonymous principal (not enough for admin methods), and a guard called as a statement whose `Result` is discarded (`require_owner();`) is a bypass - the mutation runs whether or not it returned `Err`. In `token_vault`, `claim_bonus` credits the caller with no guard and never touches `total_deposited`, so it breaks the invariant and is reachable by the anonymous principal (pitfalls #2 and #8); `deposit`'s `== Principal::anonymous()` check refutes its own candidate.\n5. **Prove a confirmed HIGH\u002FCRITICAL with PocketIC** (next section).\n6. **Report.** Per finding: the pitfall, the `file:line`, the invariant broken, and - for a proven one - the reproduction. Frame an unproven candidate honestly as \"suspected, not reproduced,\" and never ship a working exploit for an unpatched canister publicly - it belongs in a private report to the canister's controllers.\n\n## Proving a finding with PocketIC\n\nThis is the step that separates an audit from a lint. Build the audited canister to wasm, load it into PocketIC, call the suspect method as the attacker (usually `Principal::anonymous()`), and assert the prohibited outcome. If the test passes, the exploit is real.\n\nKeep the reproduction in a **separate, standalone crate** outside the audited repo's workspace, so PocketIC's dev-dependency never touches the target's manifests and your audit leaves the target unmodified. Drive the canister through its built wasm - ic-cdk canister code does not link for the host target.\n\n`token_vault_repro\u002FCargo.toml`:\n\n```toml\n[package]\nname = \"token_vault_repro\"\nversion = \"0.1.0\"\nedition = \"2021\"\npublish = false\n\n# Empty [workspace] keeps this crate out of any enclosing workspace.\n[workspace]\n\n[dev-dependencies]\ncandid = \"0.10\"\npocket-ic = \"16.1\"\n```\n\n### 1. The flaw (`token_vault\u002Fsrc\u002Flib.rs`)\n\n```rust\n\u002F\u002F INTENTIONAL FLAW: credits the caller out of thin air - no anonymous-principal\n\u002F\u002F rejection, no owner guard, and it never touches total_deposited. Breaks the\n\u002F\u002F invariant sum(balances) \u003C= total_deposited.\n#[ic_cdk::update]\nfn claim_bonus(amount: u64) {\n    let caller = msg_caller();\n    STATE.with(|s| {\n        *s.borrow_mut().balances.entry(caller).or_default() += amount;\n    });\n}\n```\n\n### 2. The reproduction (separate `token_vault_repro` crate, `tests\u002Frepro.rs`)\n\n```rust\nuse candid::{decode_one, encode_args, encode_one, Principal};\nuse pocket_ic::PocketIc;\n\nfn install(pic: &PocketIc) -> Principal {\n    let c = pic.create_canister();\n    pic.add_cycles(c, 2_000_000_000_000);\n    \u002F\u002F Must be an absolute path: cargo runs integration tests from this crate's root.\n    let path = std::env::var(\"CANISTER_WASM\").expect(\"set CANISTER_WASM to the built .wasm\");\n    let wasm = std::fs::read(&path).unwrap_or_else(|e| panic!(\"read {path}: {e}\"));\n    pic.install_canister(c, wasm, encode_args(()).unwrap(), None);\n    c\n}\n\nfn query_u64(pic: &PocketIc, c: Principal, method: &str, arg: Vec\u003Cu8>) -> u64 {\n    let reply = pic.query_call(c, Principal::anonymous(), method, arg).expect(\"query rejected\");\n    decode_one(&reply).expect(\"reply decodes to u64\")\n}\n\n#[test]\nfn anonymous_principal_mints_unbacked_balance() {\n    let pic = PocketIc::new();\n    let c = install(&pic);\n    let anon = Principal::anonymous();\n\n    \u002F\u002F Precondition: an empty ledger.\n    assert_eq!(query_u64(&pic, c, \"total_deposited\", encode_args(()).unwrap()), 0);\n\n    \u002F\u002F Attack: the anonymous principal credits itself 1_000 out of thin air.\n    pic.update_call(c, anon, \"claim_bonus\", encode_one(1_000u64).unwrap())\n        .expect(\"claim_bonus is callable by the anonymous principal - that is the bug\");\n\n    let bal = query_u64(&pic, c, \"balance_of\", encode_one(anon).unwrap());\n    let total = query_u64(&pic, c, \"total_deposited\", encode_args(()).unwrap());\n\n    assert_eq!(bal, 1_000, \"anonymous principal minted a balance\");\n    assert!(\n        bal > total,\n        \"INVARIANT BROKEN: sum(balances) {bal} > total_deposited {total} - \\\n         the ledger records a balance no deposit backs\"\n    );\n}\n```\n\n### 3. Run it\n\n```bash\nrustup target add wasm32-unknown-unknown\n# Build the audited canister in its own repo (no changes to it).\n(cd token_vault && cargo build --target wasm32-unknown-unknown --release)\n# Run the repro with an ABSOLUTE wasm path - a relative one resolves against\n# token_vault_repro\u002F, not the directory you ran this from.\n(cd token_vault_repro && \\\n  CANISTER_WASM=\"$PWD\u002F..\u002Ftoken_vault\u002Ftarget\u002Fwasm32-unknown-unknown\u002Frelease\u002Ftoken_vault.wasm\" \\\n  cargo test --test repro -- --nocapture)\n```\n\nIf the audited crate is part of a Cargo workspace, its wasm lands in the **workspace** `target\u002F` directory - adjust the path accordingly.\n\nA passing test is the whole point: it proves the anonymous principal can create a balance no deposit backs - the accounting invariant is broken on the deployed wasm. That is the difference between \"`claim_bonus` looks unguarded\" and \"here is the anonymous principal minting a balance.\" Claim exactly what the test shows: it does **not** by itself prove funds can be stolen. To prove theft, extend the test - fund the vault from an honest principal, have the attacker `claim_bonus` then `withdraw`, and assert the withdrawal succeeds and the honest user's funds can no longer be fully paid out.\n\n## Notes\n\n- The PocketIC server and the `pocket-ic` crate share a major version. Pin both and update the `update_call`\u002F`query_call` signatures together if you bump (the 16.x API returns `Result\u003CVec\u003Cu8>, _>`).\n- A clean or failed reproduction does **not** refute the static \u002F review finding. A flaw can be real but awkward to reproduce in a unit test (timing, multi-canister setup); keep the reasoning and record the proof as pending.\n- Static hits are candidates, not verdicts. The high-recall ruleset exists to miss nothing obvious; the review and the PocketIC proof are what confirm.\n",{"name":5,"license":15,"metadata":25,"description":7,"compatibility":28},{"title":26,"category":27},"Canister Audit","Security","a Rust ic-cdk canister repo (ic-cdk >= 0.18); cargo + the wasm32-unknown-unknown target; the pocket-ic crate (16.x) for the proof step, which downloads its matching server; Semgrep and cargo-audit optional","main","4aff87e77e63c1886a978b82902814d015f55a4f","skills\u002Fchains\u002Fdfinity-official-canister-audit",17,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia","https:\u002F\u002Feth2030.com","Hardcore infra. Building @alt-research and applied cryptography.","2026-11-15 02:28:10",{"source":8,"skillName":5,"commands":39,"prompt":49,"zipAvailable":50},[40,43,46],{"tool":41,"command":42},"npx","npx skills add jiayaoqijia\u002Fcryptoskill --skill canister-audit",{"tool":44,"command":45},"bunx","bunx skills add jiayaoqijia\u002Fcryptoskill --skill canister-audit",{"tool":47,"command":48},"pnpm","pnpm dlx skills add jiayaoqijia\u002Fcryptoskill --skill canister-audit","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-canister-audit\u002FSKILL.md",true,[52,56,62],{"path":53,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":16},"LICENSE","许可证",10770,{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"SOURCE.md","REFERENCE","参考文档",332,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-canister-audit\u002FSOURCE.md",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"TRUST.auto.yaml",2197,"https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fchains\u002Fdfinity-official-canister-audit\u002FTRUST.auto.yaml",[67,76,84,92,100,108],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":72,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":20},"01M7DTKCERMV0RNX3HZJP4CZ26","troves","Deposit and withdraw from Troves DeFi yield vault strategies on Starknet. View available strategies, check positions, and manage vault deposits. Use this skill when the user mentions Troves, vault, yield vault, DeFi vault, strategy, yield farming, vault deposit, vault withdraw, earning yield through vaults, passive yield strategies, or wants to deposit into or withdraw from a yield strategy — even if they don't say \"Troves\" explicitly.","MIT","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-troves\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":80,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":20},"01M7DTK6CJSMGC8KCQHGNYFZBD","trade","Swap tokens on Starknet via Fibrous DEX aggregator. Supports per-provider selection (avnu, ekubo, or auto to race all). Use this skill when the user wants to swap, exchange, trade, convert, buy, or sell one token for another on Starknet. Also use when the user asks about token prices, exchange rates, DEX routing, best swap route, or wants to check how much they would receive for a given amount — even if they don't explicitly say \"swap\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-trade\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":88,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":20},"01M7DTJZ6A0X4PAW3Y8W4J9K64","staking","Stake, unstake, claim, and compound rewards for STRK, WBTC, tBTC, SolvBTC, and LBTC on Starknet. View validators, pools, and staking positions. Use this skill when the user mentions staking, delegating, validators, staking pools, rewards, compounding, unstaking, earning yield, passive income on crypto, or wants to earn on their STRK or BTC tokens — even if they don't say \"stake\" explicitly.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-staking\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":96,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":20},"01M7DTJSDZJKCDMW7GHRF4BRH5","send","Send STRK, ETH, or any ERC-20 token to a Starknet address. Supports simulation (dry-run) before execution. Use this skill when the user wants to send, transfer, pay, tip, or move tokens to another wallet address on Starknet. Also trigger when the user mentions sending funds to someone, making a payment, transferring assets, or moving crypto to a specific address — even if they just say \"pay 10 STRK to 0x...\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-send\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":104,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":20},"01M7DTJG1E480D51ZQ7WKDQ26K","portfolio","View a comprehensive DeFi portfolio dashboard and optimize portfolio allocation via automated rebalancing. Use this skill when the user wants an overview, summary, dashboard, total value, net worth, portfolio rebalancing, target allocation, or wants to see all their DeFi positions across Starknet at once. Also trigger when the user asks \"what do I have\", \"show me everything\", \"how much am I worth\", \"my positions\", \"my investments\", \"rebalance my portfolio\", \"I want 50% ETH\", \"optimize my holdings\", or any request for a holistic view of their Starknet holdings — even if they don't explicitly say \"portfolio\".","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-portfolio\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":71,"licenseFileUrl":112,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":20},"01M7DTJ7M8TE9R2N36HFBZDGVD","multi-swap","Execute multiple token swaps in a single Starknet transaction via Fibrous (default). Supports per-provider selection (avnu, ekubo, or auto to race all). Supports 2-3 swap pairs bundled into one multicall. Use this skill when the user wants to swap multiple token pairs at once, do batch swaps, execute several trades simultaneously, perform parallel swaps, or do bulk trading in one transaction. Also trigger when the user mentions \"two swaps\", \"three swaps\", \"swap X and Y at the same time\", or wants to convert multiple tokens in a single call.","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fjiayaoqijia\u002Fcryptoskill\u002Fblob\u002Fmain\u002Fskills\u002Fmcp-servers\u002Fahmetenesdur-multi-swap\u002FSKILL.md",[],[]]