Skip to content

[Item 50] 방어적 복사를 사용하지 않았을 때의 공격 #43

@ForteEscape

Description

@ForteEscape

Q.
책(p.304)에는 다음과 같이 기술하고 있습니다.

방어적 복사에 Dateclone() 메서드가 사용하지 않은 것도 주목하자. Date는 final이 아니기 때문에 clone이 Date가 정의한 메서드가 아닐 수 있다. 즉 clone이 악의를 가진 하위 클래스의 인스턴스를 반환할 수도 있다. 예컨대 이 하위 클래스는 start와 end 필드의 참조를 private 정적 리스트에 담아뒀다가 공격자에게 이 리스트에 접근하는 길을 열어줄 수도 있다.

혹시 해당 구문에 대한 적절한 예시가 있는지 궁금합니다.

Metadata

Metadata

Assignees

No one assigned

    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