Python API security testing tool from OpenStack Security Group
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xml_external.py 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """
  2. Copyright 2015 Rackspace
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. """
  13. from syntribos.issue import Issue
  14. from syntribos.tests.fuzz import base_fuzz
  15. class XMLExternalEntityBody(base_fuzz.BaseFuzzTestCase):
  16. test_name = "XML_EXTERNAL_ENTITY_BODY"
  17. test_type = "data"
  18. data_key = "xml-external.txt"
  19. failure_keys = [
  20. 'root:',
  21. 'root@',
  22. 'daemon:',
  23. 'sys:',
  24. '[boot loader]',
  25. '[operating systems]',
  26. 'multi(0)',
  27. 'disk(0)',
  28. 'partition']
  29. def data_driven_failure_cases(self):
  30. failure_assertions = []
  31. if self.failure_keys is None:
  32. return []
  33. for line in self.failure_keys:
  34. failure_assertions.append((self.assertNotIn,
  35. line, self.resp.content))
  36. return failure_assertions
  37. def test_case(self):
  38. self.register_issue(
  39. Issue(test="xml_external_entity",
  40. severity="Medium",
  41. text=("A string known to be commonly returned after a "
  42. "successful XML external entity attack was included "
  43. "in the response. This could indicate a "
  44. "vulnerability to XML entity attacks."),
  45. assertions=self.data_driven_failure_cases()))
  46. self.test_issues()
  47. class XMLExternalEntityParams(XMLExternalEntityBody):
  48. test_name = "XML_EXTERNAL_ENTITY_PARAMS"
  49. test_type = "params"
  50. class XMLExternalEntityHeaders(XMLExternalEntityBody):
  51. test_name = "XML_EXTERNAL_ENTITY_HEADERS"
  52. test_type = "headers"
  53. class XMLExternalEntityURL(XMLExternalEntityBody):
  54. test_name = "XML_EXTERNAL_ENTITY_URL"
  55. test_type = "url"
  56. url_var = "FUZZ"