[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79XMCTG9288DZNAM1R3K2K2":3,"skill-same:01M79XMCTG9288DZNAM1R3K2K2":60},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":27,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M79XMCTG9288DZNAM1R3K2K2","ton-vulnerability-scanner",null,"Scans TON (The Open Network) smart contracts for 3 critical vulnerabilities including integer-as-boolean misuse, fake Jetton contracts, and forward TON without gas checks. Use when auditing FunC contracts.","Heesho\u002Fraffle-fun","Heesho","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F100749457?v=4","01M79XHBVXHD5BHPJTHXK51VSC","01M79XHBWZQNAH0BTYT9A1RFCW",0,"MIT","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fton-vulnerability-scanner\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: ton-vulnerability-scanner\ndescription: Scans TON (The Open Network) smart contracts for 3 critical vulnerabilities including integer-as-boolean misuse, fake Jetton contracts, and forward TON without gas checks. Use when auditing FunC contracts.\n---\n\n# TON Vulnerability Scanner\n\n## 1. Purpose\n\nSystematically scan TON blockchain smart contracts written in FunC for platform-specific security vulnerabilities related to boolean logic, Jetton token handling, and gas management. This skill encodes 3 critical vulnerability patterns unique to TON's architecture.\n\n## 2. When to Use This Skill\n\n- Auditing TON smart contracts (FunC language)\n- Reviewing Jetton token implementations\n- Validating token transfer notification handlers\n- Pre-launch security assessment of TON dApps\n- Reviewing gas forwarding logic\n- Assessing boolean condition handling\n\n## 3. Platform Detection\n\n### File Extensions & Indicators\n- **FunC files**: `.fc`, `.func`\n\n### Language\u002FFramework Markers\n```func\n;; FunC contract indicators\n#include \"imports\u002Fstdlib.fc\";\n\n() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {\n    ;; Contract logic\n}\n\n() recv_external(slice in_msg) impure {\n    ;; External message handler\n}\n\n;; Common patterns\nsend_raw_message()\nload_uint(), load_msg_addr(), load_coins()\nbegin_cell(), end_cell(), store_*()\ntransfer_notification operation\nop::transfer, op::transfer_notification\n.store_uint().store_slice().store_coins()\n```\n\n### Project Structure\n- `contracts\u002F*.fc` - FunC contract source\n- `wrappers\u002F*.ts` - TypeScript wrappers\n- `tests\u002F*.spec.ts` - Contract tests\n- `ton.config.ts` or `wasm.config.ts` - TON project config\n\n### Tool Support\n- **TON Blueprint**: Development framework for TON\n- **toncli**: CLI tool for TON contracts\n- **ton-compiler**: FunC compiler\n- Manual review primarily (limited automated tools)\n\n---\n\n## 4. How This Skill Works\n\nWhen invoked, I will:\n\n1. **Search your codebase** for FunC\u002FTact contracts\n2. **Analyze each contract** for the 3 vulnerability patterns\n3. **Report findings** with file references and severity, above them a coverage table carrying a verdict for every pattern\n4. **Provide fixes** for each identified issue\n5. **Emit the coverage table** — all 3 patterns, each with a verdict\n\n---\n\n## 5. Example Output\n\nWhen vulnerabilities are found, you'll get a report like this:\n\n```\n=== TON VULNERABILITY SCAN RESULTS ===\n\nProject: my-ton-contract\nFiles Scanned: 3 (.fc, .tact)\nVulnerabilities Found: 2\n\nCoverage: 3\u002F3 patterns reported\n 1 Integer as Boolean .............. found   contracts\u002Fwallet.fc:45\n 2 Fake Jetton Contract ............ found   contracts\u002Fstaking.fc:85\n 3 Forward TON Without Gas Check ... clear   forward amounts fixed at 0.05 TON\n\n---\n\n[CRITICAL] Fake Jetton Contract - Missing Sender Validation\nFile: contracts\u002Fstaking.fc:85\nPattern: transfer_notification sender not checked against the stored Jetton wallet\n```\n\n---\n\n## 6. Vulnerability Patterns (3 Patterns)\n\nI check for 3 critical vulnerability patterns unique to TON. For detailed detection patterns, code examples, mitigations, and testing strategies, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n### Pattern Summary:\n\n1. **Integer as Boolean** ⚠️ HIGH - Positive integers used as true; FunC's true is -1\n2. **Fake Jetton Contract** ⚠️ CRITICAL - `transfer_notification` sender not validated\n3. **Forward TON Without Gas Check** ⚠️ HIGH - Forwarding without reserving gas for the rest of execution\n\nFor complete vulnerability patterns with code examples, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n## 7. Scanning Workflow\n\n### Step 1: Platform Identification\n1. Verify FunC language (`.fc` or `.func` files)\n2. Check for TON Blueprint or toncli project structure\n3. Locate contract source files\n4. Identify Jetton-related contracts\n\n### Step 2: Boolean Logic Review\n```bash\n# Find boolean-like variables\nrg \"int.*is_|int.*has_|int.*flag|int.*enabled\" contracts\u002F\n\n# Check for positive integers used as booleans\nrg \"= 1;|return 1;\" contracts\u002F | grep -E \"is_|has_|flag|enabled|valid\"\n\n# Look for NOT operations on boolean-like values\nrg \"~.*\\(|~ \" contracts\u002F\n```\n\nFor each boolean:\n- [ ] Uses -1 for true, 0 for false\n- [ ] NOT using 1 or other positive integers\n- [ ] Logic operations work correctly\n\n### Step 3: Jetton Handler Analysis\n```bash\n# Find transfer_notification handlers\nrg \"transfer_notification|op::transfer_notification\" contracts\u002F\n```\n\nFor each Jetton handler:\n- [ ] Validates sender address\n- [ ] Sender checked against stored Jetton wallet address\n- [ ] Cannot trust forward_payload without sender validation\n- [ ] Has admin function to set Jetton wallet address\n\n### Step 4: Gas\u002FForward Amount Review\n```bash\n# Find forward amount usage\nrg \"forward_ton_amount|forward_amount\" contracts\u002F\nrg \"load_coins\\(\\)\" contracts\u002F\n\n# Find send_raw_message calls\nrg \"send_raw_message\" contracts\u002F\n```\n\nFor each outgoing message:\n- [ ] Forward amounts are fixed\u002Fbounded\n- [ ] OR user-provided amounts validated against msg_value\n- [ ] Cannot drain contract balance\n- [ ] Appropriate send_raw_message flags used\n\n### Step 5: Manual Review\nTON contracts require thorough manual review:\n- Boolean logic with `~`, `&`, `|` operators\n- Message parsing and validation\n- Gas economics and fee calculations\n- Storage operations and data serialization\n\n---\n\n## 8. Reporting Format\n\n### Coverage Table\n\nReport on every pattern in §6, whether or not it turned anything up. Emit this table above the findings, with\nall 3 rows present:\n\n| # | Pattern | Verdict | Evidence |\n|---|---------|---------|----------|\n| 1 | Integer as Boolean | `clear` | searched `is_`\u002F`has_`\u002F`flag`; all set to -1 |\n| 2 | Fake Jetton Contract | | |\n| 3 | Forward TON Without Gas Check | | |\n\nEach verdict is one of:\n\n- **`found`** — cite `file:line` and write the finding up in full below.\n- **`clear`** — the pattern applies to this contract and the contract handles it. Name the function, stored\n  address, or check you searched for, so a reader can repeat the search.\n- **`n\u002Fa`** — the pattern cannot apply here. Give the reason in one clause (\"this contract handles no Jetton\n  transfer notifications\"). Not having looked is not `n\u002Fa`.\n\nThree patterns is a short list, which makes an incomplete table harder to excuse rather than easier: a report\ncovering one pattern and silent on the other two reads exactly like a clean contract. Emit all three rows even\nwhen all three are `clear`. A row whose Verdict cell is empty is incomplete in the same way: row 1 above is filled in to show the shape, and every row is filled in the same way before the report is done.\n\n### Finding Template\n````markdown\n## [CRITICAL] Fake Jetton Contract - Missing Sender Validation\n\n**Location**: `contracts\u002Fstaking.fc:85-95` (recv_internal, transfer_notification handler)\n\n**Description**:\nThe `transfer_notification` operation handler does not validate that the sender is the expected Jetton wallet contract. Any attacker can send a fake `transfer_notification` message claiming to have transferred tokens, crediting themselves without actually depositing any Jettons.\n\n**Vulnerable Code**:\n```func\n\u002F\u002F staking.fc, line 85\nif (op == op::transfer_notification) {\n    int jetton_amount = in_msg_body~load_coins();\n    slice from_user = in_msg_body~load_msg_addr();\n\n    ;; WRONG: No validation of sender_address!\n    ;; Attacker can claim any jetton_amount\n\n    credit_user(from_user, jetton_amount);\n}\n```\n\n**Attack Scenario**:\n1. Attacker deploys malicious contract\n2. Malicious contract sends `transfer_notification` message to staking contract\n3. Message claims attacker transferred 1,000,000 Jettons\n4. Staking contract credits attacker without checking sender\n5. Attacker can now withdraw from contract or gain benefits without depositing\n\n**Proof of Concept**:\n```typescript\n\u002F\u002F Attacker sends fake transfer_notification\nconst attackerContract = await blockchain.treasury(\"attacker\");\n\nawait stakingContract.sendInternalMessage(attackerContract.getSender(), {\n  op: OP_CODES.TRANSFER_NOTIFICATION,\n  jettonAmount: toNano(\"1000000\"), \u002F\u002F Fake amount\n  fromUser: attackerContract.address,\n});\n\n\u002F\u002F Attacker successfully credited without sending real Jettons\nconst balance = await stakingContract.getUserBalance(attackerContract.address);\nexpect(balance).toEqual(toNano(\"1000000\")); \u002F\u002F Attack succeeded\n```\n\n**Recommendation**:\nStore expected Jetton wallet address and validate sender:\n```func\nglobal slice jetton_wallet_address;\n\n() recv_internal(...) impure {\n    load_data();  ;; Load jetton_wallet_address from storage\n\n    slice cs = in_msg_full.begin_parse();\n    int flags = cs~load_uint(4);\n    slice sender_address = cs~load_msg_addr();\n\n    int op = in_msg_body~load_uint(32);\n\n    if (op == op::transfer_notification) {\n        ;; CRITICAL: Validate sender\n        throw_unless(error::wrong_jetton_wallet,\n            equal_slices(sender_address, jetton_wallet_address));\n\n        int jetton_amount = in_msg_body~load_coins();\n        slice from_user = in_msg_body~load_msg_addr();\n\n        ;; Safe to credit user\n        credit_user(from_user, jetton_amount);\n    }\n}\n```\n\n**References**:\n- building-secure-contracts\u002Fnot-so-smart-contracts\u002Fton\u002Ffake_jetton_contract\n````\n\n---\n\n## 9. Priority Guidelines\n\n### Critical (Immediate Fix Required)\n- Fake Jetton contract (unauthorized minting\u002Fcrediting)\n\n### High (Fix Before Launch)\n- Integer as boolean (logic errors, broken conditions)\n- Forward TON without gas check (balance drainage)\n\n---\n\n## 10. Testing Recommendations\n\n### Unit Tests\n```typescript\nimport { Blockchain } from \"@ton\u002Fsandbox\";\nimport { toNano } from \"ton-core\";\n\ndescribe(\"Security tests\", () => {\n  let blockchain: Blockchain;\n  let contract: Contract;\n\n  beforeEach(async () => {\n    blockchain = await Blockchain.create();\n    contract = blockchain.openContract(await Contract.fromInit());\n  });\n\n  it(\"should use correct boolean values\", async () => {\n    \u002F\u002F Test that TRUE = -1, FALSE = 0\n    const result = await contract.getFlag();\n    expect(result).toEqual(-1n); \u002F\u002F True\n    expect(result).not.toEqual(1n); \u002F\u002F Not 1!\n  });\n\n  it(\"should reject fake jetton transfer\", async () => {\n    const attacker = await blockchain.treasury(\"attacker\");\n\n    const result = await contract.send(\n      attacker.getSender(),\n      { value: toNano(\"0.05\") },\n      {\n        $$type: \"TransferNotification\",\n        query_id: 0n,\n        amount: toNano(\"1000\"),\n        from: attacker.address,\n      }\n    );\n\n    expect(result.transactions).toHaveTransaction({\n      success: false, \u002F\u002F Should reject\n    });\n  });\n\n  it(\"should validate gas for forward amount\", async () => {\n    const result = await contract.send(\n      user.getSender(),\n      { value: toNano(\"0.01\") }, \u002F\u002F Insufficient gas\n      {\n        $$type: \"Transfer\",\n        to: recipient.address,\n        forward_ton_amount: toNano(\"1\"), \u002F\u002F Trying to forward 1 TON\n      }\n    );\n\n    expect(result.transactions).toHaveTransaction({\n      success: false,\n    });\n  });\n});\n```\n\n### Integration Tests\n```typescript\n\u002F\u002F Test with real Jetton wallet\nit(\"should accept transfer from real jetton wallet\", async () => {\n  \u002F\u002F Deploy actual Jetton minter and wallet\n  const jettonMinter = await blockchain.openContract(JettonMinter.create());\n  const userJettonWallet = await jettonMinter.getWalletAddress(user.address);\n\n  \u002F\u002F Set jetton wallet in contract\n  await contract.setJettonWallet(userJettonWallet);\n\n  \u002F\u002F Real transfer from Jetton wallet\n  const result = await userJettonWallet.sendTransfer(\n    user.getSender(),\n    contract.address,\n    toNano(\"100\"),\n    {}\n  );\n\n  expect(result.transactions).toHaveTransaction({\n    to: contract.address,\n    success: true,\n  });\n});\n```\n\n---\n\n## 11. Additional Resources\n\n- **Building Secure Contracts**: `building-secure-contracts\u002Fnot-so-smart-contracts\u002Fton\u002F`\n- **TON Documentation**: https:\u002F\u002Fdocs.ton.org\u002F\n- **FunC Documentation**: https:\u002F\u002Fdocs.ton.org\u002Fdevelop\u002Ffunc\u002Foverview\n- **TON Blueprint**: https:\u002F\u002Fgithub.com\u002Fton-org\u002Fblueprint\n- **Jetton Standard**: https:\u002F\u002Fgithub.com\u002Fton-blockchain\u002FTEPs\u002Fblob\u002Fmaster\u002Ftext\u002F0074-jettons-standard.md\n\n---\n\n## 12. Quick Reference Checklist\n\nBefore completing TON contract audit:\n\n**Boolean Logic (HIGH)**:\n- [ ] All boolean values use -1 (true) and 0 (false)\n- [ ] NO positive integers (1, 2, etc.) used as booleans\n- [ ] Functions returning booleans return -1 for true\n- [ ] Boolean logic with `~`, `&`, `|` uses correct values\n- [ ] Tests verify boolean operations work correctly\n\n**Jetton Security (CRITICAL)**:\n- [ ] `transfer_notification` handler validates sender address\n- [ ] Sender checked against stored Jetton wallet address\n- [ ] Jetton wallet address stored during initialization\n- [ ] Admin function to set\u002Fupdate Jetton wallet\n- [ ] Cannot trust forward_payload without sender validation\n- [ ] Tests with fake Jetton contracts verify rejection\n\n**Gas & Forward Amounts (HIGH)**:\n- [ ] Forward TON amounts are fixed\u002Fbounded\n- [ ] OR user-provided amounts validated: `msg_value >= tx_fee + forward_amount`\n- [ ] Contract balance protected from drainage\n- [ ] Appropriate `send_raw_message` flags used\n- [ ] Tests verify cannot drain contract with excessive forward amounts\n\n**Testing**:\n- [ ] Unit tests for all three vulnerability types\n- [ ] Integration tests with real Jetton contracts\n- [ ] Gas cost analysis for all operations\n- [ ] Testnet deployment before mainnet\n- [ ] Coverage table emitted with all 3 rows, each carrying a verdict of `found`, `clear` or `n\u002Fa` with a reason\n\n---\n\n## 13. Rationalizations to Reject\n\n- **\"The contract is small, so most patterns obviously don't apply.\"** Obvious to whom? An `n\u002Fa` costs one\n  clause and makes the judgment reviewable. Silence records nothing, and a reader cannot tell it apart from\n  not having checked. With only three patterns, there is no version of this scan too large to complete.\n- **\"There is no automated tooling for FunC, so coverage can't be systematic.\"** The absence of a scanner is\n  the reason the table matters, not an excuse for skipping it. Manual review is the method here; the table is\n  what makes it auditable.\n- **\"I checked the patterns that matter for this contract.\"** Deciding which patterns matter *is* the scan,\n  not a precondition for starting it. Rank by severity after the table is complete, not by leaving rows out.\n- **\"No findings, so there is nothing to report.\"** A zero-finding scan still emits the full coverage table.\n  That table is the deliverable: it is what distinguishes a contract that was examined from one that was\n  glanced at.\n- **\"The sender is obviously the Jetton wallet.\"** Then cite the stored address it is compared against. Any\n  contract can send a transfer notification; the check is a comparison against an address the contract itself\n  computed, and its absence is the fake-Jetton bug.\n- **\"The message is non-bounceable, so gas doesn't matter.\"** Name the reserve. Forwarding without leaving\n  enough for the remaining execution strands the contract mid-operation regardless of bounce behavior.\n","# TON Vulnerability Scanner\n\n## 1. Purpose\n\nSystematically scan TON blockchain smart contracts written in FunC for platform-specific security vulnerabilities related to boolean logic, Jetton token handling, and gas management. This skill encodes 3 critical vulnerability patterns unique to TON's architecture.\n\n## 2. When to Use This Skill\n\n- Auditing TON smart contracts (FunC language)\n- Reviewing Jetton token implementations\n- Validating token transfer notification handlers\n- Pre-launch security assessment of TON dApps\n- Reviewing gas forwarding logic\n- Assessing boolean condition handling\n\n## 3. Platform Detection\n\n### File Extensions & Indicators\n- **FunC files**: `.fc`, `.func`\n\n### Language\u002FFramework Markers\n```func\n;; FunC contract indicators\n#include \"imports\u002Fstdlib.fc\";\n\n() recv_internal(int my_balance, int msg_value, cell in_msg_full, slice in_msg_body) impure {\n    ;; Contract logic\n}\n\n() recv_external(slice in_msg) impure {\n    ;; External message handler\n}\n\n;; Common patterns\nsend_raw_message()\nload_uint(), load_msg_addr(), load_coins()\nbegin_cell(), end_cell(), store_*()\ntransfer_notification operation\nop::transfer, op::transfer_notification\n.store_uint().store_slice().store_coins()\n```\n\n### Project Structure\n- `contracts\u002F*.fc` - FunC contract source\n- `wrappers\u002F*.ts` - TypeScript wrappers\n- `tests\u002F*.spec.ts` - Contract tests\n- `ton.config.ts` or `wasm.config.ts` - TON project config\n\n### Tool Support\n- **TON Blueprint**: Development framework for TON\n- **toncli**: CLI tool for TON contracts\n- **ton-compiler**: FunC compiler\n- Manual review primarily (limited automated tools)\n\n---\n\n## 4. How This Skill Works\n\nWhen invoked, I will:\n\n1. **Search your codebase** for FunC\u002FTact contracts\n2. **Analyze each contract** for the 3 vulnerability patterns\n3. **Report findings** with file references and severity, above them a coverage table carrying a verdict for every pattern\n4. **Provide fixes** for each identified issue\n5. **Emit the coverage table** — all 3 patterns, each with a verdict\n\n---\n\n## 5. Example Output\n\nWhen vulnerabilities are found, you'll get a report like this:\n\n```\n=== TON VULNERABILITY SCAN RESULTS ===\n\nProject: my-ton-contract\nFiles Scanned: 3 (.fc, .tact)\nVulnerabilities Found: 2\n\nCoverage: 3\u002F3 patterns reported\n 1 Integer as Boolean .............. found   contracts\u002Fwallet.fc:45\n 2 Fake Jetton Contract ............ found   contracts\u002Fstaking.fc:85\n 3 Forward TON Without Gas Check ... clear   forward amounts fixed at 0.05 TON\n\n---\n\n[CRITICAL] Fake Jetton Contract - Missing Sender Validation\nFile: contracts\u002Fstaking.fc:85\nPattern: transfer_notification sender not checked against the stored Jetton wallet\n```\n\n---\n\n## 6. Vulnerability Patterns (3 Patterns)\n\nI check for 3 critical vulnerability patterns unique to TON. For detailed detection patterns, code examples, mitigations, and testing strategies, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n### Pattern Summary:\n\n1. **Integer as Boolean** ⚠️ HIGH - Positive integers used as true; FunC's true is -1\n2. **Fake Jetton Contract** ⚠️ CRITICAL - `transfer_notification` sender not validated\n3. **Forward TON Without Gas Check** ⚠️ HIGH - Forwarding without reserving gas for the rest of execution\n\nFor complete vulnerability patterns with code examples, see [VULNERABILITY_PATTERNS.md](resources\u002FVULNERABILITY_PATTERNS.md).\n\n## 7. Scanning Workflow\n\n### Step 1: Platform Identification\n1. Verify FunC language (`.fc` or `.func` files)\n2. Check for TON Blueprint or toncli project structure\n3. Locate contract source files\n4. Identify Jetton-related contracts\n\n### Step 2: Boolean Logic Review\n```bash\n# Find boolean-like variables\nrg \"int.*is_|int.*has_|int.*flag|int.*enabled\" contracts\u002F\n\n# Check for positive integers used as booleans\nrg \"= 1;|return 1;\" contracts\u002F | grep -E \"is_|has_|flag|enabled|valid\"\n\n# Look for NOT operations on boolean-like values\nrg \"~.*\\(|~ \" contracts\u002F\n```\n\nFor each boolean:\n- [ ] Uses -1 for true, 0 for false\n- [ ] NOT using 1 or other positive integers\n- [ ] Logic operations work correctly\n\n### Step 3: Jetton Handler Analysis\n```bash\n# Find transfer_notification handlers\nrg \"transfer_notification|op::transfer_notification\" contracts\u002F\n```\n\nFor each Jetton handler:\n- [ ] Validates sender address\n- [ ] Sender checked against stored Jetton wallet address\n- [ ] Cannot trust forward_payload without sender validation\n- [ ] Has admin function to set Jetton wallet address\n\n### Step 4: Gas\u002FForward Amount Review\n```bash\n# Find forward amount usage\nrg \"forward_ton_amount|forward_amount\" contracts\u002F\nrg \"load_coins\\(\\)\" contracts\u002F\n\n# Find send_raw_message calls\nrg \"send_raw_message\" contracts\u002F\n```\n\nFor each outgoing message:\n- [ ] Forward amounts are fixed\u002Fbounded\n- [ ] OR user-provided amounts validated against msg_value\n- [ ] Cannot drain contract balance\n- [ ] Appropriate send_raw_message flags used\n\n### Step 5: Manual Review\nTON contracts require thorough manual review:\n- Boolean logic with `~`, `&`, `|` operators\n- Message parsing and validation\n- Gas economics and fee calculations\n- Storage operations and data serialization\n\n---\n\n## 8. Reporting Format\n\n### Coverage Table\n\nReport on every pattern in §6, whether or not it turned anything up. Emit this table above the findings, with\nall 3 rows present:\n\n| # | Pattern | Verdict | Evidence |\n|---|---------|---------|----------|\n| 1 | Integer as Boolean | `clear` | searched `is_`\u002F`has_`\u002F`flag`; all set to -1 |\n| 2 | Fake Jetton Contract | | |\n| 3 | Forward TON Without Gas Check | | |\n\nEach verdict is one of:\n\n- **`found`** — cite `file:line` and write the finding up in full below.\n- **`clear`** — the pattern applies to this contract and the contract handles it. Name the function, stored\n  address, or check you searched for, so a reader can repeat the search.\n- **`n\u002Fa`** — the pattern cannot apply here. Give the reason in one clause (\"this contract handles no Jetton\n  transfer notifications\"). Not having looked is not `n\u002Fa`.\n\nThree patterns is a short list, which makes an incomplete table harder to excuse rather than easier: a report\ncovering one pattern and silent on the other two reads exactly like a clean contract. Emit all three rows even\nwhen all three are `clear`. A row whose Verdict cell is empty is incomplete in the same way: row 1 above is filled in to show the shape, and every row is filled in the same way before the report is done.\n\n### Finding Template\n````markdown\n## [CRITICAL] Fake Jetton Contract - Missing Sender Validation\n\n**Location**: `contracts\u002Fstaking.fc:85-95` (recv_internal, transfer_notification handler)\n\n**Description**:\nThe `transfer_notification` operation handler does not validate that the sender is the expected Jetton wallet contract. Any attacker can send a fake `transfer_notification` message claiming to have transferred tokens, crediting themselves without actually depositing any Jettons.\n\n**Vulnerable Code**:\n```func\n\u002F\u002F staking.fc, line 85\nif (op == op::transfer_notification) {\n    int jetton_amount = in_msg_body~load_coins();\n    slice from_user = in_msg_body~load_msg_addr();\n\n    ;; WRONG: No validation of sender_address!\n    ;; Attacker can claim any jetton_amount\n\n    credit_user(from_user, jetton_amount);\n}\n```\n\n**Attack Scenario**:\n1. Attacker deploys malicious contract\n2. Malicious contract sends `transfer_notification` message to staking contract\n3. Message claims attacker transferred 1,000,000 Jettons\n4. Staking contract credits attacker without checking sender\n5. Attacker can now withdraw from contract or gain benefits without depositing\n\n**Proof of Concept**:\n```typescript\n\u002F\u002F Attacker sends fake transfer_notification\nconst attackerContract = await blockchain.treasury(\"attacker\");\n\nawait stakingContract.sendInternalMessage(attackerContract.getSender(), {\n  op: OP_CODES.TRANSFER_NOTIFICATION,\n  jettonAmount: toNano(\"1000000\"), \u002F\u002F Fake amount\n  fromUser: attackerContract.address,\n});\n\n\u002F\u002F Attacker successfully credited without sending real Jettons\nconst balance = await stakingContract.getUserBalance(attackerContract.address);\nexpect(balance).toEqual(toNano(\"1000000\")); \u002F\u002F Attack succeeded\n```\n\n**Recommendation**:\nStore expected Jetton wallet address and validate sender:\n```func\nglobal slice jetton_wallet_address;\n\n() recv_internal(...) impure {\n    load_data();  ;; Load jetton_wallet_address from storage\n\n    slice cs = in_msg_full.begin_parse();\n    int flags = cs~load_uint(4);\n    slice sender_address = cs~load_msg_addr();\n\n    int op = in_msg_body~load_uint(32);\n\n    if (op == op::transfer_notification) {\n        ;; CRITICAL: Validate sender\n        throw_unless(error::wrong_jetton_wallet,\n            equal_slices(sender_address, jetton_wallet_address));\n\n        int jetton_amount = in_msg_body~load_coins();\n        slice from_user = in_msg_body~load_msg_addr();\n\n        ;; Safe to credit user\n        credit_user(from_user, jetton_amount);\n    }\n}\n```\n\n**References**:\n- building-secure-contracts\u002Fnot-so-smart-contracts\u002Fton\u002Ffake_jetton_contract\n````\n\n---\n\n## 9. Priority Guidelines\n\n### Critical (Immediate Fix Required)\n- Fake Jetton contract (unauthorized minting\u002Fcrediting)\n\n### High (Fix Before Launch)\n- Integer as boolean (logic errors, broken conditions)\n- Forward TON without gas check (balance drainage)\n\n---\n\n## 10. Testing Recommendations\n\n### Unit Tests\n```typescript\nimport { Blockchain } from \"@ton\u002Fsandbox\";\nimport { toNano } from \"ton-core\";\n\ndescribe(\"Security tests\", () => {\n  let blockchain: Blockchain;\n  let contract: Contract;\n\n  beforeEach(async () => {\n    blockchain = await Blockchain.create();\n    contract = blockchain.openContract(await Contract.fromInit());\n  });\n\n  it(\"should use correct boolean values\", async () => {\n    \u002F\u002F Test that TRUE = -1, FALSE = 0\n    const result = await contract.getFlag();\n    expect(result).toEqual(-1n); \u002F\u002F True\n    expect(result).not.toEqual(1n); \u002F\u002F Not 1!\n  });\n\n  it(\"should reject fake jetton transfer\", async () => {\n    const attacker = await blockchain.treasury(\"attacker\");\n\n    const result = await contract.send(\n      attacker.getSender(),\n      { value: toNano(\"0.05\") },\n      {\n        $$type: \"TransferNotification\",\n        query_id: 0n,\n        amount: toNano(\"1000\"),\n        from: attacker.address,\n      }\n    );\n\n    expect(result.transactions).toHaveTransaction({\n      success: false, \u002F\u002F Should reject\n    });\n  });\n\n  it(\"should validate gas for forward amount\", async () => {\n    const result = await contract.send(\n      user.getSender(),\n      { value: toNano(\"0.01\") }, \u002F\u002F Insufficient gas\n      {\n        $$type: \"Transfer\",\n        to: recipient.address,\n        forward_ton_amount: toNano(\"1\"), \u002F\u002F Trying to forward 1 TON\n      }\n    );\n\n    expect(result.transactions).toHaveTransaction({\n      success: false,\n    });\n  });\n});\n```\n\n### Integration Tests\n```typescript\n\u002F\u002F Test with real Jetton wallet\nit(\"should accept transfer from real jetton wallet\", async () => {\n  \u002F\u002F Deploy actual Jetton minter and wallet\n  const jettonMinter = await blockchain.openContract(JettonMinter.create());\n  const userJettonWallet = await jettonMinter.getWalletAddress(user.address);\n\n  \u002F\u002F Set jetton wallet in contract\n  await contract.setJettonWallet(userJettonWallet);\n\n  \u002F\u002F Real transfer from Jetton wallet\n  const result = await userJettonWallet.sendTransfer(\n    user.getSender(),\n    contract.address,\n    toNano(\"100\"),\n    {}\n  );\n\n  expect(result.transactions).toHaveTransaction({\n    to: contract.address,\n    success: true,\n  });\n});\n```\n\n---\n\n## 11. Additional Resources\n\n- **Building Secure Contracts**: `building-secure-contracts\u002Fnot-so-smart-contracts\u002Fton\u002F`\n- **TON Documentation**: https:\u002F\u002Fdocs.ton.org\u002F\n- **FunC Documentation**: https:\u002F\u002Fdocs.ton.org\u002Fdevelop\u002Ffunc\u002Foverview\n- **TON Blueprint**: https:\u002F\u002Fgithub.com\u002Fton-org\u002Fblueprint\n- **Jetton Standard**: https:\u002F\u002Fgithub.com\u002Fton-blockchain\u002FTEPs\u002Fblob\u002Fmaster\u002Ftext\u002F0074-jettons-standard.md\n\n---\n\n## 12. Quick Reference Checklist\n\nBefore completing TON contract audit:\n\n**Boolean Logic (HIGH)**:\n- [ ] All boolean values use -1 (true) and 0 (false)\n- [ ] NO positive integers (1, 2, etc.) used as booleans\n- [ ] Functions returning booleans return -1 for true\n- [ ] Boolean logic with `~`, `&`, `|` uses correct values\n- [ ] Tests verify boolean operations work correctly\n\n**Jetton Security (CRITICAL)**:\n- [ ] `transfer_notification` handler validates sender address\n- [ ] Sender checked against stored Jetton wallet address\n- [ ] Jetton wallet address stored during initialization\n- [ ] Admin function to set\u002Fupdate Jetton wallet\n- [ ] Cannot trust forward_payload without sender validation\n- [ ] Tests with fake Jetton contracts verify rejection\n\n**Gas & Forward Amounts (HIGH)**:\n- [ ] Forward TON amounts are fixed\u002Fbounded\n- [ ] OR user-provided amounts validated: `msg_value >= tx_fee + forward_amount`\n- [ ] Contract balance protected from drainage\n- [ ] Appropriate `send_raw_message` flags used\n- [ ] Tests verify cannot drain contract with excessive forward amounts\n\n**Testing**:\n- [ ] Unit tests for all three vulnerability types\n- [ ] Integration tests with real Jetton contracts\n- [ ] Gas cost analysis for all operations\n- [ ] Testnet deployment before mainnet\n- [ ] Coverage table emitted with all 3 rows, each carrying a verdict of `found`, `clear` or `n\u002Fa` with a reason\n\n---\n\n## 13. Rationalizations to Reject\n\n- **\"The contract is small, so most patterns obviously don't apply.\"** Obvious to whom? An `n\u002Fa` costs one\n  clause and makes the judgment reviewable. Silence records nothing, and a reader cannot tell it apart from\n  not having checked. With only three patterns, there is no version of this scan too large to complete.\n- **\"There is no automated tooling for FunC, so coverage can't be systematic.\"** The absence of a scanner is\n  the reason the table matters, not an excuse for skipping it. Manual review is the method here; the table is\n  what makes it auditable.\n- **\"I checked the patterns that matter for this contract.\"** Deciding which patterns matter *is* the scan,\n  not a precondition for starting it. Rank by severity after the table is complete, not by leaving rows out.\n- **\"No findings, so there is nothing to report.\"** A zero-finding scan still emits the full coverage table.\n  That table is the deliverable: it is what distinguishes a contract that was examined from one that was\n  glanced at.\n- **\"The sender is obviously the Jetton wallet.\"** Then cite the stored address it is compared against. Any\n  contract can send a transfer notification; the check is a comparison against an address the contract itself\n  computed, and its absence is the fake-Jetton bug.\n- **\"The message is non-bounceable, so gas doesn't matter.\"** Name the reserve. Forwarding without leaving\n  enough for the remaining execution strands the contract mid-operation regardless of bounce behavior.\n",{"name":5,"description":7},"main","aa4fc8e4a5441efccc61aca4e77753a2e9f88c8b","audits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fton-vulnerability-scanner","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun","https:\u002F\u002Fraffle-fun-lake.vercel.app","https:\u002F\u002Fgithub.com\u002FHeesho","2026-10-22 13:02:00",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add Heesho\u002Fraffle-fun --skill ton-vulnerability-scanner",{"tool":36,"command":37},"bunx","bunx skills add Heesho\u002Fraffle-fun --skill ton-vulnerability-scanner",{"tool":39,"command":40},"pnpm","pnpm dlx skills add Heesho\u002Fraffle-fun --skill ton-vulnerability-scanner","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fton-vulnerability-scanner\u002FSKILL.md",true,[44,50,56],{"path":45,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":48,"sourceHtmlUrl":49},"agents\u002Fopenai.yaml","REFERENCE","参考文档",248,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fton-vulnerability-scanner\u002Fagents\u002Fopenai.yaml",{"path":51,"resourceType":52,"resourceTypeDesc":53,"sizeBytes":54,"sourceHtmlUrl":55},"assets\u002Ftrail-of-bits-mark.svg","ASSET","资产文件",3084,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fton-vulnerability-scanner\u002Fassets\u002Ftrail-of-bits-mark.svg",{"path":57,"resourceType":46,"resourceTypeDesc":47,"sizeBytes":58,"sourceHtmlUrl":59},"resources\u002FVULNERABILITY_PATTERNS.md",18564,"https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Fton-vulnerability-scanner\u002Fresources\u002FVULNERABILITY_PATTERNS.md",[61,68,75,82,87,94],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":18},"01M79XNCGXQ9R07VAPFB1H1WNF","spec-to-code-compliance","Check code against the documentation that specifies it - which requirements hold, which the code contradicts, which are absent, and what the code does that no document mentions. Use when comparing an implementation against a whitepaper, protocol spec, or design document.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-TOB\u002Fattempt-02\u002FS5\u002Fresources\u002Fskills\u002Fspec-to-code-compliance\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":18},"01M79XN7ADEZVW17912WC2CM7R","0xsimao-ai","Accounting-first smart contract security audit in the style of 0xSimao — maps the protocol's money model, then attacks it with 12 parallel lenses derived from his 869 published findings. Trigger on \"0xsimao ai\", \"0xsimao audit\", \"audit\", \"simao audit\", \"check this contract\", \"review for security\". Modes - default (full repo) or a specific filename.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-SIMAO\u002Fattempt-01\u002Fresources\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":18},"01M79XN26B8ZCW79FATC4TSXA5","solidity-auditor","Security audit of Solidity code while you develop. Trigger on \"audit\", \"check this contract\", \"review for security\", \"loop mode\", \"run the auditor in loop mode\", \"run 3 passes\". Modes - default (full repo) or a specific filename. Loop mode runs several passes in one scan, each pass told what the earlier ones found, and ends in one combined report; it remembers findings between scans in a ledger.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FOPENAI-PASHOV\u002Fattempt-01\u002Fharness-reference\u002FSKILL.md",[],[],{"skillNo":83,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":18},"01M79XMX0BKWJN0T8HZEBWTB6P","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fspec-to-code-compliance\u002F2.0.2\u002Fskills\u002Fspec-to-code-compliance\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":18},"01M79XMM06CBG09CMZ5N8PGAZ1","entry-point-analyzer","Analyzes smart contract codebases to identify state-changing entry points for security auditing. Detects externally callable functions that modify state, categorizes them by access level (public, admin, role-restricted, contract-only), and generates structured audit reports. Excludes view\u002Fpure\u002Fread-only functions. Use when auditing smart contracts (Solidity, Vyper, Solana\u002FRust, Move, TON, CosmWasm) or when asked to find entry points, audit flows, external functions, access control patterns, or privileged operations.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fentry-point-analyzer\u002F1.0.4\u002Fskills\u002Fentry-point-analyzer\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":18},"01M79XM5YH19VREYGM73DZ6F15","token-integration-analyzer","Token integration and implementation analyzer based on Trail of Bits' token integration checklist. Analyzes token implementations for ERC20\u002FERC721 conformity, checks for 20+ weird token patterns, assesses contract composition and owner privileges, performs on-chain scarcity analysis, and evaluates how protocols handle non-standard tokens. Use when integrating or accepting arbitrary ERC20\u002FERC721 tokens, auditing a token implementation for standards conformity, or assessing risk from weird tokens such as fee-on-transfer, rebasing, missing return values, or blocklists.","https:\u002F\u002Fgithub.com\u002FHeesho\u002Fraffle-fun\u002Fblob\u002Fmain\u002Faudits\u002F2026-10-21-r001\u002Fruns\u002FDAYBREAK-TOB\u002Fattempt-02\u002Fruntime\u002Fcodex-home\u002Fplugins\u002Fcache\u002Ftrailofbits\u002Fbuilding-secure-contracts\u002F1.2.2\u002Fskills\u002Ftoken-integration-analyzer\u002FSKILL.md",[],[]]