메모리 안전성Memory safety
CWE-416 Use-After-Free
해제된 메모리를 가리키는 포인터(dangling pointer)를 계속 사용하는 결함.Memory is used through a pointer after it has been freed.
근본 원인 패턴Root-cause pattern
소유권/수명 추적 실패: 한 경로에서 객체를 해제했는데 다른 경로가 같은 객체에 대한 참조를 들고 있다. 해제된 슬롯이 공격자 제어 데이터로 재할당되면 오래된 포인터가 그 데이터를 "객체"로 해석한다.Lifetime tracking fails: one path frees an object while another still holds a reference. If the freed slot is reallocated with attacker data, the stale pointer interprets it as an object.
전형적인 패치Typical fix
참조 카운트 증가/감소 순서 교정, 해제 후 포인터 무효화(NULL 대입), 해제를 사용 이후로 지연.Fix refcount ordering, null out pointers after free, or defer the free until after the last use.