weblab-tw / ddia-study-group

Designing Data-Intensive Applications Study Group
36 stars 5 forks source link

第四章節:例項化任意類是什麼意思 - Emily #45

Open emily40830 opened 2 years ago

emily40830 commented 2 years ago

為了恢復相同物件型別的資料,解碼過程需要 例項化任意類 的能力,這通常是安全問題的一個來源【5】:如果攻擊者可以讓應用程式解碼任意的位元組序列,他們就能例項化任意的類,這會允許他們做可怕的事情,如遠端執行任意程式碼【6,7】

是指說在 runtime 用 reflection 的方式動態生成 instance 嗎? 這邊提到的安全問題是不是指可以任意序列與反序列化編譯過後的檔案? 應該如何避免這類操作的產生(反被反序列化),大家有沒有什麼經驗可以分享?

nissenyeh commented 2 years ago

+1 附上原文

In order to restore data in the same object types, the decoding process needs to be able to instantiate arbitrary classes. This is frequently a source of security problems [5]: if an attacker can get your application to decode an arbitrary byte sequence, they can instantiate arbitrary classes, which in turn often allows them to do terrible things such as remotely executing arbitrary code [6, 7].

kylemocode commented 2 years ago