3. Security and Validation

xmlProtection

Version

Prohibits XML documents to be passed through that look like XML attacks on older parsers. Too many attributes, too long element names are such indications. DTD definitions will simply be removed.

XML documents carried inside a multipart body are inspected part by part, so a document uploaded as an attachment is checked like a plain XML body. A part the plugin had to take a DTD out of is written back into the body; the other parts pass through unchanged.

Example Configuration

- xmlProtection:
maxAttributeCount: 1000
maxElementNameLength: 1000
maxAttributeNameLength: 1000
maxDepth: 50
maxSize: 10000000
removeDTD: true
otherContentTypes: SKIP
- xmlProtection:
     maxAttributeCount: 1000
     maxElementNameLength: 1000
     maxAttributeNameLength: 1000
     maxDepth: 50
     maxSize: 10000000
     removeDTD: true
     otherContentTypes: SKIP

Syntax

xmlProtection:
maxAttributeCount: <int>
maxAttributeNameLength: <int>
maxDepth: <int>
maxElementNameLength: <int>
maxSize: <int>
otherContentTypes: reject
removeDTD: <boolean>
xmlProtection:
  maxAttributeCount: <int>
  maxAttributeNameLength: <int>
  maxDepth: <int>
  maxElementNameLength: <int>
  maxSize: <int>
  otherContentTypes: reject
  removeDTD: <boolean>

Attributes

NameRequiredDefaultDescriptionExamples
maxAttributeCountfalse1000If an incoming request exceeds this limit, it will be discarded.-
maxAttributeNameLengthfalse1000Maximum length of an attribute name, counted as the document spells it, so a qualified name like ns:id counts its prefix and colon too. If an incoming request exceeds this limit, it will be discarded. A value of -1 disables the limit.-
maxDepthfalse-1 (unlimited)Maximum nesting depth of XML elements. If an incoming request exceeds this limit, it will be discarded. A value of -1 disables the limit.-
maxElementNameLengthfalse1000Maximum length of an element name, counted as the document spells it, so a qualified name like ns:order counts its prefix and colon too. If an incoming request exceeds this limit, it will be discarded. A value of -1 disables the limit.-
maxSizefalse104857600Maximum size in bytes of a single XML document. The limit is per document, so in a multipart body it applies to each XML part separately rather than to the whole upload. To cap the size of the entire request, use the limit plugin with its maxBodyLength attribute. A value of -1 disables the limit.-
otherContentTypesfalseREJECTWhat to do with content this plugin does not inspect. This applies both to the body of a request of another type and to the individual parts of a multipart body, so skip allows e.g. an image to be uploaded alongside the document that is checked.

Values: REJECT, SKIP

SKIP
removeDTDfalsetrueWhether to remove the DTD from incoming requests.-

Can be used in