Visitar URL original
fix type confusion cve issues for entity_decl nodes by jjjhhhlll · Pull Request #678 · libxmljs/libxmljs · GitHub
Skip to content

fix type confusion cve issues for entity_decl nodes - #678

Open
jjjhhhlll wants to merge 2 commits into
libxmljs:masterfrom
jjjhhhlll:issue-645-check-xmlNode-type-to-prevent-type-confusion
Open

jjjhhhlll wants to merge 2 commits into
libxmljs:masterfrom
jjjhhhlll:issue-645-check-xmlNode-type-to-prevent-type-confusion

Conversation

@jjjhhhlll

Copy link
Copy Markdown

Addresses CVEs:

CVE-2024-34391 by returning XMLNode for entity_decl instead of incorrect XMLElement.

CVE-2024-34392 by throwing an error for namespaces() method when called on entity_decl XMLNode.

I addressed these problems in javascript, since that's the way the rest of the code seems to be handling the casting-based polymorphism of the underlying libxml2 library.

Comment thread lib/node.ts

this.childNodes().forEach((child) => {
xmlUnlinkNode(child.getNativeReference());
child.remove();

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

child.remove is doing xmlUnlinkNode(this.getNativeReference()). tsc doesn't want XMLElement to access the getNativeReference() of XMLNode. By using the remove() method we end up doing the same thing but also satisfying the typescript compiler.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant