Skip to content

Security: Use defusedxml for XML parsing in MJCF/URDF importers #1028

@coderabbitai

Description

@coderabbitai

Description

The MJCF importer in newton/_src/utils/import_mjcf.py currently uses xml.etree.ElementTree to parse XML input, which is vulnerable to XML attacks such as XML bomb (billion laughs attack) and external entity injection.

While sanitize_xml_content provides some mitigation, it doesn't fully protect against all XML-based attacks. The recommended approach is to use defusedxml.ElementTree instead.

Impact

When parsing untrusted MJCF content (e.g., user-provided XML strings), the application could be vulnerable to:

  • XML bomb attacks leading to resource exhaustion
  • External entity injection
  • Other XML-based exploits

Recommendation

Replace xml.etree.ElementTree with defusedxml.ElementTree with a fallback to the standard library if defusedxml is unavailable.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions