@snovon/solast 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +190 -0
- package/dist/api.d.ts +89 -0
- package/dist/api.js +33 -0
- package/dist/ast/resolve-return-names.d.ts +2 -0
- package/dist/ast/resolve-return-names.js +199 -0
- package/dist/ast/solc-walker.d.ts +17 -0
- package/dist/ast/solc-walker.js +497 -0
- package/dist/ast/storage-layout.d.ts +21 -0
- package/dist/ast/storage-layout.js +64 -0
- package/dist/cli.d.ts +65 -0
- package/dist/cli.js +755 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +284 -0
- package/dist/dedup/files.d.ts +1 -0
- package/dist/dedup/files.js +74 -0
- package/dist/dedup/findings.d.ts +41 -0
- package/dist/dedup/findings.js +211 -0
- package/dist/detectors/_common/access-control.d.ts +204 -0
- package/dist/detectors/_common/access-control.js +377 -0
- package/dist/detectors/_common/ast.d.ts +139 -0
- package/dist/detectors/_common/ast.js +239 -0
- package/dist/detectors/_common/compiler-profile.d.ts +14 -0
- package/dist/detectors/_common/compiler-profile.js +66 -0
- package/dist/detectors/_common/dataflow.d.ts +75 -0
- package/dist/detectors/_common/dataflow.js +57 -0
- package/dist/detectors/_common/fhe.d.ts +7 -0
- package/dist/detectors/_common/fhe.js +40 -0
- package/dist/detectors/_common/integer-overflow-helpers.d.ts +58 -0
- package/dist/detectors/_common/integer-overflow-helpers.js +422 -0
- package/dist/detectors/_common/loop-call-stack.d.ts +9 -0
- package/dist/detectors/_common/loop-call-stack.js +132 -0
- package/dist/detectors/_common/oracle.d.ts +5 -0
- package/dist/detectors/_common/oracle.js +64 -0
- package/dist/detectors/_common/price-rate.d.ts +116 -0
- package/dist/detectors/_common/price-rate.js +446 -0
- package/dist/detectors/_common/source-text.d.ts +11 -0
- package/dist/detectors/_common/source-text.js +82 -0
- package/dist/detectors/_common/weighted-pool-invariant.d.ts +21 -0
- package/dist/detectors/_common/weighted-pool-invariant.js +105 -0
- package/dist/detectors/aave-v2-reentrancy.d.ts +7 -0
- package/dist/detectors/aave-v2-reentrancy.js +286 -0
- package/dist/detectors/access-control.d.ts +103 -0
- package/dist/detectors/access-control.js +983 -0
- package/dist/detectors/add-reentrancy-on-weth-contract.d.ts +7 -0
- package/dist/detectors/add-reentrancy-on-weth-contract.js +536 -0
- package/dist/detectors/ai-generated-randomness.d.ts +32 -0
- package/dist/detectors/ai-generated-randomness.js +239 -0
- package/dist/detectors/amm-spot-oracle-manipulation.d.ts +52 -0
- package/dist/detectors/amm-spot-oracle-manipulation.js +420 -0
- package/dist/detectors/analyzing-the-uniswap-v3-exploit.d.ts +26 -0
- package/dist/detectors/analyzing-the-uniswap-v3-exploit.js +279 -0
- package/dist/detectors/any-token-is-destroyed.d.ts +34 -0
- package/dist/detectors/any-token-is-destroyed.js +527 -0
- package/dist/detectors/anyswap-anytoken-permit-allowance-drain.d.ts +7 -0
- package/dist/detectors/anyswap-anytoken-permit-allowance-drain.js +524 -0
- package/dist/detectors/anyswap-insufficient-token-validation.d.ts +24 -0
- package/dist/detectors/anyswap-insufficient-token-validation.js +342 -0
- package/dist/detectors/approval-based-drain.d.ts +7 -0
- package/dist/detectors/approval-based-drain.js +772 -0
- package/dist/detectors/arbitrary-account-balance-transfer.d.ts +7 -0
- package/dist/detectors/arbitrary-account-balance-transfer.js +485 -0
- package/dist/detectors/arbitrary-address-spoofing-attack.d.ts +7 -0
- package/dist/detectors/arbitrary-address-spoofing-attack.js +444 -0
- package/dist/detectors/arbitrary-address-spoofing.d.ts +9 -0
- package/dist/detectors/arbitrary-address-spoofing.js +657 -0
- package/dist/detectors/arbitrary-call-error.d.ts +127 -0
- package/dist/detectors/arbitrary-call-error.js +1163 -0
- package/dist/detectors/arbitrary-call.d.ts +4 -0
- package/dist/detectors/arbitrary-call.js +11 -0
- package/dist/detectors/arbitrary-delegatecall-target.d.ts +35 -0
- package/dist/detectors/arbitrary-delegatecall-target.js +554 -0
- package/dist/detectors/arbitrary-recipient-no-access-control.d.ts +7 -0
- package/dist/detectors/arbitrary-recipient-no-access-control.js +638 -0
- package/dist/detectors/arbitrary-storage-proof-forgery.d.ts +35 -0
- package/dist/detectors/arbitrary-storage-proof-forgery.js +340 -0
- package/dist/detectors/arbitrary-transfer-from.d.ts +38 -0
- package/dist/detectors/arbitrary-transfer-from.js +339 -0
- package/dist/detectors/arbitrum-cross-chain-message-replay.d.ts +22 -0
- package/dist/detectors/arbitrum-cross-chain-message-replay.js +477 -0
- package/dist/detectors/avs-slashing-without-quorum-check.d.ts +50 -0
- package/dist/detectors/avs-slashing-without-quorum-check.js +386 -0
- package/dist/detectors/bad-debt-propagation.d.ts +13 -0
- package/dist/detectors/bad-debt-propagation.js +480 -0
- package/dist/detectors/bad-k-value-verification.d.ts +7 -0
- package/dist/detectors/bad-k-value-verification.js +512 -0
- package/dist/detectors/bad-randomness-zero-blockhash.d.ts +29 -0
- package/dist/detectors/bad-randomness-zero-blockhash.js +115 -0
- package/dist/detectors/balancer-flash-loan-manipulation.d.ts +33 -0
- package/dist/detectors/balancer-flash-loan-manipulation.js +178 -0
- package/dist/detectors/balancer-pause-guard.d.ts +33 -0
- package/dist/detectors/balancer-pause-guard.js +307 -0
- package/dist/detectors/balancer-weighted-pool-flash-loan.d.ts +42 -0
- package/dist/detectors/balancer-weighted-pool-flash-loan.js +275 -0
- package/dist/detectors/batch-transfer-overflow.d.ts +7 -0
- package/dist/detectors/batch-transfer-overflow.js +465 -0
- package/dist/detectors/beneficiary-validation.d.ts +7 -0
- package/dist/detectors/beneficiary-validation.js +696 -0
- package/dist/detectors/borrow-behalf-consent.d.ts +7 -0
- package/dist/detectors/borrow-behalf-consent.js +400 -0
- package/dist/detectors/break-continue-scope.d.ts +7 -0
- package/dist/detectors/break-continue-scope.js +194 -0
- package/dist/detectors/bridge-accounting-bypass.d.ts +65 -0
- package/dist/detectors/bridge-accounting-bypass.js +449 -0
- package/dist/detectors/bridge-business-logic-flaw-incorrect-acc.d.ts +43 -0
- package/dist/detectors/bridge-business-logic-flaw-incorrect-acc.js +394 -0
- package/dist/detectors/bridge-collateral-drain.d.ts +7 -0
- package/dist/detectors/bridge-collateral-drain.js +630 -0
- package/dist/detectors/bridge-forged-proof.d.ts +7 -0
- package/dist/detectors/bridge-forged-proof.js +754 -0
- package/dist/detectors/bridge-missing-message-nonce.d.ts +57 -0
- package/dist/detectors/bridge-missing-message-nonce.js +638 -0
- package/dist/detectors/bridge-swap-metapool-attack.d.ts +20 -0
- package/dist/detectors/bridge-swap-metapool-attack.js +230 -0
- package/dist/detectors/business-logic-flaw-flashloan-price-mani.d.ts +7 -0
- package/dist/detectors/business-logic-flaw-flashloan-price-mani.js +353 -0
- package/dist/detectors/business-logic-flaw-incorrect-recipient-balance.d.ts +7 -0
- package/dist/detectors/business-logic-flaw-incorrect-recipient-balance.js +403 -0
- package/dist/detectors/business-logic-flaw.d.ts +21 -0
- package/dist/detectors/business-logic-flaw.js +339 -0
- package/dist/detectors/business-logic.d.ts +17 -0
- package/dist/detectors/business-logic.js +22 -0
- package/dist/detectors/bypassed-insolvency-check.d.ts +30 -0
- package/dist/detectors/bypassed-insolvency-check.js +232 -0
- package/dist/detectors/bytecode-divergence-risk.d.ts +32 -0
- package/dist/detectors/bytecode-divergence-risk.js +150 -0
- package/dist/detectors/cache-array-length.d.ts +30 -0
- package/dist/detectors/cache-array-length.js +177 -0
- package/dist/detectors/cache-storage-reads.d.ts +46 -0
- package/dist/detectors/cache-storage-reads.js +323 -0
- package/dist/detectors/calldata-secret-access-control.d.ts +36 -0
- package/dist/detectors/calldata-secret-access-control.js +446 -0
- package/dist/detectors/capital-cross-contract-reentrancy.d.ts +34 -0
- package/dist/detectors/capital-cross-contract-reentrancy.js +481 -0
- package/dist/detectors/cartel-custom-approval-logic.d.ts +7 -0
- package/dist/detectors/cartel-custom-approval-logic.js +407 -0
- package/dist/detectors/ccip-receiver-missing-replay-guard.d.ts +22 -0
- package/dist/detectors/ccip-receiver-missing-replay-guard.js +413 -0
- package/dist/detectors/chain-coupling-risk.d.ts +8 -0
- package/dist/detectors/chain-coupling-risk.js +203 -0
- package/dist/detectors/chainlink-deprecated-function.d.ts +7 -0
- package/dist/detectors/chainlink-deprecated-function.js +205 -0
- package/dist/detectors/chainlink-tx-origin.d.ts +7 -0
- package/dist/detectors/chainlink-tx-origin.js +363 -0
- package/dist/detectors/check-effects-interactions.d.ts +39 -0
- package/dist/detectors/check-effects-interactions.js +783 -0
- package/dist/detectors/check-permit-missing-chainid.d.ts +27 -0
- package/dist/detectors/check-permit-missing-chainid.js +456 -0
- package/dist/detectors/classic-reentrancy.d.ts +93 -0
- package/dist/detectors/classic-reentrancy.js +645 -0
- package/dist/detectors/coinbase-morpho-wethloan-policy.d.ts +29 -0
- package/dist/detectors/coinbase-morpho-wethloan-policy.js +368 -0
- package/dist/detectors/compoundv2-inflation-attack.d.ts +7 -0
- package/dist/detectors/compoundv2-inflation-attack.js +675 -0
- package/dist/detectors/constructor-address-validation.d.ts +24 -0
- package/dist/detectors/constructor-address-validation.js +335 -0
- package/dist/detectors/constructor-interface-no-address-validation.d.ts +32 -0
- package/dist/detectors/constructor-interface-no-address-validation.js +283 -0
- package/dist/detectors/cross-chain-arbitrary-call.d.ts +7 -0
- package/dist/detectors/cross-chain-arbitrary-call.js +601 -0
- package/dist/detectors/cross-chain-input-validation.d.ts +31 -0
- package/dist/detectors/cross-chain-input-validation.js +347 -0
- package/dist/detectors/cross-chain-intent-replay.d.ts +38 -0
- package/dist/detectors/cross-chain-intent-replay.js +453 -0
- package/dist/detectors/cross-chain-intent-stale-resolution.d.ts +7 -0
- package/dist/detectors/cross-chain-intent-stale-resolution.js +463 -0
- package/dist/detectors/cross-chain-message-order-dependency.d.ts +8 -0
- package/dist/detectors/cross-chain-message-order-dependency.js +472 -0
- package/dist/detectors/cross-chain-message-replay.d.ts +8 -0
- package/dist/detectors/cross-chain-message-replay.js +568 -0
- package/dist/detectors/cross-chain-messaging.d.ts +7 -0
- package/dist/detectors/cross-chain-messaging.js +663 -0
- package/dist/detectors/cross-chain-msg-truncation.d.ts +7 -0
- package/dist/detectors/cross-chain-msg-truncation.js +453 -0
- package/dist/detectors/cross-chain-truncation.d.ts +7 -0
- package/dist/detectors/cross-chain-truncation.js +422 -0
- package/dist/detectors/cross-contract-integer-overflow.d.ts +76 -0
- package/dist/detectors/cross-contract-integer-overflow.js +554 -0
- package/dist/detectors/cross-contract-reentrancy-trusted-callee.d.ts +39 -0
- package/dist/detectors/cross-contract-reentrancy-trusted-callee.js +385 -0
- package/dist/detectors/cross-contract-reentrancy.d.ts +63 -0
- package/dist/detectors/cross-contract-reentrancy.js +631 -0
- package/dist/detectors/cross-function-reentrancy.d.ts +37 -0
- package/dist/detectors/cross-function-reentrancy.js +648 -0
- package/dist/detectors/cross-protocol-contagion.d.ts +20 -0
- package/dist/detectors/cross-protocol-contagion.js +445 -0
- package/dist/detectors/cross-protocol-oracle-collateral.d.ts +38 -0
- package/dist/detectors/cross-protocol-oracle-collateral.js +487 -0
- package/dist/detectors/cross-vm-reentrancy.d.ts +7 -0
- package/dist/detectors/cross-vm-reentrancy.js +484 -0
- package/dist/detectors/decimals-mismatch.d.ts +89 -0
- package/dist/detectors/decimals-mismatch.js +451 -0
- package/dist/detectors/deferred-state-update.d.ts +16 -0
- package/dist/detectors/deferred-state-update.js +35 -0
- package/dist/detectors/deflationary-token.d.ts +27 -0
- package/dist/detectors/deflationary-token.js +751 -0
- package/dist/detectors/delegate-transfer-unrestricted-caller.d.ts +44 -0
- package/dist/detectors/delegate-transfer-unrestricted-caller.js +410 -0
- package/dist/detectors/delegatecall-fallback-reentrancy-bypass.d.ts +14 -0
- package/dist/detectors/delegatecall-fallback-reentrancy-bypass.js +241 -0
- package/dist/detectors/delegatecall-in-loops.d.ts +7 -0
- package/dist/detectors/delegatecall-in-loops.js +129 -0
- package/dist/detectors/delegatecall-init-owner-mutator.d.ts +8 -0
- package/dist/detectors/delegatecall-init-owner-mutator.js +655 -0
- package/dist/detectors/delegatecall-init.d.ts +7 -0
- package/dist/detectors/delegatecall-init.js +769 -0
- package/dist/detectors/delegatecall-untrusted-implementation.d.ts +41 -0
- package/dist/detectors/delegatecall-untrusted-implementation.js +888 -0
- package/dist/detectors/delegated-authorization-bypass.d.ts +7 -0
- package/dist/detectors/delegated-authorization-bypass.js +370 -0
- package/dist/detectors/denial-of-service.d.ts +117 -0
- package/dist/detectors/denial-of-service.js +947 -0
- package/dist/detectors/division-before-multiplication.d.ts +7 -0
- package/dist/detectors/division-before-multiplication.js +303 -0
- package/dist/detectors/dn404-mirror-access-control.d.ts +26 -0
- package/dist/detectors/dn404-mirror-access-control.js +315 -0
- package/dist/detectors/doge-flashloan.d.ts +29 -0
- package/dist/detectors/doge-flashloan.js +329 -0
- package/dist/detectors/donate-inflation-exchangerate-roundin.d.ts +7 -0
- package/dist/detectors/donate-inflation-exchangerate-roundin.js +621 -0
- package/dist/detectors/donation-share-inflation.d.ts +24 -0
- package/dist/detectors/donation-share-inflation.js +466 -0
- package/dist/detectors/dont-let-eth-get-rekt.d.ts +84 -0
- package/dist/detectors/dont-let-eth-get-rekt.js +1151 -0
- package/dist/detectors/dos-unbounded-loop-external-call-revert.d.ts +37 -0
- package/dist/detectors/dos-unbounded-loop-external-call-revert.js +541 -0
- package/dist/detectors/eip1167-proxy-reentrancy.d.ts +7 -0
- package/dist/detectors/eip1167-proxy-reentrancy.js +508 -0
- package/dist/detectors/eip4626-vault-reentrancy.d.ts +32 -0
- package/dist/detectors/eip4626-vault-reentrancy.js +312 -0
- package/dist/detectors/eip5792-auth-replay.d.ts +45 -0
- package/dist/detectors/eip5792-auth-replay.js +519 -0
- package/dist/detectors/eip712-domain-separator.d.ts +42 -0
- package/dist/detectors/eip712-domain-separator.js +524 -0
- package/dist/detectors/eip712-signature-verification.d.ts +49 -0
- package/dist/detectors/eip712-signature-verification.js +689 -0
- package/dist/detectors/eip7702-auth-replay.d.ts +7 -0
- package/dist/detectors/eip7702-auth-replay.js +768 -0
- package/dist/detectors/eip7702-cross-chain-replay.d.ts +27 -0
- package/dist/detectors/eip7702-cross-chain-replay.js +307 -0
- package/dist/detectors/eip7702-delegated-eoa-approval-race.d.ts +39 -0
- package/dist/detectors/eip7702-delegated-eoa-approval-race.js +413 -0
- package/dist/detectors/eip7702-delegation-reentrancy.d.ts +21 -0
- package/dist/detectors/eip7702-delegation-reentrancy.js +705 -0
- package/dist/detectors/eip7702-delegation-risk.d.ts +7 -0
- package/dist/detectors/eip7702-delegation-risk.js +745 -0
- package/dist/detectors/eip7702-eoa-assumption.d.ts +57 -0
- package/dist/detectors/eip7702-eoa-assumption.js +461 -0
- package/dist/detectors/erc1155-batch-missing-per-id-approval.d.ts +23 -0
- package/dist/detectors/erc1155-batch-missing-per-id-approval.js +343 -0
- package/dist/detectors/erc1155-reentrancy.d.ts +31 -0
- package/dist/detectors/erc1155-reentrancy.js +217 -0
- package/dist/detectors/erc1271-stub-implementation.d.ts +21 -0
- package/dist/detectors/erc1271-stub-implementation.js +268 -0
- package/dist/detectors/erc20-safe-wrapper-return-unchecked.d.ts +43 -0
- package/dist/detectors/erc20-safe-wrapper-return-unchecked.js +368 -0
- package/dist/detectors/erc20-unchecked-non-standard-return.d.ts +55 -0
- package/dist/detectors/erc20-unchecked-non-standard-return.js +454 -0
- package/dist/detectors/erc2612-permit-frontrunning.d.ts +23 -0
- package/dist/detectors/erc2612-permit-frontrunning.js +246 -0
- package/dist/detectors/erc2771-context-spoofing.d.ts +41 -0
- package/dist/detectors/erc2771-context-spoofing.js +510 -0
- package/dist/detectors/erc4337-validation-storage-access.d.ts +35 -0
- package/dist/detectors/erc4337-validation-storage-access.js +232 -0
- package/dist/detectors/erc4626-totalassets-stub.d.ts +17 -0
- package/dist/detectors/erc4626-totalassets-stub.js +216 -0
- package/dist/detectors/erc6909-balance-overflow.d.ts +7 -0
- package/dist/detectors/erc6909-balance-overflow.js +688 -0
- package/dist/detectors/erc6909-operator-scope.d.ts +49 -0
- package/dist/detectors/erc6909-operator-scope.js +494 -0
- package/dist/detectors/erc721-unchecked-transfer.d.ts +38 -0
- package/dist/detectors/erc721-unchecked-transfer.js +364 -0
- package/dist/detectors/erc7579-module-install-without-threshold.d.ts +40 -0
- package/dist/detectors/erc7579-module-install-without-threshold.js +338 -0
- package/dist/detectors/erc7683-fill-validation.d.ts +53 -0
- package/dist/detectors/erc7683-fill-validation.js +758 -0
- package/dist/detectors/erc7683-intent-resolution.d.ts +7 -0
- package/dist/detectors/erc7683-intent-resolution.js +457 -0
- package/dist/detectors/erc777-callback-reentrancy.d.ts +8 -0
- package/dist/detectors/erc777-callback-reentrancy.js +439 -0
- package/dist/detectors/erc777-reentrancy.d.ts +7 -0
- package/dist/detectors/erc777-reentrancy.js +488 -0
- package/dist/detectors/erc777-tokens-to-send-reentrancy.d.ts +47 -0
- package/dist/detectors/erc777-tokens-to-send-reentrancy.js +674 -0
- package/dist/detectors/estuary-token-flaw.d.ts +16 -0
- package/dist/detectors/estuary-token-flaw.js +547 -0
- package/dist/detectors/euler-debt-token-manipulation.d.ts +32 -0
- package/dist/detectors/euler-debt-token-manipulation.js +347 -0
- package/dist/detectors/exploiting-a-vulnerability-in-curve-fina.d.ts +29 -0
- package/dist/detectors/exploiting-a-vulnerability-in-curve-fina.js +210 -0
- package/dist/detectors/fallback-delegatecall-reentrancy.d.ts +14 -0
- package/dist/detectors/fallback-delegatecall-reentrancy.js +236 -0
- package/dist/detectors/farm-business-logic-flaw-lack-of-access.d.ts +7 -0
- package/dist/detectors/farm-business-logic-flaw-lack-of-access.js +665 -0
- package/dist/detectors/fee-mechanism-exploitation.d.ts +20 -0
- package/dist/detectors/fee-mechanism-exploitation.js +400 -0
- package/dist/detectors/fee-on-transfer-balance-mismatch.d.ts +49 -0
- package/dist/detectors/fee-on-transfer-balance-mismatch.js +394 -0
- package/dist/detectors/fhe-encrypted-input-validation.d.ts +29 -0
- package/dist/detectors/fhe-encrypted-input-validation.js +210 -0
- package/dist/detectors/fhe-handle-leakage.d.ts +44 -0
- package/dist/detectors/fhe-handle-leakage.js +315 -0
- package/dist/detectors/fhe-oz-pattern-misuse.d.ts +26 -0
- package/dist/detectors/fhe-oz-pattern-misuse.js +311 -0
- package/dist/detectors/fhe-state-leakage.d.ts +8 -0
- package/dist/detectors/fhe-state-leakage.js +400 -0
- package/dist/detectors/fi-bridges.d.ts +33 -0
- package/dist/detectors/fi-bridges.js +428 -0
- package/dist/detectors/finance-access-control-price-oracle-man.d.ts +9 -0
- package/dist/detectors/finance-access-control-price-oracle-man.js +640 -0
- package/dist/detectors/finance-bridge-address0safetransferfrom.d.ts +8 -0
- package/dist/detectors/finance-bridge-address0safetransferfrom.js +574 -0
- package/dist/detectors/finance-business-logic-in-mint.d.ts +54 -0
- package/dist/detectors/finance-business-logic-in-mint.js +687 -0
- package/dist/detectors/finance-erc667-reentrancy.d.ts +7 -0
- package/dist/detectors/finance-erc667-reentrancy.js +509 -0
- package/dist/detectors/finance-flashloan-price-oracle-manipul.d.ts +7 -0
- package/dist/detectors/finance-flashloan-price-oracle-manipul.js +546 -0
- package/dist/detectors/finance-flashloan-reentrancy.d.ts +7 -0
- package/dist/detectors/finance-flashloan-reentrancy.js +547 -0
- package/dist/detectors/finance-swap-metapool-attack.d.ts +19 -0
- package/dist/detectors/finance-swap-metapool-attack.js +321 -0
- package/dist/detectors/flashloan-price-manipulation.d.ts +7 -0
- package/dist/detectors/flashloan-price-manipulation.js +950 -0
- package/dist/detectors/flashloan-reentrancy-rari.d.ts +28 -0
- package/dist/detectors/flashloan-reentrancy-rari.js +577 -0
- package/dist/detectors/flashloan-reentrancy.d.ts +7 -0
- package/dist/detectors/flashloan-reentrancy.js +383 -0
- package/dist/detectors/flashloan-token-migrate.d.ts +7 -0
- package/dist/detectors/flashloan-token-migrate.js +274 -0
- package/dist/detectors/force-fed-eth-state-corruption.d.ts +32 -0
- package/dist/detectors/force-fed-eth-state-corruption.js +293 -0
- package/dist/detectors/free-mint-bug.d.ts +41 -0
- package/dist/detectors/free-mint-bug.js +483 -0
- package/dist/detectors/front-running-orderbook-state-update.d.ts +37 -0
- package/dist/detectors/front-running-orderbook-state-update.js +471 -0
- package/dist/detectors/front-running-shared-collateral-write.d.ts +41 -0
- package/dist/detectors/front-running-shared-collateral-write.js +508 -0
- package/dist/detectors/fusion-v1-settlement-arbitrary-yul-calld.d.ts +30 -0
- package/dist/detectors/fusion-v1-settlement-arbitrary-yul-calld.js +354 -0
- package/dist/detectors/generalized-frontrunning.d.ts +7 -0
- package/dist/detectors/generalized-frontrunning.js +836 -0
- package/dist/detectors/governance-flash-loan.d.ts +62 -0
- package/dist/detectors/governance-flash-loan.js +452 -0
- package/dist/detectors/governance-flashloan-vote.d.ts +41 -0
- package/dist/detectors/governance-flashloan-vote.js +272 -0
- package/dist/detectors/halborn-security-report-aave-v3.d.ts +6 -0
- package/dist/detectors/halborn-security-report-aave-v3.js +357 -0
- package/dist/detectors/incorrect-access-control.d.ts +26 -0
- package/dist/detectors/incorrect-access-control.js +328 -0
- package/dist/detectors/incorrect-burn-accounting.d.ts +10 -0
- package/dist/detectors/incorrect-burn-accounting.js +387 -0
- package/dist/detectors/incorrect-dividends-calculation.d.ts +27 -0
- package/dist/detectors/incorrect-dividends-calculation.js +524 -0
- package/dist/detectors/incorrect-dividends.d.ts +27 -0
- package/dist/detectors/incorrect-dividends.js +485 -0
- package/dist/detectors/incorrect-input-validation.d.ts +23 -0
- package/dist/detectors/incorrect-input-validation.js +312 -0
- package/dist/detectors/incorrect-signature-verification.d.ts +26 -0
- package/dist/detectors/incorrect-signature-verification.js +530 -0
- package/dist/detectors/infinite-loop.d.ts +7 -0
- package/dist/detectors/infinite-loop.js +440 -0
- package/dist/detectors/infinite-number-of-loans.d.ts +13 -0
- package/dist/detectors/infinite-number-of-loans.js +565 -0
- package/dist/detectors/inheritance-override.d.ts +26 -0
- package/dist/detectors/inheritance-override.js +320 -0
- package/dist/detectors/initialization-access-control.d.ts +8 -0
- package/dist/detectors/initialization-access-control.js +659 -0
- package/dist/detectors/insecure-randomness.d.ts +73 -0
- package/dist/detectors/insecure-randomness.js +610 -0
- package/dist/detectors/insufficient-access-control-trusted-param.d.ts +39 -0
- package/dist/detectors/insufficient-access-control-trusted-param.js +356 -0
- package/dist/detectors/insufficient-dvn-threshold.d.ts +32 -0
- package/dist/detectors/insufficient-dvn-threshold.js +585 -0
- package/dist/detectors/integer-overflow-detector.d.ts +45 -0
- package/dist/detectors/integer-overflow-detector.js +284 -0
- package/dist/detectors/integer-overflow.d.ts +95 -0
- package/dist/detectors/integer-overflow.js +344 -0
- package/dist/detectors/integer-underflow.d.ts +7 -0
- package/dist/detectors/integer-underflow.js +422 -0
- package/dist/detectors/intent-settlement-balance-manipulation.d.ts +22 -0
- package/dist/detectors/intent-settlement-balance-manipulation.js +548 -0
- package/dist/detectors/l1-to-l2-message-reentrancy.d.ts +7 -0
- package/dist/detectors/l1-to-l2-message-reentrancy.js +545 -0
- package/dist/detectors/l2-withdrawal-validation.d.ts +8 -0
- package/dist/detectors/l2-withdrawal-validation.js +303 -0
- package/dist/detectors/lack-of-access-control.d.ts +7 -0
- package/dist/detectors/lack-of-access-control.js +425 -0
- package/dist/detectors/lack-of-calldata-validation.d.ts +16 -0
- package/dist/detectors/lack-of-calldata-validation.js +914 -0
- package/dist/detectors/lack-of-input-validation-reentrancy.d.ts +7 -0
- package/dist/detectors/lack-of-input-validation-reentrancy.js +637 -0
- package/dist/detectors/lack-of-slippage-control.d.ts +7 -0
- package/dist/detectors/lack-of-slippage-control.js +513 -0
- package/dist/detectors/lack-of-slippage-protection.d.ts +7 -0
- package/dist/detectors/lack-of-slippage-protection.js +474 -0
- package/dist/detectors/lack-of-validation-data.d.ts +23 -0
- package/dist/detectors/lack-of-validation-data.js +391 -0
- package/dist/detectors/lack-of-validation-pool.d.ts +7 -0
- package/dist/detectors/lack-of-validation-pool.js +492 -0
- package/dist/detectors/lack-of-validation-userdata.d.ts +7 -0
- package/dist/detectors/lack-of-validation-userdata.js +583 -0
- package/dist/detectors/lack-of-validation.d.ts +27 -0
- package/dist/detectors/lack-of-validation.js +609 -0
- package/dist/detectors/layerzero-dvn-quorum-missing.d.ts +22 -0
- package/dist/detectors/layerzero-dvn-quorum-missing.js +464 -0
- package/dist/detectors/layerzero-v2-unverified-origin.d.ts +40 -0
- package/dist/detectors/layerzero-v2-unverified-origin.js +368 -0
- package/dist/detectors/liquidation-accounting-desync.d.ts +14 -0
- package/dist/detectors/liquidation-accounting-desync.js +145 -0
- package/dist/detectors/liquidation-gain-manipulation.d.ts +42 -0
- package/dist/detectors/liquidation-gain-manipulation.js +606 -0
- package/dist/detectors/liquidation-price-rounding-advantage.d.ts +26 -0
- package/dist/detectors/liquidation-price-rounding-advantage.js +283 -0
- package/dist/detectors/liquidity-poisoning.d.ts +25 -0
- package/dist/detectors/liquidity-poisoning.js +339 -0
- package/dist/detectors/loans-malicious-proposal-price-oracle.d.ts +44 -0
- package/dist/detectors/loans-malicious-proposal-price-oracle.js +813 -0
- package/dist/detectors/logic-flaw.d.ts +186 -0
- package/dist/detectors/logic-flaw.js +3356 -0
- package/dist/detectors/manipulation-of-funds.d.ts +31 -0
- package/dist/detectors/manipulation-of-funds.js +304 -0
- package/dist/detectors/merkl-unsafe-claim-callback.d.ts +22 -0
- package/dist/detectors/merkl-unsafe-claim-callback.js +94 -0
- package/dist/detectors/mev-boost-timestamp.d.ts +7 -0
- package/dist/detectors/mev-boost-timestamp.js +318 -0
- package/dist/detectors/mev-merge-exploit.d.ts +29 -0
- package/dist/detectors/mev-merge-exploit.js +397 -0
- package/dist/detectors/mev-sandwich-vulnerability.d.ts +24 -0
- package/dist/detectors/mev-sandwich-vulnerability.js +648 -0
- package/dist/detectors/mev-slot-manipulation.d.ts +36 -0
- package/dist/detectors/mev-slot-manipulation.js +691 -0
- package/dist/detectors/mevbot-insufficient-validation.d.ts +48 -0
- package/dist/detectors/mevbot-insufficient-validation.js +574 -0
- package/dist/detectors/migration-rebalance-without-bound.d.ts +7 -0
- package/dist/detectors/migration-rebalance-without-bound.js +514 -0
- package/dist/detectors/mint-hardcoded-asset-parity.d.ts +31 -0
- package/dist/detectors/mint-hardcoded-asset-parity.js +356 -0
- package/dist/detectors/miscalculation-on-spendallowance.d.ts +7 -0
- package/dist/detectors/miscalculation-on-spendallowance.js +188 -0
- package/dist/detectors/misconfiguration.d.ts +27 -0
- package/dist/detectors/misconfiguration.js +410 -0
- package/dist/detectors/missing-access-control-caller-supplied-auth.d.ts +7 -0
- package/dist/detectors/missing-access-control-caller-supplied-auth.js +550 -0
- package/dist/detectors/missing-access-control-receiver-payout.d.ts +7 -0
- package/dist/detectors/missing-access-control-receiver-payout.js +460 -0
- package/dist/detectors/missing-access-control-role-or-transferfrom.d.ts +7 -0
- package/dist/detectors/missing-access-control-role-or-transferfrom.js +663 -0
- package/dist/detectors/missing-access-control.d.ts +19 -0
- package/dist/detectors/missing-access-control.js +781 -0
- package/dist/detectors/missing-sequencer-uptime-check.d.ts +30 -0
- package/dist/detectors/missing-sequencer-uptime-check.js +348 -0
- package/dist/detectors/missing-storage-gap.d.ts +19 -0
- package/dist/detectors/missing-storage-gap.js +193 -0
- package/dist/detectors/missing-swap-deadline-slippage.d.ts +31 -0
- package/dist/detectors/missing-swap-deadline-slippage.js +231 -0
- package/dist/detectors/missing-zk-proof-verification.d.ts +60 -0
- package/dist/detectors/missing-zk-proof-verification.js +547 -0
- package/dist/detectors/my-experience-with-yearn-finance.d.ts +7 -0
- package/dist/detectors/my-experience-with-yearn-finance.js +552 -0
- package/dist/detectors/network-bridge-ronin.d.ts +7 -0
- package/dist/detectors/network-bridge-ronin.js +408 -0
- package/dist/detectors/network-bridge.d.ts +7 -0
- package/dist/detectors/network-bridge.js +444 -0
- package/dist/detectors/network-underflow.d.ts +7 -0
- package/dist/detectors/network-underflow.js +517 -0
- package/dist/detectors/nft-denial-of-service.d.ts +7 -0
- package/dist/detectors/nft-denial-of-service.js +223 -0
- package/dist/detectors/nft-marketplace-order-reentrancy.d.ts +7 -0
- package/dist/detectors/nft-marketplace-order-reentrancy.js +427 -0
- package/dist/detectors/nft-token-standard-access-control.d.ts +7 -0
- package/dist/detectors/nft-token-standard-access-control.js +455 -0
- package/dist/detectors/oracle-manipulation-amm-spot-price.d.ts +42 -0
- package/dist/detectors/oracle-manipulation-amm-spot-price.js +321 -0
- package/dist/detectors/oracle-manipulation-liquidity-withdrawal.d.ts +27 -0
- package/dist/detectors/oracle-manipulation-liquidity-withdrawal.js +192 -0
- package/dist/detectors/oracle-manipulation.d.ts +90 -0
- package/dist/detectors/oracle-manipulation.js +1023 -0
- package/dist/detectors/oracle-vortex-manipulation.d.ts +30 -0
- package/dist/detectors/oracle-vortex-manipulation.js +473 -0
- package/dist/detectors/overpriced-asset-in-oracle.d.ts +41 -0
- package/dist/detectors/overpriced-asset-in-oracle.js +420 -0
- package/dist/detectors/oz-access-control-roles.d.ts +33 -0
- package/dist/detectors/oz-access-control-roles.js +359 -0
- package/dist/detectors/pair-manipulation-transfer-hook.d.ts +38 -0
- package/dist/detectors/pair-manipulation-transfer-hook.js +366 -0
- package/dist/detectors/parameter-access-control.d.ts +47 -0
- package/dist/detectors/parameter-access-control.js +511 -0
- package/dist/detectors/parameter-manipulation.d.ts +7 -0
- package/dist/detectors/parameter-manipulation.js +505 -0
- package/dist/detectors/parity-multisig-delegatecall.d.ts +7 -0
- package/dist/detectors/parity-multisig-delegatecall.js +707 -0
- package/dist/detectors/permissionless-claim-amm-spot-pricing.d.ts +7 -0
- package/dist/detectors/permissionless-claim-amm-spot-pricing.js +351 -0
- package/dist/detectors/permit-future-dated-deadline.d.ts +31 -0
- package/dist/detectors/permit-future-dated-deadline.js +339 -0
- package/dist/detectors/phishing-attack-bybit.d.ts +37 -0
- package/dist/detectors/phishing-attack-bybit.js +513 -0
- package/dist/detectors/post-insolvency-check.d.ts +7 -0
- package/dist/detectors/post-insolvency-check.js +277 -0
- package/dist/detectors/precision-loss-vulnerability.d.ts +7 -0
- package/dist/detectors/precision-loss-vulnerability.js +472 -0
- package/dist/detectors/precision-truncation.d.ts +8 -0
- package/dist/detectors/precision-truncation.js +425 -0
- package/dist/detectors/price-dependency-veth.d.ts +41 -0
- package/dist/detectors/price-dependency-veth.js +588 -0
- package/dist/detectors/price-feed-verification.d.ts +7 -0
- package/dist/detectors/price-feed-verification.js +557 -0
- package/dist/detectors/price-manipulation-reentrancy.d.ts +32 -0
- package/dist/detectors/price-manipulation-reentrancy.js +445 -0
- package/dist/detectors/price-manipulation-via-reentranc.d.ts +7 -0
- package/dist/detectors/price-manipulation-via-reentranc.js +569 -0
- package/dist/detectors/price-oracle-manipulation.d.ts +25 -0
- package/dist/detectors/price-oracle-manipulation.js +530 -0
- package/dist/detectors/project-instant-rewards-unlocked.d.ts +6 -0
- package/dist/detectors/project-instant-rewards-unlocked.js +462 -0
- package/dist/detectors/protocol-reentrancy.d.ts +7 -0
- package/dist/detectors/protocol-reentrancy.js +457 -0
- package/dist/detectors/proxy-init-race.d.ts +11 -0
- package/dist/detectors/proxy-init-race.js +634 -0
- package/dist/detectors/proxy-storage-slot-collision.d.ts +7 -0
- package/dist/detectors/proxy-storage-slot-collision.js +135 -0
- package/dist/detectors/public-internal-function.d.ts +39 -0
- package/dist/detectors/public-internal-function.js +233 -0
- package/dist/detectors/quote-silent-zero.d.ts +25 -0
- package/dist/detectors/quote-silent-zero.js +156 -0
- package/dist/detectors/readonly-reentrancy.d.ts +9 -0
- package/dist/detectors/readonly-reentrancy.js +108 -0
- package/dist/detectors/receipt-redemption-missing-validation.d.ts +31 -0
- package/dist/detectors/receipt-redemption-missing-validation.js +453 -0
- package/dist/detectors/reentrancy-balance.d.ts +36 -0
- package/dist/detectors/reentrancy-balance.js +577 -0
- package/dist/detectors/reentrancy-business-logic-game.d.ts +36 -0
- package/dist/detectors/reentrancy-business-logic-game.js +616 -0
- package/dist/detectors/reentrancy-on-sell-nft.d.ts +23 -0
- package/dist/detectors/reentrancy-on-sell-nft.js +510 -0
- package/dist/detectors/reflection-token-balance-desync.d.ts +28 -0
- package/dist/detectors/reflection-token-balance-desync.js +246 -0
- package/dist/detectors/registry-engine.d.ts +34 -0
- package/dist/detectors/registry-engine.js +388 -0
- package/dist/detectors/rollup-unvalidated-state-update.d.ts +35 -0
- package/dist/detectors/rollup-unvalidated-state-update.js +286 -0
- package/dist/detectors/s-horizon-bridge-private-key-compromis.d.ts +8 -0
- package/dist/detectors/s-horizon-bridge-private-key-compromis.js +615 -0
- package/dist/detectors/share-price-manipulation.d.ts +7 -0
- package/dist/detectors/share-price-manipulation.js +653 -0
- package/dist/detectors/signature-replay.d.ts +30 -0
- package/dist/detectors/signature-replay.js +367 -0
- package/dist/detectors/simpleswap-unverified-approval.d.ts +27 -0
- package/dist/detectors/simpleswap-unverified-approval.js +198 -0
- package/dist/detectors/single-spot-oracle-collateral-valuation.d.ts +22 -0
- package/dist/detectors/single-spot-oracle-collateral-valuation.js +419 -0
- package/dist/detectors/skim-token-balance.d.ts +7 -0
- package/dist/detectors/skim-token-balance.js +788 -0
- package/dist/detectors/sky-oft-governance-payload.d.ts +7 -0
- package/dist/detectors/sky-oft-governance-payload.js +515 -0
- package/dist/detectors/sky-oft-governance-truncation.d.ts +32 -0
- package/dist/detectors/sky-oft-governance-truncation.js +377 -0
- package/dist/detectors/solana-evm-bridge-truncation.d.ts +7 -0
- package/dist/detectors/solana-evm-bridge-truncation.js +638 -0
- package/dist/detectors/solhint-unchecked-low-level-call.d.ts +74 -0
- package/dist/detectors/solhint-unchecked-low-level-call.js +463 -0
- package/dist/detectors/stablecoin-pair-spot-oracle.d.ts +7 -0
- package/dist/detectors/stablecoin-pair-spot-oracle.js +364 -0
- package/dist/detectors/staked-rate-as-oracle.d.ts +44 -0
- package/dist/detectors/staked-rate-as-oracle.js +497 -0
- package/dist/detectors/stale-oracle.d.ts +63 -0
- package/dist/detectors/stale-oracle.js +649 -0
- package/dist/detectors/starkware-proof-validation-gap.d.ts +18 -0
- package/dist/detectors/starkware-proof-validation-gap.js +629 -0
- package/dist/detectors/steth-transfer-reentrancy.d.ts +8 -0
- package/dist/detectors/steth-transfer-reentrancy.js +317 -0
- package/dist/detectors/storage-collision-malicious-proposal.d.ts +27 -0
- package/dist/detectors/storage-collision-malicious-proposal.js +386 -0
- package/dist/detectors/timestamp-manipulation.d.ts +49 -0
- package/dist/detectors/timestamp-manipulation.js +383 -0
- package/dist/detectors/token-access-control.d.ts +7 -0
- package/dist/detectors/token-access-control.js +544 -0
- package/dist/detectors/token-incorrect-signature-verification.d.ts +23 -0
- package/dist/detectors/token-incorrect-signature-verification.js +434 -0
- package/dist/detectors/token-transfer-logic-flaw.d.ts +33 -0
- package/dist/detectors/token-transfer-logic-flaw.js +267 -0
- package/dist/detectors/transfer-double-debit-pool-recipient.d.ts +7 -0
- package/dist/detectors/transfer-double-debit-pool-recipient.js +542 -0
- package/dist/detectors/treasury-reentrancy.d.ts +7 -0
- package/dist/detectors/treasury-reentrancy.js +442 -0
- package/dist/detectors/tstore-poison.d.ts +32 -0
- package/dist/detectors/tstore-poison.js +417 -0
- package/dist/detectors/tstore-race-condition.d.ts +7 -0
- package/dist/detectors/tstore-race-condition.js +632 -0
- package/dist/detectors/types.d.ts +85 -0
- package/dist/detectors/types.js +20 -0
- package/dist/detectors/unauthorized-payer-transferfrom.d.ts +66 -0
- package/dist/detectors/unauthorized-payer-transferfrom.js +339 -0
- package/dist/detectors/unauthorized-transferfrom-shell.d.ts +7 -0
- package/dist/detectors/unauthorized-transferfrom-shell.js +504 -0
- package/dist/detectors/unauthorized-transferfrom.d.ts +16 -0
- package/dist/detectors/unauthorized-transferfrom.js +838 -0
- package/dist/detectors/unbound-zk-verifier-input.d.ts +7 -0
- package/dist/detectors/unbound-zk-verifier-input.js +445 -0
- package/dist/detectors/unbounded-share-price-collateral-oracle.d.ts +48 -0
- package/dist/detectors/unbounded-share-price-collateral-oracle.js +566 -0
- package/dist/detectors/uncapped-reward-emission.d.ts +7 -0
- package/dist/detectors/uncapped-reward-emission.js +493 -0
- package/dist/detectors/unchecked-call-forwarding.d.ts +31 -0
- package/dist/detectors/unchecked-call-forwarding.js +330 -0
- package/dist/detectors/unchecked-external-call-unconditional-state-mutation.d.ts +18 -0
- package/dist/detectors/unchecked-external-call-unconditional-state-mutation.js +311 -0
- package/dist/detectors/unchecked-external-call.d.ts +66 -0
- package/dist/detectors/unchecked-external-call.js +389 -0
- package/dist/detectors/unchecked-oft-return.d.ts +13 -0
- package/dist/detectors/unchecked-oft-return.js +118 -0
- package/dist/detectors/unguarded-governance-execution.d.ts +35 -0
- package/dist/detectors/unguarded-governance-execution.js +422 -0
- package/dist/detectors/unguarded-governance-executor.d.ts +35 -0
- package/dist/detectors/unguarded-governance-executor.js +349 -0
- package/dist/detectors/unindexed-event-address.d.ts +7 -0
- package/dist/detectors/unindexed-event-address.js +268 -0
- package/dist/detectors/uninitialized-implementation.d.ts +27 -0
- package/dist/detectors/uninitialized-implementation.js +333 -0
- package/dist/detectors/uninitialized-storage-pointer.d.ts +7 -0
- package/dist/detectors/uninitialized-storage-pointer.js +110 -0
- package/dist/detectors/uniswap-skim-token-balance-attack.d.ts +8 -0
- package/dist/detectors/uniswap-skim-token-balance-attack.js +331 -0
- package/dist/detectors/uniswap-v4-hook-state-manipulation.d.ts +7 -0
- package/dist/detectors/uniswap-v4-hook-state-manipulation.js +296 -0
- package/dist/detectors/unprotected-admin-or-fund-sink.d.ts +7 -0
- package/dist/detectors/unprotected-admin-or-fund-sink.js +643 -0
- package/dist/detectors/unprotected-dex-swap.d.ts +43 -0
- package/dist/detectors/unprotected-dex-swap.js +334 -0
- package/dist/detectors/unprotected-initializer.d.ts +7 -0
- package/dist/detectors/unprotected-initializer.js +707 -0
- package/dist/detectors/unprotected-pair-initializer.d.ts +22 -0
- package/dist/detectors/unprotected-pair-initializer.js +359 -0
- package/dist/detectors/unprotected-upgrade-function.d.ts +7 -0
- package/dist/detectors/unprotected-upgrade-function.js +180 -0
- package/dist/detectors/unreachable-code-0.8.28.d.ts +19 -0
- package/dist/detectors/unreachable-code-0.8.28.js +206 -0
- package/dist/detectors/unsafe-proxy-storage.d.ts +7 -0
- package/dist/detectors/unsafe-proxy-storage.js +436 -0
- package/dist/detectors/unsafe-transient-storage.d.ts +7 -0
- package/dist/detectors/unsafe-transient-storage.js +1052 -0
- package/dist/detectors/unsafe-tx-origin.d.ts +9 -0
- package/dist/detectors/unsafe-tx-origin.js +179 -0
- package/dist/detectors/unsigned-validity-window.d.ts +20 -0
- package/dist/detectors/unsigned-validity-window.js +220 -0
- package/dist/detectors/unvalidated-interface-address.d.ts +25 -0
- package/dist/detectors/unvalidated-interface-address.js +377 -0
- package/dist/detectors/uups-uninitialized-storage.d.ts +9 -0
- package/dist/detectors/uups-uninitialized-storage.js +366 -0
- package/dist/detectors/v2-error-k-value-attack.d.ts +33 -0
- package/dist/detectors/v2-error-k-value-attack.js +276 -0
- package/dist/detectors/v2-k-invariant-bypass.d.ts +33 -0
- package/dist/detectors/v2-k-invariant-bypass.js +283 -0
- package/dist/detectors/v4-hook-reentrancy.d.ts +9 -0
- package/dist/detectors/v4-hook-reentrancy.js +488 -0
- package/dist/detectors/vault-inflation-rounding.d.ts +23 -0
- package/dist/detectors/vault-inflation-rounding.js +477 -0
- package/dist/detectors/vault-share-price-manipulation.d.ts +7 -0
- package/dist/detectors/vault-share-price-manipulation.js +332 -0
- package/dist/detectors/vortex-interaction-guard.d.ts +45 -0
- package/dist/detectors/vortex-interaction-guard.js +275 -0
- package/dist/detectors/vortex-protocol-reentrancy-guard.d.ts +27 -0
- package/dist/detectors/vortex-protocol-reentrancy-guard.js +408 -0
- package/dist/detectors/vulnerable-price-dependency.d.ts +41 -0
- package/dist/detectors/vulnerable-price-dependency.js +473 -0
- package/dist/detectors/weak-random-mint.d.ts +37 -0
- package/dist/detectors/weak-random-mint.js +271 -0
- package/dist/detectors/withdraw-be-to-withdraw.d.ts +26 -0
- package/dist/detectors/withdraw-be-to-withdraw.js +329 -0
- package/dist/detectors/wrong-function-visibility.d.ts +29 -0
- package/dist/detectors/wrong-function-visibility.js +147 -0
- package/dist/detectors/wrong-price-calculation.d.ts +42 -0
- package/dist/detectors/wrong-price-calculation.js +387 -0
- package/dist/detectors/yearn-vault-v2-share-price-manipulation.d.ts +32 -0
- package/dist/detectors/yearn-vault-v2-share-price-manipulation.js +248 -0
- package/dist/detectors/zero-fee.d.ts +7 -0
- package/dist/detectors/zero-fee.js +596 -0
- package/dist/detectors/zetachain-gateway-hack-analysis.d.ts +7 -0
- package/dist/detectors/zetachain-gateway-hack-analysis.js +629 -0
- package/dist/detectors/zk-rollup-da-gap.d.ts +8 -0
- package/dist/detectors/zk-rollup-da-gap.js +322 -0
- package/dist/detectors/zksync-batch-validation.d.ts +8 -0
- package/dist/detectors/zksync-batch-validation.js +461 -0
- package/dist/detectors/zksync-era-rollup-state-update.d.ts +60 -0
- package/dist/detectors/zksync-era-rollup-state-update.js +360 -0
- package/dist/detectors/zksync-simulation-drift.d.ts +35 -0
- package/dist/detectors/zksync-simulation-drift.js +309 -0
- package/dist/exit-codes.d.ts +15 -0
- package/dist/exit-codes.js +18 -0
- package/dist/formatters/github-actions.d.ts +2 -0
- package/dist/formatters/github-actions.js +61 -0
- package/dist/formatters/sarif.d.ts +24 -0
- package/dist/formatters/sarif.js +670 -0
- package/dist/formatters/text.d.ts +14 -0
- package/dist/formatters/text.js +152 -0
- package/dist/fp-rates.json +70 -0
- package/dist/identity/diff-baseline.d.ts +16 -0
- package/dist/identity/diff-baseline.js +152 -0
- package/dist/identity/hashing.d.ts +39 -0
- package/dist/identity/hashing.js +96 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +358 -0
- package/dist/parallel-scan.d.ts +66 -0
- package/dist/parallel-scan.js +227 -0
- package/dist/registry.d.ts +17 -0
- package/dist/registry.js +118 -0
- package/dist/rules/glob.d.ts +5 -0
- package/dist/rules/glob.js +76 -0
- package/dist/rules/suppressions.d.ts +23 -0
- package/dist/rules/suppressions.js +136 -0
- package/dist/rules/tiers.d.ts +23 -0
- package/dist/rules/tiers.js +341 -0
- package/dist/scan-worker.d.ts +1 -0
- package/dist/scan-worker.js +61 -0
- package/dist/scan.d.ts +24 -0
- package/dist/scan.js +558 -0
- package/dist/semantic/contracts.d.ts +10 -0
- package/dist/semantic/contracts.js +141 -0
- package/dist/semantic/diagnostics.d.ts +29 -0
- package/dist/semantic/diagnostics.js +25 -0
- package/dist/semantic/eog.d.ts +56 -0
- package/dist/semantic/eog.js +545 -0
- package/dist/semantic/imports.d.ts +88 -0
- package/dist/semantic/imports.js +246 -0
- package/dist/semantic/index.d.ts +2 -0
- package/dist/semantic/index.js +8 -0
- package/dist/semantic/inheritance.d.ts +33 -0
- package/dist/semantic/inheritance.js +137 -0
- package/dist/semantic/model.d.ts +95 -0
- package/dist/semantic/model.js +232 -0
- package/dist/semantic/taint-tracker.d.ts +49 -0
- package/dist/semantic/taint-tracker.js +410 -0
- package/dist/semantic/types.d.ts +119 -0
- package/dist/semantic/types.js +18 -0
- package/dist/severity.d.ts +10 -0
- package/dist/severity.js +78 -0
- package/package.json +52 -0
|
@@ -0,0 +1,1151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DontLetEthGetRektDetector = void 0;
|
|
4
|
+
const ast_1 = require("./_common/ast");
|
|
5
|
+
const RULE_ID = 'dont-let-eth-get-rekt';
|
|
6
|
+
const ALWAYS_ETH_OUT_MEMBERS = new Set(['transfer', 'send']);
|
|
7
|
+
const SPOT_PRICE_SOURCE_MEMBERS = new Set([
|
|
8
|
+
'getReserves',
|
|
9
|
+
'slot0',
|
|
10
|
+
'latestAnswer',
|
|
11
|
+
'latestRoundData',
|
|
12
|
+
'getAmountsOut',
|
|
13
|
+
]);
|
|
14
|
+
const TWAP_SOURCE_MEMBERS = new Set([
|
|
15
|
+
'consult',
|
|
16
|
+
'observe',
|
|
17
|
+
'getTwap',
|
|
18
|
+
'getTWAP',
|
|
19
|
+
'twap',
|
|
20
|
+
'getAveragePrice',
|
|
21
|
+
]);
|
|
22
|
+
class DontLetEthGetRektDetector {
|
|
23
|
+
id = RULE_ID;
|
|
24
|
+
patternKey = RULE_ID;
|
|
25
|
+
supportedAstKinds = ['parser'];
|
|
26
|
+
descriptor = {
|
|
27
|
+
id: RULE_ID,
|
|
28
|
+
shortDescription: 'ETH payout amount is derived from manipulable balance or spot-price state.',
|
|
29
|
+
helpUri: 'https://snovon.com/',
|
|
30
|
+
defaultSeverity: 'high',
|
|
31
|
+
help: 'Flags ETH payouts or accounting paths that derive value from address(this).balance or a single-source spot price such as getReserves(), slot0(), latestAnswer(), or getAmountsOut() without an independent anchor.',
|
|
32
|
+
};
|
|
33
|
+
currentFile = '';
|
|
34
|
+
findings = [];
|
|
35
|
+
contractStack = [];
|
|
36
|
+
setFile(file) {
|
|
37
|
+
this.currentFile = file;
|
|
38
|
+
this.findings = [];
|
|
39
|
+
this.contractStack = [];
|
|
40
|
+
}
|
|
41
|
+
getFindings() {
|
|
42
|
+
return this.findings;
|
|
43
|
+
}
|
|
44
|
+
ContractDefinition(node) {
|
|
45
|
+
const kind = String(node?.kind || '').toLowerCase();
|
|
46
|
+
this.contractStack.push({
|
|
47
|
+
name: node?.name || '<anonymous>',
|
|
48
|
+
node,
|
|
49
|
+
executable: kind !== 'interface' && kind !== 'library',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
FunctionDefinition(node) {
|
|
53
|
+
const contract = this.currentContract();
|
|
54
|
+
if (!contract?.executable || !node?.body || this.isViewOrPure(node))
|
|
55
|
+
return;
|
|
56
|
+
const finding = this.findSpotPriceEthPayout(node, contract.name);
|
|
57
|
+
if (finding)
|
|
58
|
+
this.findings.push(finding);
|
|
59
|
+
}
|
|
60
|
+
['ContractDefinition:exit'](node) {
|
|
61
|
+
const contract = this.contractStack[this.contractStack.length - 1];
|
|
62
|
+
if (contract?.node === node && contract.executable) {
|
|
63
|
+
const result = this.analyzeContract(node, contract.name);
|
|
64
|
+
if (result)
|
|
65
|
+
this.findings.push({ ...result, file: this.currentFile });
|
|
66
|
+
}
|
|
67
|
+
this.contractStack.pop();
|
|
68
|
+
}
|
|
69
|
+
ContractDefinition_post(node) {
|
|
70
|
+
this['ContractDefinition:exit'](node);
|
|
71
|
+
}
|
|
72
|
+
currentContract() {
|
|
73
|
+
return this.contractStack[this.contractStack.length - 1] || null;
|
|
74
|
+
}
|
|
75
|
+
findSpotPriceEthPayout(fn, contractName) {
|
|
76
|
+
const taint = this.buildPerFunctionSpotPriceTaint(fn);
|
|
77
|
+
if (taint.size === 0 && !this.functionContainsUnsafeSpotSource(fn))
|
|
78
|
+
return null;
|
|
79
|
+
if (this.hasSafeLatestRoundDataValidation(fn.body || fn))
|
|
80
|
+
return null;
|
|
81
|
+
const sink = this.findSpotTaintedEthSink(fn.body || fn, taint);
|
|
82
|
+
if (!sink)
|
|
83
|
+
return null;
|
|
84
|
+
// Taint-linked safety check: a TWAP/oracle call plus any generic require(...)
|
|
85
|
+
// must never suppress on its own (see PR #3437 review consensus). The
|
|
86
|
+
// payout is allowed to use spot-derived values only when a dominating
|
|
87
|
+
// guard bounds the spot taint against an independently-derived reference
|
|
88
|
+
// taint via a real bounded comparator (<, <=, >, >=).
|
|
89
|
+
const referenceTaint = this.buildPerFunctionReferenceTaint(fn);
|
|
90
|
+
if (referenceTaint.size > 0 &&
|
|
91
|
+
this.guardBindsSpotToReference(fn, sink.node, taint, referenceTaint)) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
const loc = (0, ast_1.assertLoc)(sink.node, fn);
|
|
95
|
+
const fnName = fn.name || '<anonymous>';
|
|
96
|
+
return {
|
|
97
|
+
file: this.currentFile,
|
|
98
|
+
contract: contractName,
|
|
99
|
+
'function': fnName,
|
|
100
|
+
line: loc.line,
|
|
101
|
+
endLine: loc.endLine,
|
|
102
|
+
column: loc.column,
|
|
103
|
+
endColumn: loc.endColumn,
|
|
104
|
+
ruleId: RULE_ID,
|
|
105
|
+
pattern: `${RULE_ID}/spot-price-eth-payout`,
|
|
106
|
+
severity: 'high',
|
|
107
|
+
confidence: 'high',
|
|
108
|
+
category: 'oracle-manipulation',
|
|
109
|
+
message: `ETH payout in '${contractName}.${fnName}' is derived from a single-source spot price without an independent freshness, TWAP, or bounds check.`,
|
|
110
|
+
rationale: 'Same-block reserve, slot0, raw aggregator, or router quote values can be manipulated before they determine an ETH transfer amount.',
|
|
111
|
+
suggestedFix: 'Use a TWAP or independent oracle and bound the spot value against that reference before using it in ETH settlement.',
|
|
112
|
+
contractName,
|
|
113
|
+
functionName: fnName,
|
|
114
|
+
sourceLocation: { line: loc.line, column: loc.column },
|
|
115
|
+
findingId: '',
|
|
116
|
+
contractHash: '',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
buildPerFunctionSpotPriceTaint(fn) {
|
|
120
|
+
const localVariables = this.collectLocalVariableNames(fn.body || fn);
|
|
121
|
+
const taint = new Set();
|
|
122
|
+
const steps = this.collectLocalTaintSteps(fn.body || fn, localVariables);
|
|
123
|
+
let changed = true;
|
|
124
|
+
while (changed) {
|
|
125
|
+
changed = false;
|
|
126
|
+
for (const step of steps) {
|
|
127
|
+
if (taint.has(step.name))
|
|
128
|
+
continue;
|
|
129
|
+
if (this.expressionDependsOnSpotPrice(step.value, taint)) {
|
|
130
|
+
taint.add(step.name);
|
|
131
|
+
changed = true;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return taint;
|
|
136
|
+
}
|
|
137
|
+
functionContainsUnsafeSpotSource(fn) {
|
|
138
|
+
let found = false;
|
|
139
|
+
this.walk(fn.body || fn, (node) => {
|
|
140
|
+
if (found)
|
|
141
|
+
return;
|
|
142
|
+
if (this.isUnsafeSpotPriceSourceCall(node))
|
|
143
|
+
found = true;
|
|
144
|
+
});
|
|
145
|
+
return found;
|
|
146
|
+
}
|
|
147
|
+
findSpotTaintedEthSink(node, taint) {
|
|
148
|
+
if (!node || typeof node !== 'object')
|
|
149
|
+
return null;
|
|
150
|
+
const value = this.ethPayoutValueExpression(node);
|
|
151
|
+
if (value && this.expressionDependsOnSpotPrice(value, taint)) {
|
|
152
|
+
return { node };
|
|
153
|
+
}
|
|
154
|
+
for (const key of childKeys(node)) {
|
|
155
|
+
const child = node[key];
|
|
156
|
+
if (Array.isArray(child)) {
|
|
157
|
+
for (const item of child) {
|
|
158
|
+
const found = this.findSpotTaintedEthSink(item, taint);
|
|
159
|
+
if (found)
|
|
160
|
+
return found;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (child && typeof child === 'object') {
|
|
164
|
+
const found = this.findSpotTaintedEthSink(child, taint);
|
|
165
|
+
if (found)
|
|
166
|
+
return found;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
ethPayoutValueExpression(node) {
|
|
172
|
+
if (!node || node.type !== 'FunctionCall')
|
|
173
|
+
return null;
|
|
174
|
+
const callee = node.expression;
|
|
175
|
+
if (callee?.type === 'MemberAccess') {
|
|
176
|
+
const member = String(callee.memberName || '').toLowerCase();
|
|
177
|
+
if (ALWAYS_ETH_OUT_MEMBERS.has(member) && this.isLikelyEthReceiver(callee.expression)) {
|
|
178
|
+
return node.arguments?.[0] || null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (callee?.type === 'NameValueExpression' || callee?.type === 'FunctionCallOptions') {
|
|
182
|
+
const inner = callee.expression;
|
|
183
|
+
if (inner?.type === 'MemberAccess' && String(inner.memberName || '').toLowerCase() === 'call') {
|
|
184
|
+
return this.nameValueOptionExpression(callee, 'value');
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
isLikelyEthReceiver(expr) {
|
|
190
|
+
if (!expr || typeof expr !== 'object')
|
|
191
|
+
return false;
|
|
192
|
+
if (expr.type === 'MemberAccess') {
|
|
193
|
+
return expr.expression?.type === 'Identifier' && ['msg', 'tx'].includes(expr.expression.name);
|
|
194
|
+
}
|
|
195
|
+
if (expr.type === 'FunctionCall') {
|
|
196
|
+
const callee = expr.expression;
|
|
197
|
+
if (callee?.type === 'Identifier' && (callee.name === 'payable' || callee.name === 'address'))
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
nameValueOptionExpression(nve, optionName) {
|
|
203
|
+
const args = nve?.arguments;
|
|
204
|
+
if (args?.type === 'NameValueList') {
|
|
205
|
+
const names = args.names || [];
|
|
206
|
+
const values = args.arguments || [];
|
|
207
|
+
const index = names.indexOf(optionName);
|
|
208
|
+
return index >= 0 ? values[index] || null : null;
|
|
209
|
+
}
|
|
210
|
+
for (const option of nve?.options || []) {
|
|
211
|
+
if (option?.name === optionName)
|
|
212
|
+
return option.value || null;
|
|
213
|
+
}
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
expressionDependsOnSpotPrice(node, taint) {
|
|
217
|
+
if (!node || typeof node !== 'object')
|
|
218
|
+
return false;
|
|
219
|
+
if (node.type === 'Identifier' && taint.has(node.name))
|
|
220
|
+
return true;
|
|
221
|
+
if (this.isUnsafeSpotPriceSourceCall(node))
|
|
222
|
+
return true;
|
|
223
|
+
for (const key of childKeys(node)) {
|
|
224
|
+
const child = node[key];
|
|
225
|
+
if (Array.isArray(child)) {
|
|
226
|
+
for (const item of child) {
|
|
227
|
+
if (this.expressionDependsOnSpotPrice(item, taint))
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else if (child && typeof child === 'object') {
|
|
232
|
+
if (this.expressionDependsOnSpotPrice(child, taint))
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
isUnsafeSpotPriceSourceCall(node) {
|
|
239
|
+
if (!node || node.type !== 'FunctionCall')
|
|
240
|
+
return false;
|
|
241
|
+
const calleeName = this.getCalleeMemberName(node.expression);
|
|
242
|
+
return SPOT_PRICE_SOURCE_MEMBERS.has(calleeName);
|
|
243
|
+
}
|
|
244
|
+
getCalleeMemberName(expr) {
|
|
245
|
+
if (!expr || typeof expr !== 'object')
|
|
246
|
+
return '';
|
|
247
|
+
if (expr.type === 'Identifier')
|
|
248
|
+
return expr.name || '';
|
|
249
|
+
if (expr.type === 'MemberAccess')
|
|
250
|
+
return expr.memberName || '';
|
|
251
|
+
if (expr.type === 'NameValueExpression' || expr.type === 'FunctionCallOptions')
|
|
252
|
+
return this.getCalleeMemberName(expr.expression);
|
|
253
|
+
return '';
|
|
254
|
+
}
|
|
255
|
+
buildPerFunctionReferenceTaint(fn) {
|
|
256
|
+
const localVariables = this.collectLocalVariableNames(fn.body || fn);
|
|
257
|
+
const taint = new Set();
|
|
258
|
+
const steps = this.collectLocalTaintSteps(fn.body || fn, localVariables);
|
|
259
|
+
let changed = true;
|
|
260
|
+
while (changed) {
|
|
261
|
+
changed = false;
|
|
262
|
+
for (const step of steps) {
|
|
263
|
+
if (taint.has(step.name))
|
|
264
|
+
continue;
|
|
265
|
+
if (this.expressionDependsOnReferencePrice(step.value, taint)) {
|
|
266
|
+
taint.add(step.name);
|
|
267
|
+
changed = true;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return taint;
|
|
272
|
+
}
|
|
273
|
+
expressionDependsOnReferencePrice(node, taint) {
|
|
274
|
+
if (!node || typeof node !== 'object')
|
|
275
|
+
return false;
|
|
276
|
+
if (node.type === 'Identifier' && taint.has(node.name))
|
|
277
|
+
return true;
|
|
278
|
+
if (this.isReferencePriceSourceCall(node))
|
|
279
|
+
return true;
|
|
280
|
+
for (const key of childKeys(node)) {
|
|
281
|
+
const child = node[key];
|
|
282
|
+
if (Array.isArray(child)) {
|
|
283
|
+
for (const item of child) {
|
|
284
|
+
if (this.expressionDependsOnReferencePrice(item, taint))
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
else if (child && typeof child === 'object') {
|
|
289
|
+
if (this.expressionDependsOnReferencePrice(child, taint))
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
isReferencePriceSourceCall(node) {
|
|
296
|
+
if (!node || node.type !== 'FunctionCall')
|
|
297
|
+
return false;
|
|
298
|
+
const calleeName = this.getCalleeMemberName(node.expression);
|
|
299
|
+
return TWAP_SOURCE_MEMBERS.has(calleeName);
|
|
300
|
+
}
|
|
301
|
+
// Suppress only when a require/assert/if-revert guard textually precedes the
|
|
302
|
+
// payout sink in the same function and explicitly binds a spot-derived value
|
|
303
|
+
// to a reference-derived value via a bounded comparison (e.g. `spot <= avg *
|
|
304
|
+
// 105 / 100`, `abs(spot - avg) < threshold`). Trivial guards like
|
|
305
|
+
// `require(avg > 0)` — which only mention a reference identifier without
|
|
306
|
+
// bounding spot against it — must not suppress, since they leave the spot
|
|
307
|
+
// value free to be manipulated before driving the ETH payout.
|
|
308
|
+
guardBindsSpotToReference(fn, sinkNode, spotTaint, referenceTaint) {
|
|
309
|
+
if (spotTaint.size === 0 || referenceTaint.size === 0)
|
|
310
|
+
return false;
|
|
311
|
+
const sinkStart = this.getRangeStart(sinkNode);
|
|
312
|
+
if (sinkStart < 0)
|
|
313
|
+
return false;
|
|
314
|
+
let bound = false;
|
|
315
|
+
this.walk(fn.body || fn, (current) => {
|
|
316
|
+
if (bound)
|
|
317
|
+
return;
|
|
318
|
+
const condition = this.getGuardCondition(current);
|
|
319
|
+
if (!condition)
|
|
320
|
+
return;
|
|
321
|
+
const guardStart = this.getRangeStart(current);
|
|
322
|
+
if (guardStart < 0 || guardStart >= sinkStart)
|
|
323
|
+
return;
|
|
324
|
+
if (this.conditionBindsSpotToReference(condition, spotTaint, referenceTaint)) {
|
|
325
|
+
bound = true;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
return bound;
|
|
329
|
+
}
|
|
330
|
+
getGuardCondition(node) {
|
|
331
|
+
if (node?.type === 'FunctionCall') {
|
|
332
|
+
const name = this.getCalleeMemberName(node.expression);
|
|
333
|
+
if ((name === 'require' || name === 'assert') && node.arguments?.[0]) {
|
|
334
|
+
return node.arguments[0];
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (node?.type === 'IfStatement' && node.condition && this.bodyContainsRevert(node.trueBody)) {
|
|
338
|
+
return node.condition;
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
bodyContainsRevert(node) {
|
|
343
|
+
if (!node || typeof node !== 'object')
|
|
344
|
+
return false;
|
|
345
|
+
if (node.type === 'RevertStatement')
|
|
346
|
+
return true;
|
|
347
|
+
if (node.type === 'FunctionCall') {
|
|
348
|
+
const name = this.getCalleeMemberName(node.expression);
|
|
349
|
+
if (name === 'revert')
|
|
350
|
+
return true;
|
|
351
|
+
}
|
|
352
|
+
for (const key of childKeys(node)) {
|
|
353
|
+
const child = node[key];
|
|
354
|
+
if (Array.isArray(child)) {
|
|
355
|
+
for (const item of child)
|
|
356
|
+
if (this.bodyContainsRevert(item))
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
else if (child && typeof child === 'object') {
|
|
360
|
+
if (this.bodyContainsRevert(child))
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
conditionBindsSpotToReference(condition, spotTaint, referenceTaint) {
|
|
367
|
+
let bound = false;
|
|
368
|
+
this.walk(condition, (current) => {
|
|
369
|
+
if (bound)
|
|
370
|
+
return;
|
|
371
|
+
if (current?.type !== 'BinaryOperation')
|
|
372
|
+
return;
|
|
373
|
+
if (!['<', '<=', '>', '>='].includes(current.operator))
|
|
374
|
+
return;
|
|
375
|
+
const left = current.left;
|
|
376
|
+
const right = current.right;
|
|
377
|
+
const touchesSpot = this.expressionTouchesTaint(left, spotTaint) ||
|
|
378
|
+
this.expressionTouchesTaint(right, spotTaint);
|
|
379
|
+
const touchesRef = this.expressionTouchesTaint(left, referenceTaint) ||
|
|
380
|
+
this.expressionTouchesTaint(right, referenceTaint);
|
|
381
|
+
if (touchesSpot && touchesRef)
|
|
382
|
+
bound = true;
|
|
383
|
+
});
|
|
384
|
+
return bound;
|
|
385
|
+
}
|
|
386
|
+
expressionTouchesTaint(node, taint) {
|
|
387
|
+
if (!node || typeof node !== 'object')
|
|
388
|
+
return false;
|
|
389
|
+
if (node.type === 'Identifier' && taint.has(node.name))
|
|
390
|
+
return true;
|
|
391
|
+
for (const key of childKeys(node)) {
|
|
392
|
+
const child = node[key];
|
|
393
|
+
if (Array.isArray(child)) {
|
|
394
|
+
for (const item of child) {
|
|
395
|
+
if (this.expressionTouchesTaint(item, taint))
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
else if (child && typeof child === 'object') {
|
|
400
|
+
if (this.expressionTouchesTaint(child, taint))
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
getRangeStart(node) {
|
|
407
|
+
if (Array.isArray(node?.range) && node.range.length >= 1) {
|
|
408
|
+
const start = Number(node.range[0]);
|
|
409
|
+
if (Number.isFinite(start))
|
|
410
|
+
return start;
|
|
411
|
+
}
|
|
412
|
+
const line = node?.loc?.start?.line;
|
|
413
|
+
const column = node?.loc?.start?.column;
|
|
414
|
+
if (typeof line === 'number' && line > 0) {
|
|
415
|
+
return line * 1_000_000 + (typeof column === 'number' ? column : 0);
|
|
416
|
+
}
|
|
417
|
+
return -1;
|
|
418
|
+
}
|
|
419
|
+
hasSafeLatestRoundDataValidation(node) {
|
|
420
|
+
let hasLatestRoundData = false;
|
|
421
|
+
let hasFreshness = false;
|
|
422
|
+
let hasRoundCompleteness = false;
|
|
423
|
+
let hasBounds = false;
|
|
424
|
+
this.walk(node, (current) => {
|
|
425
|
+
if (current?.type !== 'FunctionCall')
|
|
426
|
+
return;
|
|
427
|
+
const name = this.getCalleeMemberName(current.expression);
|
|
428
|
+
if (name === 'latestRoundData')
|
|
429
|
+
hasLatestRoundData = true;
|
|
430
|
+
if (name !== 'require' || !current.arguments?.[0])
|
|
431
|
+
return;
|
|
432
|
+
const condition = current.arguments[0];
|
|
433
|
+
if (this.expressionMentionsAny(condition, ['updatedAt']) && this.expressionMentionsAny(condition, ['timestamp', 'block'])) {
|
|
434
|
+
hasFreshness = true;
|
|
435
|
+
}
|
|
436
|
+
if (this.expressionMentionsAny(condition, ['answeredInRound']) && this.expressionMentionsAny(condition, ['roundId'])) {
|
|
437
|
+
hasRoundCompleteness = true;
|
|
438
|
+
}
|
|
439
|
+
if (this.expressionMentionsAny(condition, ['price', 'answer']) && this.expressionHasNumericLiteral(condition)) {
|
|
440
|
+
hasBounds = true;
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
return hasLatestRoundData && hasFreshness && hasRoundCompleteness && hasBounds;
|
|
444
|
+
}
|
|
445
|
+
expressionMentionsAny(node, needles) {
|
|
446
|
+
let found = false;
|
|
447
|
+
this.walk(node, (current) => {
|
|
448
|
+
if (found || !current || typeof current !== 'object')
|
|
449
|
+
return;
|
|
450
|
+
if (current.type === 'Identifier' && needles.includes(current.name))
|
|
451
|
+
found = true;
|
|
452
|
+
if (current.type === 'MemberAccess' && needles.includes(current.memberName))
|
|
453
|
+
found = true;
|
|
454
|
+
});
|
|
455
|
+
return found;
|
|
456
|
+
}
|
|
457
|
+
expressionHasNumericLiteral(node) {
|
|
458
|
+
let found = false;
|
|
459
|
+
this.walk(node, (current) => {
|
|
460
|
+
if (found || !current || typeof current !== 'object')
|
|
461
|
+
return;
|
|
462
|
+
if (current.type === 'NumberLiteral')
|
|
463
|
+
found = true;
|
|
464
|
+
});
|
|
465
|
+
return found;
|
|
466
|
+
}
|
|
467
|
+
walk(node, cb) {
|
|
468
|
+
if (!node || typeof node !== 'object')
|
|
469
|
+
return;
|
|
470
|
+
cb(node);
|
|
471
|
+
for (const key of childKeys(node)) {
|
|
472
|
+
const child = node[key];
|
|
473
|
+
if (Array.isArray(child)) {
|
|
474
|
+
for (const item of child)
|
|
475
|
+
this.walk(item, cb);
|
|
476
|
+
}
|
|
477
|
+
else if (child && typeof child === 'object') {
|
|
478
|
+
this.walk(child, cb);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
analyzeContract(contract, contractName) {
|
|
483
|
+
const hasEthIn = this.contractHasEthInSurface(contract);
|
|
484
|
+
if (!hasEthIn)
|
|
485
|
+
return null;
|
|
486
|
+
// Direct payout path is independent of whether the enclosing function performs
|
|
487
|
+
// state mutation: a `claim()` whose only statement is `transfer(address(this).balance)`
|
|
488
|
+
// still drains the contract on a manipulated balance.
|
|
489
|
+
const directPayoutInfo = this.balanceDrivesDirectPayoutWithLoc(contract);
|
|
490
|
+
if (directPayoutInfo) {
|
|
491
|
+
return {
|
|
492
|
+
contract: contractName,
|
|
493
|
+
line: directPayoutInfo.line,
|
|
494
|
+
column: directPayoutInfo.column,
|
|
495
|
+
'function': directPayoutInfo.functionName,
|
|
496
|
+
ruleId: RULE_ID,
|
|
497
|
+
severity: 'high',
|
|
498
|
+
confidence: 'high',
|
|
499
|
+
message: `Contract '${contractName}' receives ETH and derives a payout or accounting amount directly from address(this).balance with no independent accounting anchor. An attacker can manipulate the balance via forced ETH to drain funds.`,
|
|
500
|
+
contractName,
|
|
501
|
+
functionName: directPayoutInfo.functionName,
|
|
502
|
+
findingId: '',
|
|
503
|
+
contractHash: '',
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
const balanceReadInfo = this.contractHasBalanceReadWithLoc(contract);
|
|
507
|
+
if (!balanceReadInfo)
|
|
508
|
+
return null;
|
|
509
|
+
const hasEthOut = this.contractHasEthOutCall(contract);
|
|
510
|
+
const severity = this.balanceReadDrivesAccountingRate(contract) ? 'high' : 'medium';
|
|
511
|
+
if (!hasEthOut) {
|
|
512
|
+
return {
|
|
513
|
+
contract: contractName,
|
|
514
|
+
line: balanceReadInfo.line,
|
|
515
|
+
column: balanceReadInfo.column,
|
|
516
|
+
'function': balanceReadInfo.functionName,
|
|
517
|
+
ruleId: RULE_ID,
|
|
518
|
+
severity,
|
|
519
|
+
confidence: 'high',
|
|
520
|
+
message: `Contract '${contractName}' receives ETH and reads address(this).balance in non-view state-changing logic, but has no ETH-out path (no call{value:}, transfer, send, or selfdestruct found in the contract body). Forced ETH accumulation can manipulate the balance-driven accounting.`,
|
|
521
|
+
contractName,
|
|
522
|
+
functionName: balanceReadInfo.functionName,
|
|
523
|
+
findingId: '',
|
|
524
|
+
contractHash: '',
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
contractHasEthInSurface(contract) {
|
|
530
|
+
for (const sub of contract.subNodes || []) {
|
|
531
|
+
if (sub?.type === 'FunctionDefinition') {
|
|
532
|
+
if (this.isPayableFunction(sub))
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
isPayableFunction(fn) {
|
|
539
|
+
const mutability = String(fn.stateMutability || '').toLowerCase();
|
|
540
|
+
if (mutability === 'payable')
|
|
541
|
+
return true;
|
|
542
|
+
const kind = (fn.kind || fn.functionKind || '').toLowerCase();
|
|
543
|
+
if (kind === 'fallback' || kind === 'receive')
|
|
544
|
+
return true;
|
|
545
|
+
return false;
|
|
546
|
+
}
|
|
547
|
+
contractHasBalanceReadWithLoc(contract) {
|
|
548
|
+
let result = null;
|
|
549
|
+
for (const sub of contract.subNodes || []) {
|
|
550
|
+
if (sub?.type !== 'FunctionDefinition')
|
|
551
|
+
continue;
|
|
552
|
+
const fn = sub;
|
|
553
|
+
if (this.isViewOrPure(fn))
|
|
554
|
+
continue;
|
|
555
|
+
if (!this.functionHasStateMutation(fn))
|
|
556
|
+
continue;
|
|
557
|
+
this.walkForBalanceRead(fn.body || fn, (node) => {
|
|
558
|
+
if (!result) {
|
|
559
|
+
const { line, column } = (0, ast_1.assertLoc)(node);
|
|
560
|
+
result = { line, column, functionName: fn.name || '<anonymous>' };
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
if (result)
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
return result;
|
|
567
|
+
}
|
|
568
|
+
walkForBalanceRead(node, cb) {
|
|
569
|
+
if (!node || typeof node !== 'object')
|
|
570
|
+
return;
|
|
571
|
+
if (node.type === 'MemberAccess' && node.memberName === 'balance') {
|
|
572
|
+
if (this.isThisBalanceRead(node)) {
|
|
573
|
+
cb(node);
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
for (const key of childKeys(node)) {
|
|
578
|
+
const value = node[key];
|
|
579
|
+
if (Array.isArray(value)) {
|
|
580
|
+
for (const item of value) {
|
|
581
|
+
if (item && typeof item === 'object')
|
|
582
|
+
this.walkForBalanceRead(item, cb);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
else if (value && typeof value === 'object') {
|
|
586
|
+
this.walkForBalanceRead(value, cb);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
isThisBalanceRead(node) {
|
|
591
|
+
if (node.type !== 'MemberAccess')
|
|
592
|
+
return false;
|
|
593
|
+
if (node.memberName !== 'balance')
|
|
594
|
+
return false;
|
|
595
|
+
const expr = node.expression;
|
|
596
|
+
if (expr?.type === 'FunctionCall') {
|
|
597
|
+
const callee = expr.expression;
|
|
598
|
+
if (callee?.type === 'Identifier' && callee.name === 'address' && expr.arguments?.length === 1) {
|
|
599
|
+
const arg = expr.arguments[0];
|
|
600
|
+
if (arg?.type === 'Identifier' && arg.name === 'this')
|
|
601
|
+
return true;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (expr?.type === 'MemberAccess') {
|
|
605
|
+
if (expr.expression?.type === 'Identifier' && expr.expression.name === 'this')
|
|
606
|
+
return true;
|
|
607
|
+
}
|
|
608
|
+
return false;
|
|
609
|
+
}
|
|
610
|
+
contractHasEthOutCall(contract) {
|
|
611
|
+
const contractReceivers = this.collectContractAddressReceivers(contract);
|
|
612
|
+
for (const sub of contract.subNodes || []) {
|
|
613
|
+
if (sub?.type !== 'FunctionDefinition')
|
|
614
|
+
continue;
|
|
615
|
+
if (!sub.body)
|
|
616
|
+
continue;
|
|
617
|
+
const fnReceivers = this.buildPerFunctionReceivers(sub, contractReceivers);
|
|
618
|
+
let found = false;
|
|
619
|
+
this.walkForEthOutCallWithLocals(sub.body, fnReceivers, () => { found = true; });
|
|
620
|
+
if (found)
|
|
621
|
+
return true;
|
|
622
|
+
}
|
|
623
|
+
return false;
|
|
624
|
+
}
|
|
625
|
+
collectContractAddressReceivers(contract) {
|
|
626
|
+
const locals = new Set();
|
|
627
|
+
for (const sub of contract.subNodes || []) {
|
|
628
|
+
if (sub?.type === 'StateVariableDeclaration') {
|
|
629
|
+
for (const v of sub.variables || []) {
|
|
630
|
+
if (v?.name && this.isAddressType(v)) {
|
|
631
|
+
locals.add(v.name);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
if (sub?.type === 'FunctionDefinition') {
|
|
636
|
+
this.walkLocalAddressDeclarations(sub.body || sub, locals);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
return locals;
|
|
640
|
+
}
|
|
641
|
+
buildPerFunctionReceivers(fn, contractReceivers) {
|
|
642
|
+
const receivers = new Set(contractReceivers);
|
|
643
|
+
const params = (Array.isArray(fn?.parameters) ? fn.parameters : fn?.parameters?.parameters) || [];
|
|
644
|
+
for (const p of params) {
|
|
645
|
+
if (p?.name && this.isAddressType(p)) {
|
|
646
|
+
receivers.add(p.name);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
return receivers;
|
|
650
|
+
}
|
|
651
|
+
isAddressType(v) {
|
|
652
|
+
const typeString = String(v.typeName?.name || v.typeName || '');
|
|
653
|
+
return typeString === 'address' || typeString === 'address payable';
|
|
654
|
+
}
|
|
655
|
+
walkLocalAddressDeclarations(node, locals) {
|
|
656
|
+
if (!node || typeof node !== 'object')
|
|
657
|
+
return;
|
|
658
|
+
if (node.type === 'VariableDeclarationStatement') {
|
|
659
|
+
for (const v of node.variables || []) {
|
|
660
|
+
if (v?.name && this.isAddressType(v)) {
|
|
661
|
+
locals.add(v.name);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
for (const key of childKeys(node)) {
|
|
666
|
+
const value = node[key];
|
|
667
|
+
if (Array.isArray(value)) {
|
|
668
|
+
for (const item of value) {
|
|
669
|
+
if (item && typeof item === 'object')
|
|
670
|
+
this.walkLocalAddressDeclarations(item, locals);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
else if (value && typeof value === 'object') {
|
|
674
|
+
this.walkLocalAddressDeclarations(value, locals);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
walkForEthOutCallWithLocals(node, addressTypedLocals, cb) {
|
|
679
|
+
if (!node || typeof node !== 'object')
|
|
680
|
+
return;
|
|
681
|
+
if (this.isRealEthOutCall(node, addressTypedLocals)) {
|
|
682
|
+
cb();
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
for (const key of childKeys(node)) {
|
|
686
|
+
const value = node[key];
|
|
687
|
+
if (Array.isArray(value)) {
|
|
688
|
+
for (const item of value) {
|
|
689
|
+
if (item && typeof item === 'object')
|
|
690
|
+
this.walkForEthOutCallWithLocals(item, addressTypedLocals, cb);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
else if (value && typeof value === 'object') {
|
|
694
|
+
this.walkForEthOutCallWithLocals(value, addressTypedLocals, cb);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
isRealEthOutCall(node, addressTypedLocals) {
|
|
699
|
+
if (node.type !== 'FunctionCall')
|
|
700
|
+
return false;
|
|
701
|
+
const callee = node.expression;
|
|
702
|
+
if (callee?.type === 'Identifier' && callee.name === 'selfdestruct') {
|
|
703
|
+
return true;
|
|
704
|
+
}
|
|
705
|
+
if (callee?.type === 'MemberAccess') {
|
|
706
|
+
const member = String(callee.memberName || '').toLowerCase();
|
|
707
|
+
if (ALWAYS_ETH_OUT_MEMBERS.has(member)) {
|
|
708
|
+
return this.isAddressShapedReceiver(callee.expression, addressTypedLocals);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
if (callee?.type === 'NameValueExpression' || callee?.type === 'FunctionCallOptions') {
|
|
712
|
+
const inner = callee.expression;
|
|
713
|
+
if (inner?.type === 'MemberAccess') {
|
|
714
|
+
const member = String(inner.memberName || '').toLowerCase();
|
|
715
|
+
if (member === 'call' && this.nameValueHasOption(callee, 'value')) {
|
|
716
|
+
return true;
|
|
717
|
+
}
|
|
718
|
+
if (ALWAYS_ETH_OUT_MEMBERS.has(member)) {
|
|
719
|
+
return this.isAddressShapedReceiver(inner.expression, addressTypedLocals);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
isAddressShapedReceiver(expr, addressTypedLocals) {
|
|
726
|
+
if (!expr)
|
|
727
|
+
return false;
|
|
728
|
+
if (expr.type === 'Identifier') {
|
|
729
|
+
const name = expr.name;
|
|
730
|
+
if (name === 'msg.sender' || name === 'tx.origin')
|
|
731
|
+
return true;
|
|
732
|
+
if (addressTypedLocals.has(name))
|
|
733
|
+
return true;
|
|
734
|
+
return false;
|
|
735
|
+
}
|
|
736
|
+
if (expr.type === 'FunctionCall') {
|
|
737
|
+
const fn = expr.expression;
|
|
738
|
+
if (fn?.type === 'Identifier') {
|
|
739
|
+
const fnName = fn.name;
|
|
740
|
+
if (fnName === 'payable' || fnName === 'address')
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return false;
|
|
745
|
+
}
|
|
746
|
+
nameValueHasOption(nve, optionName) {
|
|
747
|
+
const args = nve.arguments;
|
|
748
|
+
if (args?.type === 'NameValueList')
|
|
749
|
+
return (args.names || []).includes(optionName);
|
|
750
|
+
return (nve.options || []).some((option) => option?.name === optionName);
|
|
751
|
+
}
|
|
752
|
+
functionHasStateMutation(fn) {
|
|
753
|
+
return this.walkForStateMutation(fn.body || fn);
|
|
754
|
+
}
|
|
755
|
+
walkForStateMutation(node) {
|
|
756
|
+
if (!node || typeof node !== 'object')
|
|
757
|
+
return false;
|
|
758
|
+
if (node.type === 'VariableDeclarationStatement')
|
|
759
|
+
return true;
|
|
760
|
+
if (node.type === 'BinaryOperation' && ['=', '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '<<=', '>>=', '>>>='].includes(node.operator)) {
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
if (node.type === 'UnaryOperation' && ['++', '--'].includes(node.operator)) {
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
for (const key of childKeys(node)) {
|
|
767
|
+
const value = node[key];
|
|
768
|
+
if (Array.isArray(value)) {
|
|
769
|
+
for (const item of value) {
|
|
770
|
+
if (item && typeof item === 'object' && this.walkForStateMutation(item))
|
|
771
|
+
return true;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
else if (value && typeof value === 'object') {
|
|
775
|
+
if (this.walkForStateMutation(value))
|
|
776
|
+
return true;
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
return false;
|
|
780
|
+
}
|
|
781
|
+
balanceReadDrivesAccountingRate(contract) {
|
|
782
|
+
for (const sub of contract.subNodes || []) {
|
|
783
|
+
if (sub?.type !== 'FunctionDefinition')
|
|
784
|
+
continue;
|
|
785
|
+
if (!sub.body)
|
|
786
|
+
continue;
|
|
787
|
+
if (this.isViewOrPure(sub))
|
|
788
|
+
continue;
|
|
789
|
+
if (!this.functionHasStateMutation(sub))
|
|
790
|
+
continue;
|
|
791
|
+
if (this.functionHasBalanceAndMsgValueInSameExpression(sub))
|
|
792
|
+
return true;
|
|
793
|
+
}
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
functionHasBalanceAndMsgValueInSameExpression(fn) {
|
|
797
|
+
return this.walkForBalanceMsgValueExpression(fn.body || fn);
|
|
798
|
+
}
|
|
799
|
+
walkForBalanceMsgValueExpression(node) {
|
|
800
|
+
if (!node || typeof node !== 'object')
|
|
801
|
+
return false;
|
|
802
|
+
if (this.isExpressionNode(node) && this.expressionContainsBalanceRead(node) && this.expressionContainsMsgValue(node)) {
|
|
803
|
+
return true;
|
|
804
|
+
}
|
|
805
|
+
for (const key of childKeys(node)) {
|
|
806
|
+
const value = node[key];
|
|
807
|
+
if (Array.isArray(value)) {
|
|
808
|
+
for (const item of value) {
|
|
809
|
+
if (item && typeof item === 'object' && this.walkForBalanceMsgValueExpression(item))
|
|
810
|
+
return true;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
else if (value && typeof value === 'object') {
|
|
814
|
+
if (this.walkForBalanceMsgValueExpression(value))
|
|
815
|
+
return true;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
return false;
|
|
819
|
+
}
|
|
820
|
+
isExpressionNode(node) {
|
|
821
|
+
return [
|
|
822
|
+
'BinaryOperation',
|
|
823
|
+
'Conditional',
|
|
824
|
+
'FunctionCall',
|
|
825
|
+
'IndexAccess',
|
|
826
|
+
'MemberAccess',
|
|
827
|
+
'NameValueExpression',
|
|
828
|
+
'TupleExpression',
|
|
829
|
+
'UnaryOperation',
|
|
830
|
+
].includes(node.type);
|
|
831
|
+
}
|
|
832
|
+
expressionContainsBalanceRead(node) {
|
|
833
|
+
let found = false;
|
|
834
|
+
this.walkForBalanceRead(node, () => { found = true; });
|
|
835
|
+
return found;
|
|
836
|
+
}
|
|
837
|
+
expressionContainsMsgValue(node) {
|
|
838
|
+
if (!node || typeof node !== 'object')
|
|
839
|
+
return false;
|
|
840
|
+
if (node.type === 'MemberAccess' && node.memberName === 'value') {
|
|
841
|
+
const expr = node.expression;
|
|
842
|
+
if (expr?.type === 'Identifier' && expr.name === 'msg')
|
|
843
|
+
return true;
|
|
844
|
+
}
|
|
845
|
+
for (const key of childKeys(node)) {
|
|
846
|
+
const value = node[key];
|
|
847
|
+
if (Array.isArray(value)) {
|
|
848
|
+
for (const item of value) {
|
|
849
|
+
if (item && typeof item === 'object' && this.expressionContainsMsgValue(item))
|
|
850
|
+
return true;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
else if (value && typeof value === 'object') {
|
|
854
|
+
if (this.expressionContainsMsgValue(value))
|
|
855
|
+
return true;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
balanceDrivesDirectPayoutWithLoc(contract) {
|
|
861
|
+
const contractReceivers = this.collectContractAddressReceivers(contract);
|
|
862
|
+
for (const sub of contract.subNodes || []) {
|
|
863
|
+
if (sub?.type !== 'FunctionDefinition')
|
|
864
|
+
continue;
|
|
865
|
+
if (!sub.body)
|
|
866
|
+
continue;
|
|
867
|
+
if (this.isViewOrPure(sub))
|
|
868
|
+
continue;
|
|
869
|
+
const fnReceivers = this.buildPerFunctionReceivers(sub, contractReceivers);
|
|
870
|
+
const taint = this.buildPerFunctionTaint(sub);
|
|
871
|
+
const loc = this.findBalanceInPayoutContext(sub.body || sub, taint, sub, fnReceivers);
|
|
872
|
+
if (loc)
|
|
873
|
+
return { ...loc, functionName: sub.name || '<anonymous>' };
|
|
874
|
+
}
|
|
875
|
+
return null;
|
|
876
|
+
}
|
|
877
|
+
findBalanceInPayoutContext(node, taint, funcNode, receivers) {
|
|
878
|
+
if (!node || typeof node !== 'object')
|
|
879
|
+
return null;
|
|
880
|
+
if (this.isRealEthOutCall(node, receivers) && this.callArgumentsContainBalance(node, taint)) {
|
|
881
|
+
if (!this.isOwnerSweep(funcNode, node)) {
|
|
882
|
+
const { line, column } = (0, ast_1.assertLoc)(node);
|
|
883
|
+
return { line, column };
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
for (const key of childKeys(node)) {
|
|
887
|
+
const value = node[key];
|
|
888
|
+
if (Array.isArray(value)) {
|
|
889
|
+
for (const item of value) {
|
|
890
|
+
if (item && typeof item === 'object') {
|
|
891
|
+
const found = this.findBalanceInPayoutContext(item, taint, funcNode, receivers);
|
|
892
|
+
if (found)
|
|
893
|
+
return found;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
else if (value && typeof value === 'object') {
|
|
898
|
+
const found = this.findBalanceInPayoutContext(value, taint, funcNode, receivers);
|
|
899
|
+
if (found)
|
|
900
|
+
return found;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
return null;
|
|
904
|
+
}
|
|
905
|
+
isOwnerSweep(funcNode, callNode) {
|
|
906
|
+
if (!this.functionHasAccessControlModifier(funcNode))
|
|
907
|
+
return false;
|
|
908
|
+
const recipient = this.getEthOutRecipient(callNode);
|
|
909
|
+
if (!recipient)
|
|
910
|
+
return false;
|
|
911
|
+
return this.isFixedSafeRecipient(recipient);
|
|
912
|
+
}
|
|
913
|
+
functionHasAccessControlModifier(fn) {
|
|
914
|
+
for (const mod of fn.modifiers || []) {
|
|
915
|
+
if (mod?.type === 'ModifierInvocation' && mod.name) {
|
|
916
|
+
if (/^only[A-Z]/.test(mod.name))
|
|
917
|
+
return true;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return false;
|
|
921
|
+
}
|
|
922
|
+
getEthOutRecipient(callNode) {
|
|
923
|
+
const callee = callNode.expression;
|
|
924
|
+
if (callee?.type === 'Identifier' && callee.name === 'selfdestruct') {
|
|
925
|
+
return callNode.arguments?.[0] || null;
|
|
926
|
+
}
|
|
927
|
+
if (callee?.type === 'MemberAccess') {
|
|
928
|
+
const member = String(callee.memberName || '').toLowerCase();
|
|
929
|
+
if (ALWAYS_ETH_OUT_MEMBERS.has(member)) {
|
|
930
|
+
return callee.expression;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (callee?.type === 'NameValueExpression' || callee?.type === 'FunctionCallOptions') {
|
|
934
|
+
const inner = callee.expression;
|
|
935
|
+
if (inner?.type === 'MemberAccess') {
|
|
936
|
+
const member = String(inner.memberName || '').toLowerCase();
|
|
937
|
+
if (member === 'call' || ALWAYS_ETH_OUT_MEMBERS.has(member)) {
|
|
938
|
+
return inner.expression;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
return null;
|
|
943
|
+
}
|
|
944
|
+
isFixedSafeRecipient(expr) {
|
|
945
|
+
if (!expr)
|
|
946
|
+
return false;
|
|
947
|
+
if (expr.type === 'FunctionCall' &&
|
|
948
|
+
expr.expression?.type === 'Identifier' &&
|
|
949
|
+
expr.expression.name === 'payable' &&
|
|
950
|
+
expr.arguments?.length === 1) {
|
|
951
|
+
return this.isFixedSafeRecipient(expr.arguments[0]);
|
|
952
|
+
}
|
|
953
|
+
if (expr.type === 'Identifier') {
|
|
954
|
+
return /^(owner|admin|treasury|feeRecipient|feeAddress|fee_to|beneficiary|payee)$/.test(expr.name);
|
|
955
|
+
}
|
|
956
|
+
if (expr.type === 'FunctionCall' && expr.expression?.type === 'Identifier') {
|
|
957
|
+
return /^(owner|admin|treasury|feeRecipient|feeAddress|fee_to|beneficiary|payee)$/.test(expr.expression.name);
|
|
958
|
+
}
|
|
959
|
+
return false;
|
|
960
|
+
}
|
|
961
|
+
buildPerFunctionTaint(fn) {
|
|
962
|
+
const localVariables = this.collectLocalVariableNames(fn.body || fn);
|
|
963
|
+
const taint = new Set();
|
|
964
|
+
const steps = this.collectLocalTaintSteps(fn.body || fn, localVariables);
|
|
965
|
+
let changed = true;
|
|
966
|
+
while (changed) {
|
|
967
|
+
changed = false;
|
|
968
|
+
for (const step of steps) {
|
|
969
|
+
if (taint.has(step.name))
|
|
970
|
+
continue;
|
|
971
|
+
if (this.expressionDependsOnTaint(step.value, taint)) {
|
|
972
|
+
taint.add(step.name);
|
|
973
|
+
changed = true;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
return taint;
|
|
978
|
+
}
|
|
979
|
+
collectLocalVariableNames(node) {
|
|
980
|
+
const locals = new Set();
|
|
981
|
+
this.walkLocalDeclarations(node, locals);
|
|
982
|
+
return locals;
|
|
983
|
+
}
|
|
984
|
+
walkLocalDeclarations(node, locals) {
|
|
985
|
+
if (!node || typeof node !== 'object')
|
|
986
|
+
return;
|
|
987
|
+
if (node.type === 'VariableDeclarationStatement') {
|
|
988
|
+
for (const v of node.variables || []) {
|
|
989
|
+
if (v?.name)
|
|
990
|
+
locals.add(v.name);
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
for (const key of childKeys(node)) {
|
|
994
|
+
const value = node[key];
|
|
995
|
+
if (Array.isArray(value)) {
|
|
996
|
+
for (const item of value) {
|
|
997
|
+
if (item && typeof item === 'object')
|
|
998
|
+
this.walkLocalDeclarations(item, locals);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
else if (value && typeof value === 'object') {
|
|
1002
|
+
this.walkLocalDeclarations(value, locals);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
collectLocalTaintSteps(node, locals) {
|
|
1007
|
+
const steps = [];
|
|
1008
|
+
this.walkLocalTaintSteps(node, locals, steps);
|
|
1009
|
+
return steps;
|
|
1010
|
+
}
|
|
1011
|
+
walkLocalTaintSteps(node, locals, steps) {
|
|
1012
|
+
if (!node || typeof node !== 'object')
|
|
1013
|
+
return;
|
|
1014
|
+
if (node.type === 'VariableDeclarationStatement' && node.initialValue) {
|
|
1015
|
+
for (const v of node.variables || []) {
|
|
1016
|
+
if (v?.name)
|
|
1017
|
+
steps.push({ name: v.name, value: node.initialValue });
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
if (node.type === 'ExpressionStatement' && node.expression?.type === 'BinaryOperation' && node.expression.operator === '=') {
|
|
1021
|
+
const lhs = node.expression.left;
|
|
1022
|
+
if (lhs?.type === 'Identifier' && locals.has(lhs.name)) {
|
|
1023
|
+
steps.push({ name: lhs.name, value: node.expression.right });
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
for (const key of childKeys(node)) {
|
|
1027
|
+
const value = node[key];
|
|
1028
|
+
if (Array.isArray(value)) {
|
|
1029
|
+
for (const item of value) {
|
|
1030
|
+
if (item && typeof item === 'object')
|
|
1031
|
+
this.walkLocalTaintSteps(item, locals, steps);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
else if (value && typeof value === 'object') {
|
|
1035
|
+
this.walkLocalTaintSteps(value, locals, steps);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
callArgumentsContainBalance(node, taint) {
|
|
1040
|
+
const allArgs = [];
|
|
1041
|
+
if (node?.arguments) {
|
|
1042
|
+
if (node.arguments.type === 'NameValueList') {
|
|
1043
|
+
for (const arg of node.arguments.arguments || []) {
|
|
1044
|
+
allArgs.push(arg);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
else {
|
|
1048
|
+
for (const arg of node.arguments) {
|
|
1049
|
+
allArgs.push(arg);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
if (node?.expression?.type === 'NameValueExpression' || node?.expression?.type === 'FunctionCallOptions') {
|
|
1054
|
+
const nveArgs = node.expression.arguments;
|
|
1055
|
+
if (nveArgs?.type === 'NameValueList') {
|
|
1056
|
+
for (const arg of nveArgs.arguments || []) {
|
|
1057
|
+
allArgs.push(arg);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
for (const option of node.expression.options || []) {
|
|
1061
|
+
if (option?.value)
|
|
1062
|
+
allArgs.push(option.value);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
for (const arg of allArgs) {
|
|
1066
|
+
if (this.argContainsBalance(arg, taint))
|
|
1067
|
+
return true;
|
|
1068
|
+
}
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
argContainsBalance(arg, taint) {
|
|
1072
|
+
return this.expressionDependsOnTaint(arg, taint);
|
|
1073
|
+
}
|
|
1074
|
+
expressionDependsOnTaint(node, taint) {
|
|
1075
|
+
if (!node || typeof node !== 'object')
|
|
1076
|
+
return false;
|
|
1077
|
+
if (node.type === 'Identifier' && taint.has(node.name))
|
|
1078
|
+
return true;
|
|
1079
|
+
if (node.type === 'MemberAccess' && node.memberName === 'balance' && this.isThisBalanceRead(node)) {
|
|
1080
|
+
return true;
|
|
1081
|
+
}
|
|
1082
|
+
if (node.type === 'BinaryOperation') {
|
|
1083
|
+
return this.expressionDependsOnTaint(node.left, taint) || this.expressionDependsOnTaint(node.right, taint);
|
|
1084
|
+
}
|
|
1085
|
+
if (node.type === 'UnaryOperation') {
|
|
1086
|
+
return this.expressionDependsOnTaint(node.subExpression, taint);
|
|
1087
|
+
}
|
|
1088
|
+
if (node.type === 'Conditional') {
|
|
1089
|
+
return this.expressionDependsOnTaint(node.trueExpression, taint) || this.expressionDependsOnTaint(node.falseExpression, taint);
|
|
1090
|
+
}
|
|
1091
|
+
if (node.type === 'TupleExpression') {
|
|
1092
|
+
for (const component of node.components || []) {
|
|
1093
|
+
if (this.expressionDependsOnTaint(component, taint))
|
|
1094
|
+
return true;
|
|
1095
|
+
}
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1098
|
+
if (node.type === 'FunctionCall') {
|
|
1099
|
+
if (this.expressionDependsOnTaint(node.expression, taint))
|
|
1100
|
+
return true;
|
|
1101
|
+
const args = node.arguments;
|
|
1102
|
+
if (args?.type === 'NameValueList') {
|
|
1103
|
+
for (const arg of args.arguments || []) {
|
|
1104
|
+
if (this.expressionDependsOnTaint(arg, taint))
|
|
1105
|
+
return true;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
for (const arg of args || []) {
|
|
1110
|
+
if (this.expressionDependsOnTaint(arg, taint))
|
|
1111
|
+
return true;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
return false;
|
|
1115
|
+
}
|
|
1116
|
+
if (node.type === 'IndexAccess') {
|
|
1117
|
+
return this.expressionDependsOnTaint(node.base, taint) || this.expressionDependsOnTaint(node.index, taint);
|
|
1118
|
+
}
|
|
1119
|
+
if (node.type === 'MemberAccess') {
|
|
1120
|
+
return this.expressionDependsOnTaint(node.expression, taint);
|
|
1121
|
+
}
|
|
1122
|
+
if (node.type === 'NameValueExpression') {
|
|
1123
|
+
if (this.expressionDependsOnTaint(node.expression, taint))
|
|
1124
|
+
return true;
|
|
1125
|
+
const args = node.arguments;
|
|
1126
|
+
if (args?.type === 'NameValueList') {
|
|
1127
|
+
for (const arg of args.arguments || []) {
|
|
1128
|
+
if (this.expressionDependsOnTaint(arg, taint))
|
|
1129
|
+
return true;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1134
|
+
return false;
|
|
1135
|
+
}
|
|
1136
|
+
isViewOrPure(fn) {
|
|
1137
|
+
const mutability = String(fn.stateMutability || '').toLowerCase();
|
|
1138
|
+
return mutability === 'view' || mutability === 'pure';
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
exports.DontLetEthGetRektDetector = DontLetEthGetRektDetector;
|
|
1142
|
+
function childKeys(node) {
|
|
1143
|
+
const skip = new Set(['loc', 'range', 'typeName']);
|
|
1144
|
+
const keys = [];
|
|
1145
|
+
for (const k of Object.keys(node)) {
|
|
1146
|
+
if (!skip.has(k))
|
|
1147
|
+
keys.push(k);
|
|
1148
|
+
}
|
|
1149
|
+
return keys;
|
|
1150
|
+
}
|
|
1151
|
+
//# sourceMappingURL=dont-let-eth-get-rekt.js.map
|