Skip to content

[DeepSec] Carousel の Embla reInit リスナーが cleanup されない #48

@TkymHrt

Description

@TkymHrt

概要

DeepSec の診断で、carousel component が Embla の reInit event listener を cleanup していないことが検出されました。

影響

src/components/ui/carousel.tsx の effect は、同じ callback を reInitselect の両方に登録しています。しかし cleanup では select の listener だけを解除しており、reInit の listener が残ります。

carousel が unmount / remount された場合や API instance が差し替わった場合、古い reInit listener が残り、重複した state update や古い closure からの update が発生する可能性があります。セキュリティ脆弱性ではありませんが、実害のある lifecycle / resource leak バグです。

対象

  • src/components/ui/carousel.tsx
  • 関連行: 97, 101
  • DeepSec severity: BUG
  • Confidence: high
  • Slug: other-resource-leak

修正案

cleanup で登録した event をすべて解除します。

return () => {
  api.off("select", onSelect)
  api.off("reInit", onSelect)
}

受け入れ条件

  • effect で api.on("reInit", onSelect) した listener が cleanup で解除される
  • unmount / remount 後に古い listener が残らない
  • 既存の carousel 操作に回帰がない

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions