Skip to content

Fix: add XmlReaderSettings to prevent XXE attacks#24

Open
HashidaTKS wants to merge 1 commit into
masterfrom
fix/xxe-protection
Open

Fix: add XmlReaderSettings to prevent XXE attacks#24
HashidaTKS wants to merge 1 commit into
masterfrom
fix/xxe-protection

Conversation

@HashidaTKS
Copy link
Copy Markdown
Owner

問題点

XmlSerializerWrapper.Deserialize()XmlReader.Create(filePath)XmlReaderSettings なしで呼び出していた。

デフォルト設定では DTD 処理と外部エンティティの解決が有効になる場合があり、外部から操作された XML ファイルを読み込む際に XXE (XML External Entity) 攻撃が成立する可能性があった。

改善内容

  • XmlReaderSettings を追加し DtdProcessing = DtdProcessing.Prohibit を設定
  • XmlResolver = null で外部エンティティの解決を無効化

Test plan

  • 通常の XML ファイルのデシリアライズが正常に機能することを確認
  • DTD を含む XML ファイルを読み込もうとした際に例外がスローされることを確認

🤖 Generated with Claude Code

XmlReader.Create(filePath) without settings uses default settings that may
allow DTD processing and external entity resolution, making the application
vulnerable to XXE (XML External Entity) injection attacks.

Set DtdProcessing = Prohibit and XmlResolver = null to explicitly disable
DTD processing and external entity resolution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant