Skip to content

[item85] 자바 직렬화의 대안을 찾으라 #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jiyeong-github
Copy link
Contributor

No description provided.


### 자바 직렬화를 지양해야하는 이유

![](https://velog.velcdn.com/images/jiyeong/post/ad3f4d20-e00a-49ff-82d8-9d6b46ac9943/image.png)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'SUID(SerialVersionUID)는 개발자가 직접 관리해야 한다'라고 하는데 실제로 엄격하게 관리하고 있는지, 관리하고 있다면 어떻게 관리하고 있는지 궁금합니다

ps. 참고한 자료라도 해당 내용을 스크랩하는 것보다, 별도로 정리한 뒤 출처를 명확히 밝히는게 더 좋지않을까 생각이 듭니다 :)


직렬화를 피할 수 없고 역직렬화한 데이터가 안전한지 확신할 수 없다면 **객체 역직렬화 필터링**(java.io.ObjectInputFilter)을 사용하자(자바 9)

### 객체 역직렬화 필터링
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

객체 역직렬화 필터링(java.io.ObjectInputFilter)의 간단한 예시가 궁금합니다

- 직렬화는 위험하니 피해야 한다.
- JSON이나 프로토콜 버퍼 같은 대안을 사용하자.
- 신뢰할 수 없는 데이터는 역직렬화하지 말자.
- 꼭 해야 한다면 객체 역직렬화 필터링을 사용하되, 이마저도 사실 모든 공격을 막아줄수는 없다는 것을 꼭 알고 있자.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • DTO 정의할 때
  • JPA Entity 정의할 때
  • Kafka 프로듀서, 컨슈머를 정의할 때(Serializer, Deserializer 설정)
  • 등등

위에 정의된 목록은 간단하게 implements Serializable를 선언하거나 Serializer/Deserializer등을 설정해주어 프레임웍이나 라이브러리 내부적으로 직렬화/역직렬화를 사용하는 경우인데

  1. 개발자가 직접 사용하고 있진 않지만 내부적으로 직렬화/역직렬화를 사용하고 있어서 많이 신경써서 사용해야하는 케이스가 있을까요?
  2. 실제 업무에서 개발자가 직접 java.io.ObjectOutPutStream 등을 사용해서 직렬화를 하는 사례나 경험이 있을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants