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

encoding/xml: document why round-trip stability is not guaranteed #44405

Open
DemiMarie opened this issue Feb 19, 2021 · 3 comments
Open

encoding/xml: document why round-trip stability is not guaranteed #44405

DemiMarie opened this issue Feb 19, 2021 · 3 comments
Labels
Documentation help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@DemiMarie
Copy link

It is extremely non-obvious why encoding/xml does not guarantee round-trip stability. The package documentation should explain why that is the case, when this is a problem, and what users should do instead.

@ianlancetaylor
Copy link
Contributor

Thanks. Documentation changes don't need to go through the proposal process, so changing this into an ordinary issue.

@ianlancetaylor ianlancetaylor changed the title Proposal: encoding/xml: document why round-trip stability is not guaranteed encoding/xml: document why round-trip stability is not guaranteed Feb 19, 2021
@ianlancetaylor ianlancetaylor added help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed Proposal labels Feb 19, 2021
@ianlancetaylor ianlancetaylor modified the milestones: Proposal, Backlog Feb 19, 2021
@ianlancetaylor
Copy link
Contributor

Note that while I don't know the details this is not necessarily going to be appropriate for the package documentation. It may be a better fit for a blog post.

@DemiMarie
Copy link
Author

What about something like this?

Warning: The encoding/xml package does not guarantee round-trip stability. If one uses encoding/xml to tokenize an XML document, serializes the tokens, and then re-parses the resulting document, it is possible for the resulting token stream to be different than the original. As a result, encoding/xml should not be used in applications where round-trip stability is required, such as XML-DSIG and SAML. Abusing encoding/xml in these applications has lead to security vulnerabilities in the past and is not supported. See <insert blog post here> for details.

Applications that require round-trip stability should use a third-party library that provides such guarantees. According to their maintainers, the following libraries have been designed for this purpose. <insert list here>. Note that these libraries are maintained by third parties and are not endorsed by Google, the Go Project, or the Go Security Team.

Other uses of encoding/xml are security supported. For example, it is considered a security vulnerability if malicious XML can cause encoding/xml to panic, corrupt memory, or consume excessive resources.

This actually brings up another question: is encoding/xml guaranteed to be deterministic? One way to detect round-trip mismatches is to serialize a document and reparse it, and then check that the reparsed document is identical to the original. Is this a sufficient mitigation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants