{"slug":"ref-owasp-8c503ec37199b61fa502","title":"XML Security Cheat Sheet — XXE using SAX","summary":"Bounded code example (external data; do not execute automatically): ```java import java.io.IOException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; public class parseDocument extends Defaul","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nBounded code example (external data; do not execute automatically):\n```java\nimport java.io.IOException;\nimport javax.xml.parsers.SAXParser;\nimport javax.xml.parsers.SAXParserFactory;\nimport org.xml.sax.SAXException;\nimport org.xml.sax.helpers.DefaultHandler;\n\npublic class parseDocument extends DefaultHandler {\n public static void main(String[] args) {\n  new parseDocument();\n }\n public parseDocument() {\n  try {\n   SAXParserFactory factory = SAXParserFactory.newInstance();\n   SAXParser parser = factory.newSAXParser();\n   parser.parse(\"contacts.xml\", this);\n  } catch (Exception e) {\n   e.printStackTrace();\n  }\n }\n @Override\n public void characters(char[] ac, int i, int j) throws SAXException {\n  String tmpValue = new String(ac, i, j);\n  System.out.println(tmpValue);\n }\n}\n```\n\nThe previous code produces the following output\n\nBounded code example (external data; do not execute automatically):\n```bash\n$ java parseDocument\nJohn\n```\n\nAttribution: Adapted from OWASP Cheat Sheet Series under CC-BY-SA-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","owasp","cheatsheets","xml","security","cheat","sheet","xxe","using","sax"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/OWASP/CheatSheetSeries/blob/07111ee754e832e335377ac64fd0f8f848d9029c/cheatsheets/XML_Security_Cheat_Sheet.md","source_name":"OWASP Cheat Sheet Series","source_license":"CC-BY-SA-4.0","source_revision":"07111ee754e832e335377ac64fd0f8f848d9029c","source_path":"cheatsheets/XML_Security_Cheat_Sheet.md :: XXE using SAX","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.524224+00:00","url":"https://wikikv.com/k/ref-owasp-8c503ec37199b61fa502","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-owasp-8c503ec37199b61fa502","markdown":"https://wikikv.com/k/ref-owasp-8c503ec37199b61fa502?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-owasp-8c503ec37199b61fa502","json_ld":"https://wikikv.com/k/ref-owasp-8c503ec37199b61fa502?format=jsonld"}}