@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,1023 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OracleManipulationDetector = void 0;
|
|
4
|
+
const oracle_1 = require("./_common/oracle");
|
|
5
|
+
const ast_1 = require("./_common/ast");
|
|
6
|
+
const RULE_ID = 'oracle-manipulation';
|
|
7
|
+
const DEFAULT_MAX_AGE_S = 60;
|
|
8
|
+
const SENSITIVE_SINK_NAMES = new Set([
|
|
9
|
+
'liquidate',
|
|
10
|
+
'_liquidate',
|
|
11
|
+
'swap',
|
|
12
|
+
'_swap',
|
|
13
|
+
'mint',
|
|
14
|
+
'_mint',
|
|
15
|
+
'borrow',
|
|
16
|
+
'_borrow',
|
|
17
|
+
'redeem',
|
|
18
|
+
'_redeem',
|
|
19
|
+
'seize',
|
|
20
|
+
'_seize',
|
|
21
|
+
'close',
|
|
22
|
+
'_close',
|
|
23
|
+
'forceLiquidation',
|
|
24
|
+
'_forceLiquidation',
|
|
25
|
+
'flashLoan',
|
|
26
|
+
'_flashLoan',
|
|
27
|
+
]);
|
|
28
|
+
const FRESHNESS_FIELD_TERMS = [
|
|
29
|
+
'updatedAt',
|
|
30
|
+
'updated_at',
|
|
31
|
+
'publishTime',
|
|
32
|
+
'publish_time',
|
|
33
|
+
'roundTimestamp',
|
|
34
|
+
'lastUpdate',
|
|
35
|
+
'lastupdate',
|
|
36
|
+
];
|
|
37
|
+
class OracleManipulationDetector {
|
|
38
|
+
maxAgeSeconds;
|
|
39
|
+
id = RULE_ID;
|
|
40
|
+
patternKey = RULE_ID;
|
|
41
|
+
supportedAstKinds = ['parser', 'solc'];
|
|
42
|
+
findings = [];
|
|
43
|
+
currentFile = '';
|
|
44
|
+
currentContract = '';
|
|
45
|
+
seen = new Set();
|
|
46
|
+
ctx;
|
|
47
|
+
constructor(maxAgeSeconds = DEFAULT_MAX_AGE_S) {
|
|
48
|
+
this.maxAgeSeconds = maxAgeSeconds;
|
|
49
|
+
}
|
|
50
|
+
setFile(file) {
|
|
51
|
+
this.currentFile = file;
|
|
52
|
+
this.findings = [];
|
|
53
|
+
this.currentContract = '';
|
|
54
|
+
this.seen.clear();
|
|
55
|
+
}
|
|
56
|
+
setContext(ctx) {
|
|
57
|
+
this.ctx = ctx;
|
|
58
|
+
ctx.taint?.registerSource('oracle-amm-spot', (node) => {
|
|
59
|
+
if (node?.type !== 'FunctionCall')
|
|
60
|
+
return false;
|
|
61
|
+
return this.isAmmSpotSourceCall(node);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
getFindings() {
|
|
65
|
+
return this.findings;
|
|
66
|
+
}
|
|
67
|
+
ContractDefinition(node) {
|
|
68
|
+
this.currentContract = node.name || '<anonymous>';
|
|
69
|
+
}
|
|
70
|
+
ContractDefinition_post(_node) {
|
|
71
|
+
this.currentContract = '';
|
|
72
|
+
}
|
|
73
|
+
FunctionDefinition(node) {
|
|
74
|
+
if (!node?.body)
|
|
75
|
+
return;
|
|
76
|
+
const state = this.analyzeFunction(node.body, node.name);
|
|
77
|
+
if (this.hasAmmPriceProvenance(state) && (state.sinkCalls.length > 0 || state.enclosingSink || state.storageMutations.length > 0)) {
|
|
78
|
+
const sink = this.findUnprotectedAmmSink(state) ||
|
|
79
|
+
(state.enclosingSink && state.sinkCalls.length === 0 && state.sinkRequires.length === 0 && state.storageMutations.length === 0
|
|
80
|
+
? this.findUnprotectedAmmUse(state)
|
|
81
|
+
: null);
|
|
82
|
+
if (sink) {
|
|
83
|
+
const fnName = node.name || '<anonymous>';
|
|
84
|
+
const loc = sink?.loc?.start || node.loc?.start || { line: 0, column: 0 };
|
|
85
|
+
this.addAmFinding(this.currentFile, this.currentContract, fnName, loc.line, loc.column, sink);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (state.reads.length === 0)
|
|
89
|
+
return;
|
|
90
|
+
const hasFreshness = state.hasFreshnessGuard ||
|
|
91
|
+
state.reads.some(read => read.freshnessChecked) ||
|
|
92
|
+
(state.reads.some(read => read.kind === 'generic') && state.hasGenericFreshnessGuard);
|
|
93
|
+
const confidence = state.validatesPrice || state.validatesConf ? 'medium' : 'high';
|
|
94
|
+
let subFinding;
|
|
95
|
+
const hasPythRead = state.reads.some(read => read.kind === 'pyth');
|
|
96
|
+
if (!hasFreshness) {
|
|
97
|
+
subFinding = 'stale-feed';
|
|
98
|
+
}
|
|
99
|
+
else if (hasPythRead && (state.hasRiskyRawPriceArithmetic || !state.hasDeviationBound)) {
|
|
100
|
+
subFinding = 'unbounded-deviation';
|
|
101
|
+
}
|
|
102
|
+
if (!subFinding)
|
|
103
|
+
return;
|
|
104
|
+
const read = state.reads.find(candidate => !candidate.freshnessChecked) || state.reads[0];
|
|
105
|
+
this.addFinding(read.node, node, subFinding, confidence);
|
|
106
|
+
}
|
|
107
|
+
isPriceUsedInSensitiveContext(state) {
|
|
108
|
+
if (state.sinkCalls.length === 0 && state.sinkRequires.length === 0 && !state.enclosingSink && state.storageMutations.length === 0)
|
|
109
|
+
return false;
|
|
110
|
+
const priceNodes = [];
|
|
111
|
+
for (const read of state.ammReads) {
|
|
112
|
+
priceNodes.push(read);
|
|
113
|
+
}
|
|
114
|
+
for (const sink of state.sinkCalls) {
|
|
115
|
+
if (this.sinkUsesPrice(sink, state))
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
for (const req of state.sinkRequires) {
|
|
119
|
+
if (this.requireUsesPrice(req, state))
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (state.enclosingSink && state.sinkCalls.length === 0) {
|
|
123
|
+
if (this.functionBodyUsesPriceVariables(state))
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
for (const mutation of state.storageMutations) {
|
|
127
|
+
if (this.mutationUsesPriceVariables(mutation, state))
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
sinkUsesPrice(sink, state) {
|
|
133
|
+
const args = sink.arguments || [];
|
|
134
|
+
for (const arg of args) {
|
|
135
|
+
if (this.expressionUsesVariables(arg, state.priceVariables))
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
requireUsesPrice(req, state) {
|
|
141
|
+
const condition = req.arguments?.[0];
|
|
142
|
+
if (!condition)
|
|
143
|
+
return false;
|
|
144
|
+
return this.expressionUsesVariables(condition, state.priceVariables);
|
|
145
|
+
}
|
|
146
|
+
expressionUsesVariables(expr, variables) {
|
|
147
|
+
if (!expr || typeof expr !== 'object')
|
|
148
|
+
return false;
|
|
149
|
+
let found = false;
|
|
150
|
+
this.walk(expr, node => {
|
|
151
|
+
if (found)
|
|
152
|
+
return;
|
|
153
|
+
if (node.type === 'Identifier' && variables.has(node.name)) {
|
|
154
|
+
found = true;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return found;
|
|
158
|
+
}
|
|
159
|
+
hasTwapProtection(state) {
|
|
160
|
+
return state.twapCalls.length > 0;
|
|
161
|
+
}
|
|
162
|
+
hasChainlinkFreshnessGuard(state) {
|
|
163
|
+
if (state.hasGenericFreshnessGuard)
|
|
164
|
+
return true;
|
|
165
|
+
for (const read of state.reads) {
|
|
166
|
+
if (read.kind === 'generic' && read.freshnessChecked)
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
hasMultiSourceAggregation(state) {
|
|
172
|
+
return state.ammReads.length >= 2;
|
|
173
|
+
}
|
|
174
|
+
addAmFinding(file, contract, fnName, line, column, sinkNode) {
|
|
175
|
+
const key = `${file}:${line}:${column}:amm-spot`;
|
|
176
|
+
if (this.seen.has(key))
|
|
177
|
+
return;
|
|
178
|
+
this.seen.add(key);
|
|
179
|
+
this.findings.push({
|
|
180
|
+
file,
|
|
181
|
+
contract,
|
|
182
|
+
'function': fnName,
|
|
183
|
+
line,
|
|
184
|
+
endLine: (0, ast_1.tryLoc)(sinkNode)?.endLine ?? line,
|
|
185
|
+
column,
|
|
186
|
+
pattern: RULE_ID,
|
|
187
|
+
confidence: 'high',
|
|
188
|
+
ruleId: RULE_ID,
|
|
189
|
+
severity: 'high',
|
|
190
|
+
message: `Oracle manipulation risk in function '${fnName}': manipulable AMM spot price source drives sensitive operation without a TWAP or deviation check.`,
|
|
191
|
+
contractName: contract,
|
|
192
|
+
functionName: fnName,
|
|
193
|
+
sourceLocation: { line, column },
|
|
194
|
+
findingId: '',
|
|
195
|
+
contractHash: '',
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
analyzeFunction(body, fnName = '') {
|
|
199
|
+
const state = {
|
|
200
|
+
reads: [],
|
|
201
|
+
hasFreshnessGuard: false,
|
|
202
|
+
hasGenericFreshnessGuard: false,
|
|
203
|
+
hasDeviationBound: false,
|
|
204
|
+
validatesPrice: false,
|
|
205
|
+
validatesConf: false,
|
|
206
|
+
hasRiskyRawPriceArithmetic: false,
|
|
207
|
+
ammReads: [],
|
|
208
|
+
twapCalls: [],
|
|
209
|
+
sinkCalls: [],
|
|
210
|
+
storageMutations: [],
|
|
211
|
+
enclosingSink: false,
|
|
212
|
+
priceVariables: new Set(),
|
|
213
|
+
priceProvenance: new Map(),
|
|
214
|
+
sinkRequires: [],
|
|
215
|
+
functionBody: body,
|
|
216
|
+
};
|
|
217
|
+
this.collectAmminformation(body, state);
|
|
218
|
+
this.trackDerivedPriceVariables(state);
|
|
219
|
+
this.trackTwapDeviationChecks(state);
|
|
220
|
+
this.trackDerivedPriceVariables(state);
|
|
221
|
+
this.analyzePythChainlink(body, state);
|
|
222
|
+
state.hasRiskyRawPriceArithmetic = this.hasRiskyRawPriceArithmetic(body);
|
|
223
|
+
if (fnName && SENSITIVE_SINK_NAMES.has(fnName)) {
|
|
224
|
+
state.enclosingSink = true;
|
|
225
|
+
}
|
|
226
|
+
this.collectStorageMutations(state);
|
|
227
|
+
return state;
|
|
228
|
+
}
|
|
229
|
+
collectAmminformation(body, state) {
|
|
230
|
+
this.walk(body, node => {
|
|
231
|
+
if (!node || typeof node !== 'object')
|
|
232
|
+
return;
|
|
233
|
+
if (node.type === 'FunctionCall') {
|
|
234
|
+
const name = this.getCalleeName(node.expression);
|
|
235
|
+
if (this.isAmmSpotSourceCall(node)) {
|
|
236
|
+
state.ammReads.push({ node, kind: 'amm-spot' });
|
|
237
|
+
}
|
|
238
|
+
if (oracle_1.TWAP_CALLS.has(name)) {
|
|
239
|
+
state.twapCalls.push(node);
|
|
240
|
+
}
|
|
241
|
+
const nameLower = name.toLowerCase();
|
|
242
|
+
if (oracle_1.SINK_CALL_NAMES.has(nameLower) || oracle_1.SINK_CALL_NAMES.has(name)) {
|
|
243
|
+
state.sinkCalls.push(node);
|
|
244
|
+
}
|
|
245
|
+
if (name === 'require' || name === 'assert') {
|
|
246
|
+
state.sinkRequires.push(node);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
findUnprotectedAmmSink(state) {
|
|
252
|
+
for (const sink of state.sinkCalls) {
|
|
253
|
+
for (const arg of sink.arguments || []) {
|
|
254
|
+
const provenance = this.getExpressionProvenance(arg, state);
|
|
255
|
+
if (this.isUnprotectedSpotProvenance(provenance))
|
|
256
|
+
return sink;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
for (const req of state.sinkRequires) {
|
|
260
|
+
const condition = req.arguments?.[0];
|
|
261
|
+
const provenance = this.getExpressionProvenance(condition, state);
|
|
262
|
+
if (this.isUnprotectedSpotProvenance(provenance))
|
|
263
|
+
return req;
|
|
264
|
+
}
|
|
265
|
+
for (const mutation of state.storageMutations) {
|
|
266
|
+
const right = mutation.rightHandSide || mutation.right;
|
|
267
|
+
const provenance = this.getExpressionProvenance(right, state);
|
|
268
|
+
if (this.isUnprotectedSpotProvenance(provenance))
|
|
269
|
+
return mutation;
|
|
270
|
+
}
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
findUnprotectedAmmUse(state) {
|
|
274
|
+
if (!state.functionBody)
|
|
275
|
+
return null;
|
|
276
|
+
let result = null;
|
|
277
|
+
this.walk(state.functionBody, node => {
|
|
278
|
+
if (result)
|
|
279
|
+
return;
|
|
280
|
+
const provenance = this.getExpressionProvenance(node, state);
|
|
281
|
+
if (this.isUnprotectedSpotProvenance(provenance))
|
|
282
|
+
result = node;
|
|
283
|
+
});
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
isUnprotectedSpotProvenance(provenance) {
|
|
287
|
+
if (provenance.ammSources.size === 0)
|
|
288
|
+
return false;
|
|
289
|
+
if (provenance.twapDerived || provenance.twapChecked)
|
|
290
|
+
return false;
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
hasAmmPriceProvenance(state) {
|
|
294
|
+
if (state.ammReads.length > 0)
|
|
295
|
+
return true;
|
|
296
|
+
for (const provenance of state.priceProvenance.values()) {
|
|
297
|
+
if (provenance.ammSources.size > 0)
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
conditionUsesAmmspotPrice(condition, state) {
|
|
303
|
+
if (state.priceVariables.size === 0)
|
|
304
|
+
return false;
|
|
305
|
+
return this.expressionUsesVariables(condition, state.priceVariables);
|
|
306
|
+
}
|
|
307
|
+
trackPriceVariablesFromAmmsource(callNode, state) {
|
|
308
|
+
let found = false;
|
|
309
|
+
const search = (node, parent) => {
|
|
310
|
+
if (found)
|
|
311
|
+
return;
|
|
312
|
+
if (!node || typeof node !== 'object')
|
|
313
|
+
return;
|
|
314
|
+
if (node === callNode && parent) {
|
|
315
|
+
if (parent.type === 'VariableDeclarationStatement') {
|
|
316
|
+
for (const decl of this.getDeclaredVariables(parent)) {
|
|
317
|
+
if (decl?.name && typeof decl.name === 'string') {
|
|
318
|
+
state.priceVariables.add(decl.name);
|
|
319
|
+
this.mergeVariableProvenance(decl.name, this.getExpressionProvenance(callNode, state), state);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
found = true;
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (this.isAssignmentLikeNode(parent) && this.getAssignmentRight(parent) === callNode) {
|
|
326
|
+
const left = this.getAssignmentLeft(parent);
|
|
327
|
+
if (left) {
|
|
328
|
+
this.collectAssignmentTargets(left, state.priceVariables);
|
|
329
|
+
this.mergeAssignmentTargetProvenance(left, this.getExpressionProvenance(callNode, state), state);
|
|
330
|
+
}
|
|
331
|
+
found = true;
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
for (const [key, value] of Object.entries(node)) {
|
|
336
|
+
if (key === 'loc' || key === 'range')
|
|
337
|
+
continue;
|
|
338
|
+
if (Array.isArray(value)) {
|
|
339
|
+
for (const item of value) {
|
|
340
|
+
if (item && typeof item === 'object') {
|
|
341
|
+
search(item, node);
|
|
342
|
+
if (found)
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
else if (value && typeof value === 'object') {
|
|
348
|
+
search(value, node);
|
|
349
|
+
if (found)
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
const root = state.functionBody;
|
|
355
|
+
if (root)
|
|
356
|
+
search(root, null);
|
|
357
|
+
}
|
|
358
|
+
isAssignmentLikeNode(node) {
|
|
359
|
+
if (!node || typeof node !== 'object')
|
|
360
|
+
return false;
|
|
361
|
+
if (node.type === 'Assignment')
|
|
362
|
+
return true;
|
|
363
|
+
if (node.type === 'BinaryOperation' && node.operator === '=')
|
|
364
|
+
return true;
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
getAssignmentLeft(node) {
|
|
368
|
+
if (!node)
|
|
369
|
+
return null;
|
|
370
|
+
return node.leftHandSide ?? node.left ?? null;
|
|
371
|
+
}
|
|
372
|
+
getAssignmentRight(node) {
|
|
373
|
+
if (!node)
|
|
374
|
+
return null;
|
|
375
|
+
return node.rightHandSide ?? node.right ?? null;
|
|
376
|
+
}
|
|
377
|
+
collectAssignmentTargets(node, set) {
|
|
378
|
+
if (!node || typeof node !== 'object')
|
|
379
|
+
return;
|
|
380
|
+
if (node.type === 'Identifier' && typeof node.name === 'string') {
|
|
381
|
+
set.add(node.name);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
if (node.type === 'VariableDeclaration' && typeof node.name === 'string') {
|
|
385
|
+
set.add(node.name);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (node.type === 'TupleExpression') {
|
|
389
|
+
const components = node.components || [];
|
|
390
|
+
for (const comp of components) {
|
|
391
|
+
if (comp)
|
|
392
|
+
this.collectAssignmentTargets(comp, set);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
trackDerivedPriceVariables(state) {
|
|
397
|
+
if (!state.functionBody)
|
|
398
|
+
return;
|
|
399
|
+
const maxIterations = 100;
|
|
400
|
+
let iterations = 0;
|
|
401
|
+
let changed = true;
|
|
402
|
+
while (changed && iterations < maxIterations) {
|
|
403
|
+
changed = false;
|
|
404
|
+
iterations++;
|
|
405
|
+
const search = (node) => {
|
|
406
|
+
if (!node || typeof node !== 'object')
|
|
407
|
+
return;
|
|
408
|
+
if (node.type === 'VariableDeclarationStatement') {
|
|
409
|
+
const initial = node.initialValue;
|
|
410
|
+
if (initial) {
|
|
411
|
+
const provenance = this.getExpressionProvenance(initial, state);
|
|
412
|
+
if (this.hasPriceProvenance(provenance)) {
|
|
413
|
+
for (const decl of this.getDeclaredVariables(node)) {
|
|
414
|
+
if (decl?.name && typeof decl.name === 'string') {
|
|
415
|
+
if (this.mergeVariableProvenance(decl.name, provenance, state))
|
|
416
|
+
changed = true;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (this.isAssignmentLikeNode(node)) {
|
|
423
|
+
const left = this.getAssignmentLeft(node);
|
|
424
|
+
const right = this.getAssignmentRight(node);
|
|
425
|
+
if (right) {
|
|
426
|
+
const provenance = this.getExpressionProvenance(right, state);
|
|
427
|
+
if (this.hasPriceProvenance(provenance)) {
|
|
428
|
+
if (this.mergeAssignmentTargetProvenance(left, provenance, state))
|
|
429
|
+
changed = true;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
for (const [key, value] of Object.entries(node)) {
|
|
434
|
+
if (key === 'loc' || key === 'range')
|
|
435
|
+
continue;
|
|
436
|
+
if (Array.isArray(value)) {
|
|
437
|
+
for (const item of value) {
|
|
438
|
+
if (item && typeof item === 'object')
|
|
439
|
+
search(item);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
else if (value && typeof value === 'object') {
|
|
443
|
+
search(value);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
search(state.functionBody);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
trackTwapDeviationChecks(state) {
|
|
451
|
+
if (!state.functionBody)
|
|
452
|
+
return;
|
|
453
|
+
this.walk(state.functionBody, node => {
|
|
454
|
+
if (!node || typeof node !== 'object')
|
|
455
|
+
return;
|
|
456
|
+
let condition = null;
|
|
457
|
+
if (node.type === 'FunctionCall' && this.isRequireOrAssert(node)) {
|
|
458
|
+
condition = (node.arguments || [])[0];
|
|
459
|
+
}
|
|
460
|
+
else if (node.type === 'IfStatement') {
|
|
461
|
+
condition = node.condition;
|
|
462
|
+
}
|
|
463
|
+
if (!condition)
|
|
464
|
+
return;
|
|
465
|
+
this.markTwapComparedSpotVariables(condition, state);
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
markTwapComparedSpotVariables(node, state) {
|
|
469
|
+
if (!node || typeof node !== 'object')
|
|
470
|
+
return;
|
|
471
|
+
if (node.type === 'BinaryOperation' && ['<', '<=', '>', '>=', '==', '!='].includes(node.operator)) {
|
|
472
|
+
const left = this.getExpressionProvenance(node.left, state);
|
|
473
|
+
const right = this.getExpressionProvenance(node.right, state);
|
|
474
|
+
if (this.hasAmmSpot(left) && this.isTwapOrReference(right)) {
|
|
475
|
+
this.markIdentifiersTwapChecked(node.left, state);
|
|
476
|
+
}
|
|
477
|
+
if (this.hasAmmSpot(right) && this.isTwapOrReference(left)) {
|
|
478
|
+
this.markIdentifiersTwapChecked(node.right, state);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
for (const child of this.childNodes(node)) {
|
|
482
|
+
this.markTwapComparedSpotVariables(child, state);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
markIdentifiersTwapChecked(node, state) {
|
|
486
|
+
this.walk(node, child => {
|
|
487
|
+
if (child?.type !== 'Identifier' || typeof child.name !== 'string')
|
|
488
|
+
return;
|
|
489
|
+
const provenance = state.priceProvenance.get(child.name);
|
|
490
|
+
if (provenance && provenance.ammSources.size > 0) {
|
|
491
|
+
provenance.twapChecked = true;
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
isTwapOrReference(provenance) {
|
|
496
|
+
return provenance.twapDerived;
|
|
497
|
+
}
|
|
498
|
+
hasAmmSpot(provenance) {
|
|
499
|
+
return provenance.ammSources.size > 0;
|
|
500
|
+
}
|
|
501
|
+
hasPriceProvenance(provenance) {
|
|
502
|
+
return provenance.ammSources.size > 0 || provenance.twapDerived || provenance.twapChecked;
|
|
503
|
+
}
|
|
504
|
+
emptyProvenance() {
|
|
505
|
+
return {
|
|
506
|
+
ammSources: new Set(),
|
|
507
|
+
twapDerived: false,
|
|
508
|
+
twapChecked: false,
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
cloneProvenance(provenance) {
|
|
512
|
+
return {
|
|
513
|
+
ammSources: new Set(provenance.ammSources),
|
|
514
|
+
twapDerived: provenance.twapDerived,
|
|
515
|
+
twapChecked: provenance.twapChecked,
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
unionProvenance(...items) {
|
|
519
|
+
const result = this.emptyProvenance();
|
|
520
|
+
for (const item of items) {
|
|
521
|
+
for (const source of item.ammSources)
|
|
522
|
+
result.ammSources.add(source);
|
|
523
|
+
result.twapDerived = result.twapDerived || item.twapDerived;
|
|
524
|
+
result.twapChecked = result.twapChecked || item.twapChecked;
|
|
525
|
+
}
|
|
526
|
+
return result;
|
|
527
|
+
}
|
|
528
|
+
getExpressionProvenance(expr, state) {
|
|
529
|
+
if (!expr || typeof expr !== 'object')
|
|
530
|
+
return this.emptyProvenance();
|
|
531
|
+
if (expr.type === 'Identifier' && typeof expr.name === 'string') {
|
|
532
|
+
return this.cloneProvenance(state.priceProvenance.get(expr.name) || this.emptyProvenance());
|
|
533
|
+
}
|
|
534
|
+
if (expr.type === 'FunctionCall') {
|
|
535
|
+
const name = this.getCalleeName(expr.expression);
|
|
536
|
+
let provenance = this.emptyProvenance();
|
|
537
|
+
if (this.isAmmSpotSourceCall(expr)) {
|
|
538
|
+
provenance.ammSources.add(this.getAmmSourceIdentity(expr));
|
|
539
|
+
}
|
|
540
|
+
if (this.ctx?.taint?.isTainted(expr, expr, { source: 'oracle-amm-spot' })) {
|
|
541
|
+
const path = this.ctx.taint.explain(expr, expr, { source: 'oracle-amm-spot' });
|
|
542
|
+
if (path.length > 1) {
|
|
543
|
+
provenance.ammSources.add(this.getAmmSourceIdentity(expr));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
if (oracle_1.TWAP_CALLS.has(name)) {
|
|
547
|
+
provenance.twapDerived = true;
|
|
548
|
+
}
|
|
549
|
+
const childProvenance = (expr.arguments || []).map((arg) => this.getExpressionProvenance(arg, state));
|
|
550
|
+
return this.unionProvenance(provenance, ...childProvenance);
|
|
551
|
+
}
|
|
552
|
+
const childProvenance = this.childNodes(expr).map(child => this.getExpressionProvenance(child, state));
|
|
553
|
+
return this.unionProvenance(...childProvenance);
|
|
554
|
+
}
|
|
555
|
+
mergeVariableProvenance(name, provenance, state) {
|
|
556
|
+
const current = state.priceProvenance.get(name) || this.emptyProvenance();
|
|
557
|
+
const merged = this.unionProvenance(current, provenance);
|
|
558
|
+
const changed = merged.ammSources.size !== current.ammSources.size ||
|
|
559
|
+
merged.twapDerived !== current.twapDerived ||
|
|
560
|
+
merged.twapChecked !== current.twapChecked;
|
|
561
|
+
if (changed) {
|
|
562
|
+
state.priceProvenance.set(name, merged);
|
|
563
|
+
if (merged.ammSources.size > 0)
|
|
564
|
+
state.priceVariables.add(name);
|
|
565
|
+
}
|
|
566
|
+
return changed;
|
|
567
|
+
}
|
|
568
|
+
mergeAssignmentTargetProvenance(target, provenance, state) {
|
|
569
|
+
const names = new Set();
|
|
570
|
+
this.collectAssignmentTargets(target, names);
|
|
571
|
+
let changed = false;
|
|
572
|
+
for (const name of names) {
|
|
573
|
+
changed = this.mergeVariableProvenance(name, provenance, state) || changed;
|
|
574
|
+
}
|
|
575
|
+
return changed;
|
|
576
|
+
}
|
|
577
|
+
getAmmSourceIdentity(callNode) {
|
|
578
|
+
const callee = callNode?.expression;
|
|
579
|
+
if (callee?.type === 'MemberAccess') {
|
|
580
|
+
return this.expressionKey(callee.expression);
|
|
581
|
+
}
|
|
582
|
+
const args = callNode?.arguments || [];
|
|
583
|
+
if (args.length > 0)
|
|
584
|
+
return `${this.getCalleeName(callee)}:${this.expressionKey(args[0])}`;
|
|
585
|
+
return this.getCalleeName(callee) || '<amm-source>';
|
|
586
|
+
}
|
|
587
|
+
expressionKey(node) {
|
|
588
|
+
if (!node || typeof node !== 'object')
|
|
589
|
+
return '<unknown>';
|
|
590
|
+
if (node.type === 'Identifier')
|
|
591
|
+
return `id:${node.name || '<anonymous>'}`;
|
|
592
|
+
if (node.type === 'MemberAccess')
|
|
593
|
+
return `${this.expressionKey(node.expression)}.${node.memberName || '<member>'}`;
|
|
594
|
+
if (node.type === 'IndexAccess')
|
|
595
|
+
return `${this.expressionKey(node.base)}[${this.expressionKey(node.index)}]`;
|
|
596
|
+
if (node.type === 'NumberLiteral')
|
|
597
|
+
return `num:${node.number ?? node.value ?? ''}`;
|
|
598
|
+
return node.type || '<expr>';
|
|
599
|
+
}
|
|
600
|
+
collectStorageMutations(state) {
|
|
601
|
+
if (state.priceVariables.size === 0 || !state.functionBody)
|
|
602
|
+
return;
|
|
603
|
+
this.walk(state.functionBody, node => {
|
|
604
|
+
if (!node || typeof node !== 'object')
|
|
605
|
+
return;
|
|
606
|
+
let assignmentNode = null;
|
|
607
|
+
if (node.type === 'Assignment') {
|
|
608
|
+
assignmentNode = node;
|
|
609
|
+
}
|
|
610
|
+
else if (node.type === 'ExpressionStatement' && node.expression?.type === 'BinaryOperation') {
|
|
611
|
+
const op = node.expression.operator;
|
|
612
|
+
if (op === '=' || op === '+=' || op === '-=' || op === '*=' || op === '/=' || op === '%=' || op === '|=' || op === '&=' || op === '^=') {
|
|
613
|
+
assignmentNode = {
|
|
614
|
+
leftHandSide: node.expression.left,
|
|
615
|
+
rightHandSide: node.expression.right,
|
|
616
|
+
loc: node.expression.loc,
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
if (!assignmentNode)
|
|
621
|
+
return;
|
|
622
|
+
const left = assignmentNode.leftHandSide || assignmentNode.left;
|
|
623
|
+
const right = assignmentNode.rightHandSide || assignmentNode.right;
|
|
624
|
+
if (!right)
|
|
625
|
+
return;
|
|
626
|
+
const isStorageWrite = left && (left.type === 'IndexAccess' ||
|
|
627
|
+
left.type === 'MemberAccess' ||
|
|
628
|
+
(left.type === 'Identifier' && !state.priceVariables.has(left.name)));
|
|
629
|
+
if (isStorageWrite && this.expressionUsesVariables(right, state.priceVariables)) {
|
|
630
|
+
state.storageMutations.push(assignmentNode);
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
}
|
|
634
|
+
functionBodyUsesPriceVariables(state) {
|
|
635
|
+
if (!state.functionBody || state.priceVariables.size === 0)
|
|
636
|
+
return false;
|
|
637
|
+
let found = false;
|
|
638
|
+
this.walk(state.functionBody, node => {
|
|
639
|
+
if (found)
|
|
640
|
+
return;
|
|
641
|
+
if (node.type === 'FunctionCall') {
|
|
642
|
+
const name = this.getCalleeName(node.expression);
|
|
643
|
+
if (oracle_1.SINK_CALL_NAMES.has(name))
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (this.expressionUsesVariables(node, state.priceVariables)) {
|
|
647
|
+
found = true;
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
return found;
|
|
651
|
+
}
|
|
652
|
+
mutationUsesPriceVariables(mutation, state) {
|
|
653
|
+
const right = mutation.rightHandSide || mutation.right;
|
|
654
|
+
if (!right)
|
|
655
|
+
return false;
|
|
656
|
+
return this.expressionUsesVariables(right, state.priceVariables);
|
|
657
|
+
}
|
|
658
|
+
getIdentifierName(node) {
|
|
659
|
+
if (!node || typeof node !== 'object')
|
|
660
|
+
return null;
|
|
661
|
+
if (node.type === 'Identifier')
|
|
662
|
+
return node.name || null;
|
|
663
|
+
if (node.type === 'VariableDeclaration')
|
|
664
|
+
return node.name || null;
|
|
665
|
+
return null;
|
|
666
|
+
}
|
|
667
|
+
getDeclaredVariables(node) {
|
|
668
|
+
if (!node)
|
|
669
|
+
return [];
|
|
670
|
+
if (Array.isArray(node.variables))
|
|
671
|
+
return node.variables;
|
|
672
|
+
if (Array.isArray(node.declarations))
|
|
673
|
+
return node.declarations;
|
|
674
|
+
return [];
|
|
675
|
+
}
|
|
676
|
+
analyzePythChainlink(body, state) {
|
|
677
|
+
this.walk(body, node => {
|
|
678
|
+
if (!node || typeof node !== 'object')
|
|
679
|
+
return;
|
|
680
|
+
if (node.type === 'FunctionCall') {
|
|
681
|
+
const name = this.getCalleeName(node.expression);
|
|
682
|
+
if (name === 'getPrice' || name === 'getPriceUnsafe') {
|
|
683
|
+
state.reads.push({ node, kind: 'pyth', freshnessChecked: false });
|
|
684
|
+
}
|
|
685
|
+
else if (name === 'getPriceNoOlderThan') {
|
|
686
|
+
state.reads.push({
|
|
687
|
+
node,
|
|
688
|
+
kind: 'pyth',
|
|
689
|
+
freshnessChecked: this.literalNumber((node.arguments || [])[1]) <= this.maxAgeSeconds,
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
else if (name === 'latestRoundData' || name === 'latestAnswer') {
|
|
693
|
+
state.reads.push({ node, kind: 'generic', freshnessChecked: false });
|
|
694
|
+
}
|
|
695
|
+
if (this.isRequireOrAssert(node)) {
|
|
696
|
+
const condition = (node.arguments || [])[0];
|
|
697
|
+
state.hasFreshnessGuard = state.hasFreshnessGuard || this.isFreshnessGuard(condition);
|
|
698
|
+
state.hasGenericFreshnessGuard = state.hasGenericFreshnessGuard || this.isGenericFreshnessGuard(condition);
|
|
699
|
+
state.hasDeviationBound = state.hasDeviationBound || this.isDeviationBound(condition);
|
|
700
|
+
state.validatesPrice = state.validatesPrice || this.isFieldValidation(condition, ['price', 'answer']);
|
|
701
|
+
state.validatesConf = state.validatesConf || this.isFieldValidation(condition, ['conf']);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
if (node.type === 'IfStatement') {
|
|
705
|
+
state.hasFreshnessGuard = state.hasFreshnessGuard || this.isFreshnessGuard(node.condition);
|
|
706
|
+
state.hasGenericFreshnessGuard = state.hasGenericFreshnessGuard || this.isGenericFreshnessGuard(node.condition);
|
|
707
|
+
state.hasDeviationBound = state.hasDeviationBound || this.isDeviationBound(node.condition);
|
|
708
|
+
state.validatesPrice = state.validatesPrice || this.isFieldValidation(node.condition, ['price', 'answer']);
|
|
709
|
+
state.validatesConf = state.validatesConf || this.isFieldValidation(node.condition, ['conf']);
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
addFinding(node, fn, subFinding, confidence) {
|
|
714
|
+
// tryLoc-with-floor: solc-walker may yield loc=0 on inner nodes.
|
|
715
|
+
// Bind primaryLoc separately so endLine is sourced only from `node`
|
|
716
|
+
// (matching the legacy `node?.loc?.end?.line || line` semantics);
|
|
717
|
+
// a single nested loc would leak endLine from `fn` when node lacks loc.
|
|
718
|
+
const primaryLoc = (0, ast_1.tryLoc)(node);
|
|
719
|
+
const loc = primaryLoc ?? (0, ast_1.tryLoc)(fn) ?? { line: 0, endLine: 0, column: 0 };
|
|
720
|
+
const { line, column } = loc;
|
|
721
|
+
const endLine = primaryLoc?.endLine ?? line;
|
|
722
|
+
const functionName = fn?.name || '<anonymous>';
|
|
723
|
+
const key = `${this.currentFile}:${line}:${column}:${subFinding}`;
|
|
724
|
+
if (this.seen.has(key))
|
|
725
|
+
return;
|
|
726
|
+
this.seen.add(key);
|
|
727
|
+
const message = subFinding === 'stale-feed'
|
|
728
|
+
? `Oracle manipulation risk in function '${functionName}': price feed is consumed without an accepted freshness check.`
|
|
729
|
+
: `Oracle manipulation risk in function '${functionName}': price feed is consumed without a bounded deviation check or safe exponent-scaled arithmetic.`;
|
|
730
|
+
this.findings.push({
|
|
731
|
+
file: this.currentFile,
|
|
732
|
+
contract: this.currentContract,
|
|
733
|
+
'function': functionName,
|
|
734
|
+
line,
|
|
735
|
+
endLine,
|
|
736
|
+
column,
|
|
737
|
+
pattern: RULE_ID,
|
|
738
|
+
confidence,
|
|
739
|
+
ruleId: RULE_ID,
|
|
740
|
+
severity: 'warning',
|
|
741
|
+
message,
|
|
742
|
+
contractName: this.currentContract,
|
|
743
|
+
functionName,
|
|
744
|
+
sourceLocation: { line, column },
|
|
745
|
+
trace: subFinding,
|
|
746
|
+
findingId: '',
|
|
747
|
+
contractHash: '',
|
|
748
|
+
...{ subFinding },
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
isRequireOrAssert(node) {
|
|
752
|
+
const name = this.getCalleeName(node?.expression);
|
|
753
|
+
return name === 'require' || name === 'assert';
|
|
754
|
+
}
|
|
755
|
+
isAmmSpotSourceCall(node) {
|
|
756
|
+
if (!node || node.type !== 'FunctionCall')
|
|
757
|
+
return false;
|
|
758
|
+
const name = this.getCalleeName(node.expression);
|
|
759
|
+
if (oracle_1.AMM_SPOT_SOURCES.has(name))
|
|
760
|
+
return true;
|
|
761
|
+
return name === 'balanceOf' && this.isPoolBalanceRead(node);
|
|
762
|
+
}
|
|
763
|
+
isPoolBalanceRead(node) {
|
|
764
|
+
const [account] = node.arguments || [];
|
|
765
|
+
if (!account)
|
|
766
|
+
return false;
|
|
767
|
+
return this.expressionContainsPoolReference(account);
|
|
768
|
+
}
|
|
769
|
+
expressionContainsPoolReference(node) {
|
|
770
|
+
const names = this.flattenNames(node)
|
|
771
|
+
.split(/\s+/)
|
|
772
|
+
.map(name => name.toLowerCase())
|
|
773
|
+
.filter(Boolean);
|
|
774
|
+
return names.some(name => {
|
|
775
|
+
const compact = name.replace(/[^a-z0-9]/g, '');
|
|
776
|
+
return compact === 'pair' ||
|
|
777
|
+
compact === 'pool' ||
|
|
778
|
+
compact === 'amm' ||
|
|
779
|
+
compact.startsWith('pair') ||
|
|
780
|
+
compact.startsWith('pool') ||
|
|
781
|
+
compact.startsWith('amm') ||
|
|
782
|
+
compact.endsWith('pair') ||
|
|
783
|
+
compact.endsWith('pool') ||
|
|
784
|
+
compact.endsWith('amm') ||
|
|
785
|
+
compact.includes('uniswap') ||
|
|
786
|
+
compact.includes('sushiswap') ||
|
|
787
|
+
compact.includes('pancake') ||
|
|
788
|
+
compact.startsWith('lp') ||
|
|
789
|
+
compact.endsWith('lp');
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
getCalleeName(expr) {
|
|
793
|
+
if (!expr || typeof expr !== 'object')
|
|
794
|
+
return '';
|
|
795
|
+
if (expr.type === 'Identifier')
|
|
796
|
+
return expr.name || '';
|
|
797
|
+
if (expr.type === 'MemberAccess')
|
|
798
|
+
return expr.memberName || '';
|
|
799
|
+
return '';
|
|
800
|
+
}
|
|
801
|
+
isFreshnessGuard(node) {
|
|
802
|
+
return this.hasBoundedAgeComparison(node, ['publishTime', 'publish_time', 'updatedAt', 'updated_at'], this.maxAgeSeconds);
|
|
803
|
+
}
|
|
804
|
+
isGenericFreshnessGuard(node) {
|
|
805
|
+
return this.hasBoundedAgeComparison(node, ['updatedAt', 'updated_at', 'roundTimestamp', 'lastUpdate', 'lastupdate'], Number.POSITIVE_INFINITY);
|
|
806
|
+
}
|
|
807
|
+
hasBoundedAgeComparison(node, freshnessFields, maxLiteralBound) {
|
|
808
|
+
if (!node || typeof node !== 'object')
|
|
809
|
+
return false;
|
|
810
|
+
if (node.type === 'BinaryOperation' && ['<', '<=', '>', '>='].includes(node.operator)) {
|
|
811
|
+
if (this.isMaxAgeComparison(node, freshnessFields, maxLiteralBound))
|
|
812
|
+
return true;
|
|
813
|
+
}
|
|
814
|
+
return this.anyChild(node, child => this.hasBoundedAgeComparison(child, freshnessFields, maxLiteralBound));
|
|
815
|
+
}
|
|
816
|
+
isMaxAgeComparison(node, freshnessFields, maxLiteralBound) {
|
|
817
|
+
if (!node || node.type !== 'BinaryOperation')
|
|
818
|
+
return false;
|
|
819
|
+
if (!['<', '<=', '>', '>='].includes(node.operator))
|
|
820
|
+
return false;
|
|
821
|
+
const a = node.left;
|
|
822
|
+
const b = node.right;
|
|
823
|
+
if (this.isAgeDifference(a, freshnessFields) && this.isPositiveBoundOperand(b, freshnessFields, maxLiteralBound))
|
|
824
|
+
return true;
|
|
825
|
+
if (this.isAgeDifference(b, freshnessFields) && this.isPositiveBoundOperand(a, freshnessFields, maxLiteralBound))
|
|
826
|
+
return true;
|
|
827
|
+
if (this.isFreshnessFieldRef(a, freshnessFields) && this.isOffsetTimestamp(b, freshnessFields, maxLiteralBound))
|
|
828
|
+
return true;
|
|
829
|
+
if (this.isFreshnessFieldRef(b, freshnessFields) && this.isOffsetTimestamp(a, freshnessFields, maxLiteralBound))
|
|
830
|
+
return true;
|
|
831
|
+
return false;
|
|
832
|
+
}
|
|
833
|
+
isAgeDifference(node, freshnessFields) {
|
|
834
|
+
if (!node || node.type !== 'BinaryOperation' || node.operator !== '-')
|
|
835
|
+
return false;
|
|
836
|
+
return (this.isBlockTimestampNode(node.left) && this.isFreshnessFieldRef(node.right, freshnessFields)) ||
|
|
837
|
+
(this.isBlockTimestampNode(node.right) && this.isFreshnessFieldRef(node.left, freshnessFields));
|
|
838
|
+
}
|
|
839
|
+
isOffsetTimestamp(node, freshnessFields, maxLiteralBound) {
|
|
840
|
+
if (!node || node.type !== 'BinaryOperation')
|
|
841
|
+
return false;
|
|
842
|
+
if (node.operator !== '-' && node.operator !== '+')
|
|
843
|
+
return false;
|
|
844
|
+
return (this.isBlockTimestampNode(node.left) && this.isPositiveBoundOperand(node.right, freshnessFields, maxLiteralBound)) ||
|
|
845
|
+
(this.isBlockTimestampNode(node.right) && this.isPositiveBoundOperand(node.left, freshnessFields, maxLiteralBound));
|
|
846
|
+
}
|
|
847
|
+
isBlockTimestampNode(node) {
|
|
848
|
+
return !!node && node.type === 'MemberAccess' && node.memberName === 'timestamp' &&
|
|
849
|
+
node.expression?.type === 'Identifier' && node.expression.name === 'block';
|
|
850
|
+
}
|
|
851
|
+
isFreshnessFieldRef(node, freshnessFields) {
|
|
852
|
+
if (!node || typeof node !== 'object')
|
|
853
|
+
return false;
|
|
854
|
+
if (node.type === 'Identifier' && freshnessFields.includes(node.name))
|
|
855
|
+
return true;
|
|
856
|
+
if (node.type === 'MemberAccess' && freshnessFields.includes(node.memberName))
|
|
857
|
+
return true;
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
isPositiveBoundOperand(node, freshnessFields, maxLiteralBound) {
|
|
861
|
+
if (!node || typeof node !== 'object')
|
|
862
|
+
return false;
|
|
863
|
+
if (this.isFreshnessFieldRef(node, freshnessFields))
|
|
864
|
+
return false;
|
|
865
|
+
if (this.isBlockTimestampNode(node))
|
|
866
|
+
return false;
|
|
867
|
+
if (node.type === 'NumberLiteral') {
|
|
868
|
+
const value = this.literalNumber(node);
|
|
869
|
+
return Number.isFinite(value) && value > 0 && value <= maxLiteralBound;
|
|
870
|
+
}
|
|
871
|
+
if (node.type === 'Identifier' || node.type === 'MemberAccess')
|
|
872
|
+
return true;
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
875
|
+
isDeviationBound(node) {
|
|
876
|
+
if (!node || typeof node !== 'object')
|
|
877
|
+
return false;
|
|
878
|
+
if (node.type === 'BinaryOperation' && ['<', '<=', '>', '>='].includes(node.operator)) {
|
|
879
|
+
const left = this.flattenNames(node.left);
|
|
880
|
+
const right = this.flattenNames(node.right);
|
|
881
|
+
const names = `${left} ${right}`.toLowerCase();
|
|
882
|
+
const hasPriceSide = names.includes('price') || names.includes('answer') || names.includes('delta') || names.includes('deviation');
|
|
883
|
+
const hasReference = ['last', 'old', 'prior', 'twap', 'median', 'reference', 'trusted', 'maxdeviation', 'delta', 'deviation']
|
|
884
|
+
.some(term => names.includes(term));
|
|
885
|
+
if (hasPriceSide && hasReference)
|
|
886
|
+
return true;
|
|
887
|
+
}
|
|
888
|
+
return this.anyChild(node, child => this.isDeviationBound(child));
|
|
889
|
+
}
|
|
890
|
+
isFieldValidation(node, fields) {
|
|
891
|
+
if (!node || typeof node !== 'object')
|
|
892
|
+
return false;
|
|
893
|
+
if (node.type === 'BinaryOperation' && ['<', '<=', '>', '>=', '==', '!='].includes(node.operator)) {
|
|
894
|
+
return this.containsMember(node, fields);
|
|
895
|
+
}
|
|
896
|
+
return this.anyChild(node, child => this.isFieldValidation(child, fields));
|
|
897
|
+
}
|
|
898
|
+
isRiskyRawPriceArithmetic(node) {
|
|
899
|
+
if (!node || node.type !== 'BinaryOperation')
|
|
900
|
+
return false;
|
|
901
|
+
if (node.operator !== '*' && node.operator !== '/')
|
|
902
|
+
return false;
|
|
903
|
+
if (!this.containsMember(node, ['price', 'answer']))
|
|
904
|
+
return false;
|
|
905
|
+
return !this.containsMember(node, ['expo']);
|
|
906
|
+
}
|
|
907
|
+
hasRiskyRawPriceArithmetic(node) {
|
|
908
|
+
if (!node || typeof node !== 'object')
|
|
909
|
+
return false;
|
|
910
|
+
if (node.type === 'FunctionCall' && this.isRequireOrAssert(node))
|
|
911
|
+
return false;
|
|
912
|
+
if (this.isRiskyRawPriceArithmetic(node))
|
|
913
|
+
return true;
|
|
914
|
+
return this.anyChild(node, child => this.hasRiskyRawPriceArithmetic(child));
|
|
915
|
+
}
|
|
916
|
+
containsTimestamp(node) {
|
|
917
|
+
if (!node || typeof node !== 'object')
|
|
918
|
+
return false;
|
|
919
|
+
if (node.type === 'MemberAccess' &&
|
|
920
|
+
node.memberName === 'timestamp' &&
|
|
921
|
+
node.expression?.type === 'Identifier' &&
|
|
922
|
+
node.expression.name === 'block') {
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
return this.anyChild(node, child => this.containsTimestamp(child));
|
|
926
|
+
}
|
|
927
|
+
containsMember(node, members) {
|
|
928
|
+
if (!node || typeof node !== 'object')
|
|
929
|
+
return false;
|
|
930
|
+
if (node.type === 'MemberAccess' && members.includes(node.memberName))
|
|
931
|
+
return true;
|
|
932
|
+
if (node.type === 'Identifier' && members.includes(node.name))
|
|
933
|
+
return true;
|
|
934
|
+
return this.anyChild(node, child => this.containsMember(child, members));
|
|
935
|
+
}
|
|
936
|
+
containsBoundedNumber(node, max) {
|
|
937
|
+
const value = this.literalNumber(node);
|
|
938
|
+
if (value !== Number.POSITIVE_INFINITY && value <= max)
|
|
939
|
+
return true;
|
|
940
|
+
return this.anyChild(node, child => this.containsBoundedNumber(child, max));
|
|
941
|
+
}
|
|
942
|
+
containsAnyNumber(node) {
|
|
943
|
+
const value = this.literalNumber(node);
|
|
944
|
+
if (value !== Number.POSITIVE_INFINITY)
|
|
945
|
+
return true;
|
|
946
|
+
return this.anyChild(node, child => this.containsAnyNumber(child));
|
|
947
|
+
}
|
|
948
|
+
literalNumber(node) {
|
|
949
|
+
if (!node || typeof node !== 'object')
|
|
950
|
+
return Number.POSITIVE_INFINITY;
|
|
951
|
+
if (node.type === 'NumberLiteral') {
|
|
952
|
+
const raw = String(node.number ?? node.value ?? '').replace(/_/g, '');
|
|
953
|
+
const parsed = Number(raw);
|
|
954
|
+
if (!Number.isFinite(parsed))
|
|
955
|
+
return Number.POSITIVE_INFINITY;
|
|
956
|
+
return parsed * this.timeUnitMultiplier(node.subdenomination);
|
|
957
|
+
}
|
|
958
|
+
return Number.POSITIVE_INFINITY;
|
|
959
|
+
}
|
|
960
|
+
timeUnitMultiplier(unit) {
|
|
961
|
+
switch (unit) {
|
|
962
|
+
case undefined:
|
|
963
|
+
case null:
|
|
964
|
+
case '':
|
|
965
|
+
case 'seconds':
|
|
966
|
+
return 1;
|
|
967
|
+
case 'minutes':
|
|
968
|
+
return 60;
|
|
969
|
+
case 'hours':
|
|
970
|
+
return 60 * 60;
|
|
971
|
+
case 'days':
|
|
972
|
+
return 24 * 60 * 60;
|
|
973
|
+
case 'weeks':
|
|
974
|
+
return 7 * 24 * 60 * 60;
|
|
975
|
+
default:
|
|
976
|
+
return Number.POSITIVE_INFINITY;
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
flattenNames(node) {
|
|
980
|
+
const names = [];
|
|
981
|
+
this.walk(node, child => {
|
|
982
|
+
if (child?.type === 'Identifier')
|
|
983
|
+
names.push(child.name || '');
|
|
984
|
+
if (child?.type === 'MemberAccess')
|
|
985
|
+
names.push(child.memberName || '');
|
|
986
|
+
});
|
|
987
|
+
return names.join(' ');
|
|
988
|
+
}
|
|
989
|
+
walk(node, visit) {
|
|
990
|
+
if (!node || typeof node !== 'object')
|
|
991
|
+
return;
|
|
992
|
+
visit(node);
|
|
993
|
+
for (const child of this.childNodes(node)) {
|
|
994
|
+
this.walk(child, visit);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
anyChild(node, predicate) {
|
|
998
|
+
for (const child of this.childNodes(node)) {
|
|
999
|
+
if (predicate(child))
|
|
1000
|
+
return true;
|
|
1001
|
+
}
|
|
1002
|
+
return false;
|
|
1003
|
+
}
|
|
1004
|
+
childNodes(node) {
|
|
1005
|
+
const children = [];
|
|
1006
|
+
for (const [key, value] of Object.entries(node)) {
|
|
1007
|
+
if (key === 'loc' || key === 'range' || key === 'typeName')
|
|
1008
|
+
continue;
|
|
1009
|
+
if (Array.isArray(value)) {
|
|
1010
|
+
for (const item of value) {
|
|
1011
|
+
if (item && typeof item === 'object')
|
|
1012
|
+
children.push(item);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
else if (value && typeof value === 'object') {
|
|
1016
|
+
children.push(value);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
return children;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
exports.OracleManipulationDetector = OracleManipulationDetector;
|
|
1023
|
+
//# sourceMappingURL=oracle-manipulation.js.map
|