Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML schema and DTD validation passes if XML is not well-formed, but still is mostly parseable #159

Closed
rcbarnett-zz opened this issue Oct 17, 2013 · 6 comments
Assignees

Comments

@rcbarnett-zz
Copy link
Contributor

MODSEC-5: A missing and/or bad end tag may cause the XML to not be well formed, but it may still pass validation. It seems that libxml2 is being lax here and inserting the correct end tag into the tree?

* Can this lead to an evasion?
* Can (should) we tell libxml2 to be more strict? 

In the following, the XML parsing yields:

{noformat}
XML: Parsing complete (well_formed 0).
XML parser error: XML: Failed parsing document.
...
XML: Successfully validated payload against DTD: /path/to/SoapEnvelope.dtd
{noformat}

XML (missing 'e' in ):
{noformat}

12123 {noformat}

DTD:
{noformat}

{noformat}

Rules:
{noformat}
SecRule REQUEST_HEADERS:Content-Type "^text/xml$"
"phase:1,t:none,t:lowercase,nolog,pass,ctl:requestBodyProcessor=XML"
SecRule REQBODY_PROCESSOR "!^XML$" nolog,pass,skipAfter:12345
SecRule XML "@validateDTD /path/to/SoapEnvelope.dtd"
"phase:2,deny,id:12345"
{noformat}

@ghost ghost assigned zimmerle Oct 17, 2013
@rcbarnett-zz
Copy link
Contributor Author

Original reporter: brectanus

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Fixed a typo in the description.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Patch to fail XML validation after previous parser error.

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Changeset: 1187

@rcbarnett-zz
Copy link
Contributor Author

ivanr: Why not check msr->xml->well_formed and use a meaningful message such as "XML: DTD validation failed because content is not well formed."?

@rcbarnett-zz
Copy link
Contributor Author

brectanus: Any previous errors are already logged:

[4] XML: Parsing complete (well_formed 0).
[2] XML parser error: XML: Failed parsing document.

This also prevents a possibly well-formed XML that may have had other generic errors.

However, it is a good idea to check that as well and yield a bit more meaningful error. I added that as well.

Changeset 1203

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

No branches or pull requests

2 participants