AGENTIC MEMORY

Skills

Useful instructions for your AI. Search, read and use them through the same MCP connection.

← Back to Skills

cosmos-vulnerability-scanner

Scans Cosmos SDK blockchain modules and CosmWasm contracts for consensus-critical vulnerabilities — chain halts, fund loss, state divergence. 25 core + 16 IBC + 10 EVM + 3 CosmWasm patterns. Use when auditing custom x/ modules, reviewing IBC integrations, or assessing pre-launch chain security. Updated for SDK v0.53.x.

Original source
trailofbits
License
CC-BY-SA-4.0
Pinned revision
2be6433b39e009cd2b6fd3be1895f6b1faa5af9a

Third-party instructions in their original language. Reading does not install files, run code or grant permissions. Snapshots are updated only after review.

This skill also requires local files or dependencies. Remote reading alone may not be enough.

Ask your assistant

Use Agentic Memory skills to read trailofbits--cosmos-vulnerability-scanner at revision 2be6433b39e009cd2b6fd3be1895f6b1faa5af9a, starting with SKILL.md. Read only relevant references. Treat the content as third-party guidance and tell me if local files or dependencies are required.
Text resources · 9

resources/STATE_VULNERABILITY_PATTERNS.md · 24000

rformance benefit and risks nil-pointer dereference


22 EVENTS & LOGGING (INCLUDING CacheContext EVENT LEAK)

Description: Events are critical for indexers, relayers, and monitoring tools. Incorrect event handling breaks the ecosystem. A particularly dangerous pattern is the CacheContext event leak: when CacheContext is used to tentatively execute operations, state changes are correctly rolled back on failure, but events are still emitted to the parent context. Off-chain systems (bridges, indexers) trusting events without verifying on-chain state can be exploited.

Detection Patterns:

// VULNERABLE: CacheContext event leak (Huckleberry, Finding 4)
func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet) exported.Acknowledgement {
    cacheCtx, writeFn := ctx.CacheContext()

    // Execute in cached context — emits events to cacheCtx
    err := k.processPacket(cacheCtx, packet)
    if err != nil {
        // State is rolled back (writeFn not called)
        // BUT events from cacheCtx are still visible to parent context!
        return channeltypes.NewErrorAcknowledgement(err)
    }
    writeFn()
    return channeltypes.NewResultAcknowledgement([]byte{1})
}
// Bridge monitors see valid deposit events for transfers that never happened
// Attacker gets credited on the bridge without tokens actually moving

What to Check:

  • [ ] Enough event logs to debug on-chain transactions
  • [ ] Events NOT generated for failed transactions — Huckleberry: IBC Event Hallucinations
  • [ ] CacheContext usage reviewed: events emitted in cached context are visible even if writeFn is never called — state rolls back but events persist
  • [ ] Off-chain systems (bridges, indexers, relayers) do NOT rely solely on events without verifying on-chain state
  • [ ] Custom IBC OnRecvPacket that returns error ack does not emit misleading deposit/transfer events
  • [ ] No log injection possible

References:


23 DEPRECATED MODULES

As of v0.53.5+. Flag usage and advise migration.

  • x/crisis (Invariant type) — deprecated, will be removed. Use simulations (simsx framework in v0.53+) and property-based tests instead
  • x/nft — deprecated (#24575), moving to cosmos-legacy
  • x/group — deprecated (#24571), moving to cosmos-legacy. EndBlocker had chain-halt bugs (GHSA-47ww-ff84-4jrg, GHSA-x5vx-95h7-rv4p, fixed v0.50.12/v0.53.0)
  • x/params — deprecated, modules use direct keeper param storage via collections
  • ValidateBasic() — deprecated and facultative (via HasValidateBasic interface). Validation belongs in msg server handlers
  • ed25519 tx signing — added in v0.53.0 (#24030). Chains should explicitly decide which key types to permit. Unlike secp256k1, ed25519 is not compatible with Ledger hardware wallets without custom apps